Browse Source

wxGUI: add addons module to the path (be more safe)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@48547 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 13 năm trước cách đây
mục cha
commit
247eb709e2
1 tập tin đã thay đổi với 10 bổ sung6 xóa
  1. 10 6
      gui/wxpython/gui_modules/globalvar.py

+ 10 - 6
gui/wxpython/gui_modules/globalvar.py

@@ -154,12 +154,16 @@ def GetGRASSCmds(bin = True, scripts = True, gui_scripts = True, addons = True):
     
     if addons and os.getenv('GRASS_ADDON_PATH'):
         path = os.getenv('GRASS_ADDON_PATH')
-        for executable in os.listdir(os.path.join(path, 'bin')):
-            ext = os.path.splitext(executable)[1]
-            if not EXT_BIN or \
-                    ext in (EXT_BIN, EXT_SCT):
-                cmd.append(executable)
-        cmd += os.listdir(os.path.join(path, 'scripts'))
+        bpath = os.path.join(path, 'bin')
+        spath = os.path.join(path, 'scripts')
+        if os.path.exists(bpath) and os.path.isdir(bpath):
+            for executable in os.listdir(bpath):
+                ext = os.path.splitext(executable)[1]
+                if not EXT_BIN or \
+                        ext in (EXT_BIN, EXT_SCT):
+                    cmd.append(executable)
+        if os.path.exists(spath) and os.path.isdir(spath):
+            cmd += os.listdir(spath)
     
     if sys.platform == 'win32':
         for idx in range(len(cmd)):