[GRASS-SVN] r49567 - in grass/branches/develbranch_6: gui/wxpython/gui_modules lib/python

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Dec 6 12:22:42 EST 2011


Author: martinl
Date: 2011-12-06 09:22:42 -0800 (Tue, 06 Dec 2011)
New Revision: 49567

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/gcmd.py
   grass/branches/develbranch_6/lib/python/core.py
   grass/branches/develbranch_6/lib/python/task.py
Log:
attempt to fix #1496 - TODO: replace such ugly hacks with something more reasonable in the future
	(merge r49565 from trunk)


Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gcmd.py	2011-12-06 17:14:43 UTC (rev 49566)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gcmd.py	2011-12-06 17:22:42 UTC (rev 49567)
@@ -476,8 +476,15 @@
         Debug.msg(1, "gcmd.CommandThread(): %s" % ' '.join(self.cmd))
 
         self.startTime = time.time()
+
+        # TODO: replace ugly hack bellow
+        args = self.cmd
+        if sys.platform == 'win32' and os.path.splitext(self.cmd[0])[1] == '.py':
+            os.chdir(os.path.join(os.getenv('GISBASE'), 'etc', 'gui', 'scripts'))
+            args = [sys.executable, self.cmd[0]] + self.cmd[1:]
+        
         try:
-            self.module = Popen(self.cmd,
+            self.module = Popen(args,
                                 stdin = subprocess.PIPE,
                                 stdout = subprocess.PIPE,
                                 stderr = subprocess.PIPE,

Modified: grass/branches/develbranch_6/lib/python/core.py
===================================================================
--- grass/branches/develbranch_6/lib/python/core.py	2011-12-06 17:14:43 UTC (rev 49566)
+++ grass/branches/develbranch_6/lib/python/core.py	2011-12-06 17:22:42 UTC (rev 49567)
@@ -165,7 +165,10 @@
 	else:
 	    options[opt] = val
     args = make_command(prog, flags, overwrite, quiet, verbose, **options)
-
+    if sys.platform == 'win32' and os.path.splitext(prog)[1] == '.py':
+        os.chdir(os.path.join(os.getenv('GISBASE'), 'etc', 'gui', 'scripts'))
+        args.insert(0, sys.executable)
+    
     global debug_level
     if debug_level > 0:
         sys.stderr.write("D1/%d: %s.start_command(): %s\n" % (debug_level, __name__, ' '.join(args)))

Modified: grass/branches/develbranch_6/lib/python/task.py
===================================================================
--- grass/branches/develbranch_6/lib/python/task.py	2011-12-06 17:14:43 UTC (rev 49566)
+++ grass/branches/develbranch_6/lib/python/task.py	2011-12-06 17:22:42 UTC (rev 49567)
@@ -431,8 +431,15 @@
     @param cmd command (name of GRASS module)
     """
     try:
-        cmdout, cmderr = Popen([cmd, '--interface-description'], stdout = PIPE,
-                                     stderr = PIPE).communicate()
+        if sys.platform == 'win32' and os.path.splitext(cmd)[1] == '.py':
+            os.chdir(os.path.join(os.getenv('GISBASE'), 'etc', 'gui', 'scripts'))
+            args = [sys.executable, cmd, '--interface-description']
+        else:
+            args = [cmd, '--interface-description']
+        
+        cmdout, cmderr = Popen(args, stdout = PIPE,
+                               stderr = PIPE).communicate()
+        
     except OSError, e:
         raise ScriptError, _("Unable to fetch interface description for command '%(cmd)s'."
                              "\n\nDetails: %(det)s") % { 'cmd' : cmd, 'det' : e }



More information about the grass-commit mailing list