[GRASS-SVN] r53514 - grass/branches/develbranch_6/gui/wxpython/core

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Oct 20 04:38:36 PDT 2012


Author: martinl
Date: 2012-10-20 04:38:36 -0700 (Sat, 20 Oct 2012)
New Revision: 53514

Modified:
   grass/branches/develbranch_6/gui/wxpython/core/gcmd.py
   grass/branches/develbranch_6/gui/wxpython/core/globalvar.py
Log:
wxGUI: define BIN/SCT_EXT


Modified: grass/branches/develbranch_6/gui/wxpython/core/gcmd.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/core/gcmd.py	2012-10-20 11:32:17 UTC (rev 53513)
+++ grass/branches/develbranch_6/gui/wxpython/core/gcmd.py	2012-10-20 11:38:36 UTC (rev 53514)
@@ -526,12 +526,12 @@
         
         # TODO: replace ugly hack bellow
         args = self.cmd
-        if sys.platform == 'win32' and os.path.splitext(self.cmd[0])[1] == '.py':
+        if sys.platform == 'win32' and os.path.splitext(self.cmd[0])[1] == globalvar.SCT_EXT:
             os.chdir(os.path.join(os.getenv('GISBASE'), 'etc', 'gui', 'scripts'))
             args = [sys.executable, self.cmd[0]] + self.cmd[1:]
         if sys.platform == 'win32' and os.getenv('GRASS_ADDON_PATH') and \
-                os.path.exists(os.path.join(os.getenv('GRASS_ADDON_PATH'), self.cmd[0] + '.bat')):
-            args[0] = self.cmd[0] + '.bat'
+                os.path.exists(os.path.join(os.getenv('GRASS_ADDON_PATH'), self.cmd[0] + globalvar.SCT_EXT)):
+            args[0] = self.cmd[0] + globalvar.SCT_EXT
             env = copy.deepcopy(self.env)
             env['PATH'] = os.path.join(os.getenv('GISBASE').replace('/', '\\'), 'scripts') + \
                 os.pathsep + env['PATH']

Modified: grass/branches/develbranch_6/gui/wxpython/core/globalvar.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/core/globalvar.py	2012-10-20 11:32:17 UTC (rev 53513)
+++ grass/branches/develbranch_6/gui/wxpython/core/globalvar.py	2012-10-20 11:38:36 UTC (rev 53514)
@@ -104,6 +104,12 @@
 MAP_WINDOW_SIZE = (800, 600)
 GM_WINDOW_SIZE = (500, 600)
 
+if sys.platform == 'win32':
+    BIN_EXT = '.exe'
+    SCT_EXT = '.bat'
+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 @@
     gisbase = os.environ['GISBASE']
     cmd = list()
     if sys.platform == 'win32':
-        scripts = { '.bat' : list(),
-                    '.py'  : list()
-                    }
+        scripts = { SCT_EXT : list() }
     else:
         scripts = {}
     
@@ -177,13 +181,13 @@
                 continue
             if grassScripts: # win32
                 name, ext = os.path.splitext(fname)
-                if ext not in ['.exe', '.bat']:
+                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 == '.bat' and \
+                if ext == SCT_EXT and \
                         ext in grassScripts.keys() and \
                         name not in grassScripts[ext]:
                     grassScripts[ext].append(name)



More information about the grass-commit mailing list