Ejemplo n.º 1
0
    def getAllInstalled(self, testLoad=True):
        """ Build the localCache """
        self.localCache = {}

        # reversed list of the plugin paths: first system plugins -> then user plugins -> finally custom path(s)
        pluginPaths = list(plugin_paths)
        pluginPaths.reverse()

        for pluginsPath in pluginPaths:
            isTheSystemDir = (pluginPaths.index(pluginsPath) == 0
                              )  # The curent dir is the system plugins dir
            if isTheSystemDir:
                # temporarily add the system path as the first element to force loading the readonly plugins, even if masked by user ones.
                sys.path = [pluginsPath] + sys.path
            try:
                pluginDir = QDir(pluginsPath)
                pluginDir.setFilter(QDir.AllDirs)
                for key in pluginDir.entryList():
                    if key not in [".", ".."]:
                        path = QDir.convertSeparators(pluginsPath + "/" + key)
                        # readOnly = not QFileInfo(pluginsPath).isWritable() # On windows testing the writable status isn't reliable.
                        readOnly = isTheSystemDir  # Assume only the system plugins are not writable.
                        # only test those not yet loaded. Loaded plugins already proved they're o.k.
                        # failedToLoad = settings.value("/PythonPlugins/watchDog/" + key) is not None
                        testLoadThis = testLoad and key not in qgis.utils.plugins
                        plugin = self.getInstalledPlugin(key,
                                                         path=path,
                                                         readOnly=readOnly,
                                                         testLoad=testLoadThis)
                        self.localCache[key] = plugin
                        if key in self.localCache.keys() and compareVersions(
                                self.localCache[key]["version_installed"],
                                plugin["version_installed"]) == 1:
                            # An obsolete plugin in the "user" location is masking a newer one in the "system" location!
                            self.obsoletePlugins += [key]
            except:
                # it's not necessary to stop if one of the dirs is inaccessible
                pass

            if isTheSystemDir:
                # remove the temporarily added path
                sys.path.remove(pluginsPath)
Ejemplo n.º 2
0
    def getAllInstalled(self, testLoad=True):
        """ Build the localCache """
        self.localCache = {}

        # reversed list of the plugin paths: first system plugins -> then user plugins -> finally custom path(s)
        pluginPaths = list(plugin_paths)
        pluginPaths.reverse()

        for pluginsPath in pluginPaths:
            isTheSystemDir = (pluginPaths.index(pluginsPath) == 0)  # The curent dir is the system plugins dir
            if isTheSystemDir:
                # temporarily add the system path as the first element to force loading the readonly plugins, even if masked by user ones.
                sys.path = [pluginsPath] + sys.path
            try:
                pluginDir = QDir(pluginsPath)
                pluginDir.setFilter(QDir.AllDirs)
                for key in pluginDir.entryList():
                    if key not in [".", ".."]:
                        path = QDir.convertSeparators(pluginsPath + "/" + key)
                        # readOnly = not QFileInfo(pluginsPath).isWritable() # On windows testing the writable status isn't reliable.
                        readOnly = isTheSystemDir                            # Assume only the system plugins are not writable.
                        # only test those not yet loaded. Loaded plugins already proved they're o.k.
                        # failedToLoad = settings.value("/PythonPlugins/watchDog/" + key) is not None
                        testLoadThis = testLoad and key not in qgis.utils.plugins
                        plugin = self.getInstalledPlugin(key, path=path, readOnly=readOnly, testLoad=testLoadThis)
                        self.localCache[key] = plugin
                        if key in self.localCache.keys() and compareVersions(self.localCache[key]["version_installed"], plugin["version_installed"]) == 1:
                            # An obsolete plugin in the "user" location is masking a newer one in the "system" location!
                            self.obsoletePlugins += [key]
            except:
                # it's not necessary to stop if one of the dirs is inaccessible
                pass

            if isTheSystemDir:
                # remove the temporarily added path
                sys.path.remove(pluginsPath)