utils_py.diff
| utils.py (working copy) | ||
|---|---|---|
| 71 | 71 | |
| 72 | 72 |
def findPlugins(path): |
| 73 | 73 |
plugins = [] |
| 74 |
for plugin in glob.glob(path + "/plugins/*"): |
|
| 75 |
if os.path.isdir(plugin): |
|
| 76 |
plugins.append( os.path.basename(plugin) ) |
|
| 77 |
|
|
| 74 |
try: |
|
| 75 |
for plugin in glob.glob(path + "/*/__init__.py*"): |
|
| 76 |
plugindir = os.path.split(plugin)[0] |
|
| 77 |
plugin = os.path.basename(plugindir) |
|
| 78 |
if plugin not in plugins: |
|
| 79 |
plugins.append( plugin ) |
|
| 80 |
except: |
|
| 81 |
pass |
|
| 78 | 82 |
return plugins |
| 79 | 83 | |
| 80 | 84 |
def updateAvailablePlugins(): |
| 81 | 85 |
from qgis.core import QgsApplication |
| 82 |
pythonPath = unicode(QgsApplication.pkgDataPath()) + "/python" |
|
| 83 |
homePythonPath = unicode(QgsApplication.qgisSettingsDirPath()) + "/python" |
|
| 86 |
plugindirs = [ |
|
| 87 |
(QgsApplication.pkgDataPath()) + "/python/plugins", |
|
| 88 |
unicode(QgsApplication.qgisSettingsDirPath()) + "/python/plugins" |
|
| 89 |
] |
|
| 90 |
env = os.environ.get("QGIS_PLUGINPATH")
|
|
| 91 |
if env: |
|
| 92 |
plugindirs.extend(env.split(";"))
|
|
| 84 | 93 | |
| 85 |
plugins = findPlugins( pythonPath ) |
|
| 86 |
homePlugins = findPlugins( homePythonPath ) |
|
| 87 | ||
| 88 | 94 |
# merge the lists |
| 89 |
for p in homePlugins: |
|
| 90 |
if p not in plugins: |
|
| 91 |
plugins.append(p) |
|
| 95 |
plugins = [] |
|
| 96 |
for path in plugindirs: |
|
| 97 |
pluginpath = path+"/plugins" |
|
| 98 |
newplugins = findPlugins(path) |
|
| 99 |
if len(newplugins) > 0: |
|
| 100 |
if pluginpath not in sys.path: |
|
| 101 |
sys.path.append(pluginpath) |
|
| 102 |
for p in newplugins: |
|
| 103 |
if p not in plugins: |
|
| 104 |
plugins.append(p) |
|
| 92 | 105 | |
| 93 | 106 |
global available_plugins |
| 94 | 107 |
available_plugins = plugins |