Parcourir la source

wxGUI: define BIN/SCT_EXT

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@53513 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa il y a 12 ans
Parent
commit
619761cc91
2 fichiers modifiés avec 12 ajouts et 8 suppressions
  1. 3 3
      gui/wxpython/core/gcmd.py
  2. 9 5
      gui/wxpython/core/globalvar.py

+ 3 - 3
gui/wxpython/core/gcmd.py

@@ -528,11 +528,11 @@ class CommandThread(Thread):
         # TODO: replace ugly hack bellow
         args = self.cmd
         if sys.platform == 'win32':
-            ext = os.path.splitext(self.cmd[0])[1] == '.py'
-            if ext or self.cmd[0] in globalvar.grassScripts['.py']:
+            ext = os.path.splitext(self.cmd[0])[1] == globalvar.SCT_EXT
+            if ext or self.cmd[0] in globalvar.grassScripts[globalvar.SCT_EXT]:
                 os.chdir(os.path.join(os.getenv('GISBASE'), 'scripts'))
                 if not ext:
-                    args = [sys.executable, self.cmd[0] + '.py'] + self.cmd[1:]
+                    args = [sys.executable, self.cmd[0] + globalvar.SCT_EXT] + self.cmd[1:]
                 else:
                     args = [sys.executable, self.cmd[0]] + self.cmd[1:]
         

+ 9 - 5
gui/wxpython/core/globalvar.py

@@ -104,6 +104,12 @@ DIALOG_COLOR_SIZE = (30, 30)
 MAP_WINDOW_SIZE = (800, 600)
 GM_WINDOW_SIZE = (500, 600)
 
+if sys.platform == 'win32':
+    BIN_EXT = '.exe'
+    SCT_EXT = '.py'
+else:
+    BIN_EXT = SCT_EXT = ''
+
 def GetGRASSCommands():
     """!Create list of available GRASS commands to use when parsing
     string from the command line
@@ -114,9 +120,7 @@ def GetGRASSCommands():
     gisbase = os.environ['GISBASE']
     cmd = list()
     if sys.platform == 'win32':
-        scripts = { '.bat' : list(),
-                    '.py'  : list()
-                    }
+        scripts = { SCT_EXT : list() }
     else:
         scripts = {}
     
@@ -182,13 +186,13 @@ def UpdateGRASSAddOnCommands(eList = None):
             if grassScripts: # win32
                 name, ext = os.path.splitext(fname)
                 if name not in grassCmd:
-                    if ext not in ['.exe', '.py']:
+                    if ext not in [BIN_EXT, SCT_EXT]:
                         continue
                     if name not in grassCmd:
                         grassCmd.add(name)
                         Debug.msg(3, "AddOn commands: %s", name)
                         nCmd += 1
-                if ext == '.py' and \
+                if ext == SCT_EXT and \
                         ext in grassScripts.keys() and \
                         name not in grassScripts[ext]:
                     grassScripts[ext].append(name)