Skip to content

Commit

Permalink
Merge pull request #5532 from borysiasty/nopreloading
Browse files Browse the repository at this point in the history
[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 4677026
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
4 changes: 2 additions & 2 deletions python/pyplugin_installer/installer.py
Expand Up @@ -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"]:
Expand Down Expand Up @@ -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):
Expand Down
23 changes: 3 additions & 20 deletions python/pyplugin_installer/installer_data.py
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -683,7 +668,7 @@ def pluginMetadata(fct):
return plugin

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

Expand All @@ -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]
Expand Down

0 comments on commit 4677026

Please sign in to comment.