Skip to content
Permalink
Browse files
[FEATURE] support for custom plugin directories using QGIS_PLUGINPATH…
… environment variables.

More paths can be passed, separated by semicolon. Patch from Chris Crook (#2608), slightly modified.


git-svn-id: http://svn.osgeo.org/qgis/trunk@13236 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Apr 4, 2010
1 parent a022e55 commit 610f356975db1b16d90336ae672e8976df2de4e8
Showing with 18 additions and 11 deletions.
  1. +18 −11 python/utils.py
@@ -71,24 +71,31 @@ def initInterface(pointer):

def findPlugins(path):
plugins = []
for plugin in glob.glob(path + "/plugins/*"):
if os.path.isdir(plugin):
for plugin in glob.glob(path + "/*"):
if os.path.isdir(plugin) and os.path.exists(os.path.join(plugin, '__init__.py')):
plugins.append( os.path.basename(plugin) )

return plugins

def updateAvailablePlugins():
from qgis.core import QgsApplication
pythonPath = unicode(QgsApplication.pkgDataPath()) + "/python"
homePythonPath = unicode(QgsApplication.qgisSettingsDirPath()) + "/python"

plugins = findPlugins( pythonPath )
homePlugins = findPlugins( homePythonPath )
plugindirs = [
unicode(QgsApplication.pkgDataPath()) + "/python/plugins",
unicode(QgsApplication.qgisSettingsDirPath()) + "/python/plugins"
]
env = os.environ.get("QGIS_PLUGINPATH")
if env:
plugindirs.extend(env.split(";"))

# merge the lists
for p in homePlugins:
if p not in plugins:
plugins.append(p)
plugins = []
for pluginpath in plugindirs:
newplugins = findPlugins(pluginpath)
if len(newplugins) > 0:
if pluginpath not in sys.path:
sys.path.append(pluginpath)
for p in newplugins:
if p not in plugins:
plugins.append(p)

global available_plugins
available_plugins = plugins

0 comments on commit 610f356

Please sign in to comment.