mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-19 00:04:52 -04:00
[Plugin Installer] Don't forget about plugins in QGIS-PLUGINPATH env variable. Fix #8376
This commit is contained in:
parent
34c3b44c29
commit
b9c9ec440b
@ -32,7 +32,7 @@ import codecs
|
|||||||
import ConfigParser
|
import ConfigParser
|
||||||
import qgis.utils
|
import qgis.utils
|
||||||
from qgis.core import *
|
from qgis.core import *
|
||||||
from qgis.utils import iface
|
from qgis.utils import iface, plugin_paths
|
||||||
from version_compare import compareVersions, normalizeVersion, isCompatible
|
from version_compare import compareVersions, normalizeVersion, isCompatible
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@ -563,7 +563,7 @@ class Plugins(QObject):
|
|||||||
|
|
||||||
|
|
||||||
# ----------------------------------------- #
|
# ----------------------------------------- #
|
||||||
def getInstalledPlugin(self, key, readOnly, testLoad=True):
|
def getInstalledPlugin(self, key, path, readOnly, testLoad=True):
|
||||||
""" get the metadata of an installed plugin """
|
""" get the metadata of an installed plugin """
|
||||||
def metadataParser(fct):
|
def metadataParser(fct):
|
||||||
""" plugin metadata parser reimplemented from qgis.utils
|
""" plugin metadata parser reimplemented from qgis.utils
|
||||||
@ -590,11 +590,6 @@ class Plugins(QObject):
|
|||||||
if value: return value
|
if value: return value
|
||||||
return metadataParser( fct )
|
return metadataParser( fct )
|
||||||
|
|
||||||
if readOnly:
|
|
||||||
path = QDir.cleanPath( QgsApplication.pkgDataPath() ) + "/python/plugins/" + key
|
|
||||||
else:
|
|
||||||
path = QDir.cleanPath( QgsApplication.qgisSettingsDirPath() ) + "/python/plugins/" + key
|
|
||||||
|
|
||||||
if not QDir(path).exists():
|
if not QDir(path).exists():
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -681,39 +676,38 @@ class Plugins(QObject):
|
|||||||
def getAllInstalled(self, testLoad=True):
|
def getAllInstalled(self, testLoad=True):
|
||||||
""" Build the localCache """
|
""" Build the localCache """
|
||||||
self.localCache = {}
|
self.localCache = {}
|
||||||
# first, try to add the readonly plugins...
|
|
||||||
pluginsPath = unicode(QDir.convertSeparators(QDir.cleanPath(QgsApplication.pkgDataPath() + "/python/plugins")))
|
# 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.
|
# 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
|
sys.path = [pluginsPath] + sys.path
|
||||||
try:
|
try:
|
||||||
pluginDir = QDir(pluginsPath)
|
pluginDir = QDir(pluginsPath)
|
||||||
pluginDir.setFilter(QDir.AllDirs)
|
pluginDir.setFilter(QDir.AllDirs)
|
||||||
for key in pluginDir.entryList():
|
for key in pluginDir.entryList():
|
||||||
key = unicode(key)
|
|
||||||
if not key in [".",".."]:
|
if not key in [".",".."]:
|
||||||
# only test those not yet loaded. Others proved they're o.k.
|
path = QDir.convertSeparators( pluginsPath + "/" + key )
|
||||||
self.localCache[key] = self.getInstalledPlugin(key, readOnly=True, testLoad=testLoad and not qgis.utils.plugins.has_key(key))
|
# readOnly = not QFileInfo(pluginsPath).isWritable() # On windows testing the writable status isn't reliable.
|
||||||
except:
|
readOnly = isTheSystemDir # Assume only the system plugins are not writable.
|
||||||
# return QCoreApplication.translate("QgsPluginInstaller","Couldn't open the system plugin directory")
|
# only test those not yet loaded. Loaded plugins already proved they're o.k.
|
||||||
pass # it's not necessary to stop due to this error
|
testLoadThis = testLoad and not qgis.utils.plugins.has_key(key)
|
||||||
# remove the temporarily added path
|
plugin = self.getInstalledPlugin(key, path=path, readOnly=readOnly, testLoad=testLoadThis)
|
||||||
sys.path.remove(pluginsPath)
|
self.localCache[key] = plugin
|
||||||
# ...then try to add locally installed ones
|
|
||||||
try:
|
|
||||||
pluginDir = QDir.convertSeparators(QDir.cleanPath(QgsApplication.qgisSettingsDirPath() + "/python/plugins"))
|
|
||||||
pluginDir = QDir(pluginDir)
|
|
||||||
pluginDir.setFilter(QDir.AllDirs)
|
|
||||||
except:
|
|
||||||
return QCoreApplication.translate("QgsPluginInstaller","Couldn't open the local plugin directory")
|
|
||||||
for key in pluginDir.entryList():
|
|
||||||
key = unicode(key)
|
|
||||||
if not key in [".",".."]:
|
|
||||||
# only test those not yet loaded. Others proved they're o.k.
|
|
||||||
plugin = self.getInstalledPlugin(key, readOnly=False, testLoad=testLoad and not qgis.utils.plugins.has_key(key))
|
|
||||||
if key in self.localCache.keys() and compareVersions(self.localCache[key]["version_installed"],plugin["version_installed"]) == 1:
|
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!
|
# An obsolete plugin in the "user" location is masking a newer one in the "system" location!
|
||||||
self.obsoletePlugins += [key]
|
self.obsoletePlugins += [key]
|
||||||
self.localCache[key] = plugin
|
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)
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------- #
|
# ----------------------------------------- #
|
||||||
|
Loading…
x
Reference in New Issue
Block a user