Procházet zdrojové kódy

wxGUI: add addons module to the path

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@48545 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa před 13 roky
rodič
revize
6e13be7a4e
1 změnil soubory, kde provedl 15 přidání a 3 odebrání
  1. 15 3
      gui/wxpython/gui_modules/globalvar.py

+ 15 - 3
gui/wxpython/gui_modules/globalvar.py

@@ -124,7 +124,7 @@ else:
     EXT_BIN = ''
     EXT_BIN = ''
     EXT_SCT = ''
     EXT_SCT = ''
 
 
-def GetGRASSCmds(bin = True, scripts = True, gui_scripts = True):
+def GetGRASSCmds(bin = True, scripts = True, gui_scripts = True, addons = True):
     """!Create list of available GRASS commands to use when parsing
     """!Create list of available GRASS commands to use when parsing
     string from the command line
     string from the command line
 
 
@@ -134,6 +134,7 @@ def GetGRASSCmds(bin = True, scripts = True, gui_scripts = True):
     """
     """
     gisbase = os.environ['GISBASE']
     gisbase = os.environ['GISBASE']
     cmd = list()
     cmd = list()
+    
     if bin:
     if bin:
         for executable in os.listdir(os.path.join(gisbase, 'bin')):
         for executable in os.listdir(os.path.join(gisbase, 'bin')):
             ext = os.path.splitext(executable)[1]
             ext = os.path.splitext(executable)[1]
@@ -143,12 +144,23 @@ def GetGRASSCmds(bin = True, scripts = True, gui_scripts = True):
         
         
         # add special call for setting vector colors
         # add special call for setting vector colors
         cmd.append('vcolors')
         cmd.append('vcolors')
+    
     if scripts:
     if scripts:
-        cmd = cmd + os.listdir(os.path.join(gisbase, 'scripts')) 
+        cmd += os.listdir(os.path.join(gisbase, 'scripts'))
+    
     if gui_scripts:
     if gui_scripts:
         os.environ["PATH"] = os.getenv("PATH") + os.pathsep + os.path.join(gisbase, 'etc', 'gui', 'scripts')
         os.environ["PATH"] = os.getenv("PATH") + os.pathsep + os.path.join(gisbase, 'etc', 'gui', 'scripts')
         cmd = cmd + os.listdir(os.path.join(gisbase, 'etc', 'gui', 'scripts'))
         cmd = cmd + os.listdir(os.path.join(gisbase, 'etc', 'gui', 'scripts'))
     
     
+    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'))
+    
     if sys.platform == 'win32':
     if sys.platform == 'win32':
         for idx in range(len(cmd)):
         for idx in range(len(cmd)):
             name, ext = os.path.splitext(cmd[idx])
             name, ext = os.path.splitext(cmd[idx])
@@ -159,7 +171,7 @@ def GetGRASSCmds(bin = True, scripts = True, gui_scripts = True):
 
 
 """@brief Collected GRASS-relared binaries/scripts"""
 """@brief Collected GRASS-relared binaries/scripts"""
 grassCmd = {}
 grassCmd = {}
-grassCmd['all'] = GetGRASSCmds()
+grassCmd['all']    = GetGRASSCmds()
 grassCmd['script'] = GetGRASSCmds(bin = False, gui_scripts = False)
 grassCmd['script'] = GetGRASSCmds(bin = False, gui_scripts = False)
 
 
 """@Toolbar icon size"""
 """@Toolbar icon size"""