Skip to content
Permalink
Browse files

Merge pull request #5532 from borysiasty/nopreloading

[Plugin manager] [needs-doc] Don't preload all plugins for a test
  • Loading branch information
borysiasty committed Nov 7, 2017
2 parents cb8fc68 + a8f4665 commit 4677026c3eb62be2ad71886fdd236cfadcbe8947
Showing with 5 additions and 22 deletions.
  1. +2 −2 python/pyplugin_installer/installer.py
  2. +3 −20 python/pyplugin_installer/installer_data.py
@@ -307,7 +307,7 @@ def installPlugin(self, key, quiet=False):
updateAvailablePlugins()
# try to load the plugin
loadPlugin(plugin["id"])
plugins.getAllInstalled(testLoad=True)
plugins.getAllInstalled()
plugins.rebuild()
plugin = plugins.all()[key]
if not plugin["error"]:
@@ -565,7 +565,7 @@ def installFromZipFile(self, filePath):
if infoString is None:
updateAvailablePlugins()
loadPlugin(pluginName)
plugins.getAllInstalled(testLoad=True)
plugins.getAllInstalled()
plugins.rebuild()

if settings.contains('/PythonPlugins/' + pluginName):
@@ -548,7 +548,7 @@ def removeRepository(self, repo):
del self.repoCache[repo]

# ----------------------------------------- #
def getInstalledPlugin(self, key, path, readOnly, testLoad=True):
def getInstalledPlugin(self, key, path, readOnly):
""" get the metadata of an installed plugin """
def metadataParser(fct):
""" plugin metadata parser reimplemented from qgis.utils
@@ -602,21 +602,6 @@ def pluginMetadata(fct):
if not isCompatible(Qgis.QGIS_VERSION, qgisMinimumVersion, qgisMaximumVersion):
error = "incompatible"
errorDetails = "%s - %s" % (qgisMinimumVersion, qgisMaximumVersion)
elif testLoad:
# only testLoad if compatible version
try:
pkg = __import__(key)
reload(pkg)
pkg.classFactory(iface)
except Exception as e:
error = "broken"
errorDetails = str(e.args[0])
except SystemExit as e:
error = "broken"
errorDetails = QCoreApplication.translate("QgsPluginInstaller", "The plugin exited with error status: {0}").format(e.args[0])
except:
error = "broken"
errorDetails = QCoreApplication.translate("QgsPluginInstaller", "Unknown error")
elif not os.path.exists(metadataFile):
error = "broken"
errorDetails = QCoreApplication.translate("QgsPluginInstaller", "Missing metadata file")
@@ -683,7 +668,7 @@ def pluginMetadata(fct):
return plugin

# ----------------------------------------- #
def getAllInstalled(self, testLoad=True):
def getAllInstalled(self):
""" Build the localCache """
self.localCache = {}

@@ -704,10 +689,8 @@ def getAllInstalled(self, testLoad=True):
path = QDir.toNativeSeparators(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)
plugin = self.getInstalledPlugin(key, path=path, readOnly=readOnly)
if key in list(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]

0 comments on commit 4677026

Please sign in to comment.
You can’t perform that action at this time.