예제 #1
0
 def __init__(self, pluginManager, pluginFileNames, parent=None):
     """
     Constructor
     
     @param pluginManager reference to the plugin manager object
     @param pluginFileNames list of plugin files suggested for
         installation (list of strings)
     @param parent parent of this dialog (QWidget)
     """
     super(PluginInstallWidget, self).__init__(parent)
     self.setupUi(self)
     
     if pluginManager is None:
         # started as external plugin installer
         from .PluginManager import PluginManager
         self.__pluginManager = PluginManager(doLoadPlugins=False)
         self.__external = True
     else:
         self.__pluginManager = pluginManager
         self.__external = False
     
     self.__backButton = self.buttonBox.addButton(
         self.tr("< Back"), QDialogButtonBox.ActionRole)
     self.__nextButton = self.buttonBox.addButton(
         self.tr("Next >"), QDialogButtonBox.ActionRole)
     self.__finishButton = self.buttonBox.addButton(
         self.tr("Install"), QDialogButtonBox.ActionRole)
     
     self.__closeButton = self.buttonBox.button(QDialogButtonBox.Close)
     self.__cancelButton = self.buttonBox.button(QDialogButtonBox.Cancel)
     
     userDir = self.__pluginManager.getPluginDir("user")
     if userDir is not None:
         self.destinationCombo.addItem(
             self.tr("User plugins directory"),
             userDir)
     
     globalDir = self.__pluginManager.getPluginDir("global")
     if globalDir is not None and os.access(globalDir, os.W_OK):
         self.destinationCombo.addItem(
             self.tr("Global plugins directory"),
             globalDir)
     
     self.__installedDirs = []
     self.__installedFiles = []
     
     self.__restartNeeded = False
     
     downloadDir = QDir(Preferences.getPluginManager("DownloadPath"))
     for pluginFileName in pluginFileNames:
         fi = QFileInfo(pluginFileName)
         if fi.isRelative():
             pluginFileName = QFileInfo(
                 downloadDir, fi.fileName()).absoluteFilePath()
         self.archivesList.addItem(pluginFileName)
         self.archivesList.sortItems()
     
     self.__currentIndex = 0
     self.__selectPage()
예제 #2
0
    def _fileinfo_from_user(self, user_path):
        """ Convert the name of a file or directory specified by the user to a
        QFileInfo instance.  A user path may be relative to the name of the
        project and may contain environment variables.
        """

        fi = QFileInfo(self.expandvars(user_path.strip()))

        if fi.isRelative() and self._name is not None:
            fi = QFileInfo(self._name.canonicalPath() + '/' + fi.filePath())

        return fi
예제 #3
0
    def _fileinfo_from_user(self, user_path):
        """ Convert the name of a file or directory specified by the user to a
        QFileInfo instance.  A user path may be relative to the name of the
        project and may contain environment variables.
        """

        fi = QFileInfo(self.expandvars(user_path.strip()))

        if fi.isRelative() and self._name is not None:
            fi = QFileInfo(self._name.canonicalPath() + '/' + fi.filePath())

        return fi
예제 #4
0
def copyFiles(filesToCopy, out_dir):
    plugin_dir = pluginDir()
    for item in filesToCopy:
        dest_dir = os.path.join(out_dir, item.get("dest", ""))
        subdirs = item.get("subdirs", False)
        overwrite = item.get("overwrite", False)

        if DEBUG_MODE:
            qDebug(str(item))
            qDebug("dest dir: %s" % dest_dir)

        # make destination directory
        QDir().mkpath(dest_dir)

        # copy files
        for f in item.get("files", []):
            fi = QFileInfo(f)
            dest = os.path.join(dest_dir, fi.fileName())
            if fi.isRelative():
                copyFile(os.path.join(plugin_dir, f), dest, overwrite)
            else:
                copyFile(f, dest, overwrite)

        # copy directories
        for d in item.get("dirs", []):
            fi = QFileInfo(d)
            source = os.path.join(plugin_dir, d) if fi.isRelative() else d
            dest = os.path.join(dest_dir, fi.fileName())
            if subdirs:
                copyDir(source, dest, overwrite)
            else:
                # make destination directory
                QDir().mkpath(dest)

                # copy files in the source directory
                filenames = QDir(source).entryList(QDir.Files)
                for filename in filenames:
                    copyFile(os.path.join(source, filename),
                             os.path.join(dest, filename), overwrite)