[GRASS-SVN] r51417 - in grass/branches/develbranch_6/gui/wxpython: core gui_core

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Apr 13 13:11:55 EDT 2012


Author: martinl
Date: 2012-04-13 10:11:55 -0700 (Fri, 13 Apr 2012)
New Revision: 51417

Modified:
   grass/branches/develbranch_6/gui/wxpython/core/gcmd.py
   grass/branches/develbranch_6/gui/wxpython/gui_core/goutput.py
Log:
wxGUI: RunCmd() use copy of environ dict


Modified: grass/branches/develbranch_6/gui/wxpython/core/gcmd.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/core/gcmd.py	2012-04-13 16:54:18 UTC (rev 51416)
+++ grass/branches/develbranch_6/gui/wxpython/core/gcmd.py	2012-04-13 17:11:55 UTC (rev 51417)
@@ -479,10 +479,11 @@
 class CommandThread(Thread):
     """!Create separate thread for command. Used for commands launched
     on the background."""
-    def __init__ (self, cmd, stdin = None,
+    def __init__ (self, cmd, env = None, stdin = None,
                   stdout = sys.stdout, stderr = sys.stderr):
         """
         @param cmd command (given as list)
+        @param env environmental variables
         @param stdin standard input stream 
         @param stdout redirect standard output or None
         @param stderr redirect standard error output or None
@@ -493,6 +494,7 @@
         self.stdin  = stdin
         self.stdout = stdout
         self.stderr = stderr
+        self.env    = env
         
         self.module = None
         self.error  = ''
@@ -532,7 +534,9 @@
                                 stdin = subprocess.PIPE,
                                 stdout = subprocess.PIPE,
                                 stderr = subprocess.PIPE,
-                                shell = sys.platform == "win32")
+                                shell = sys.platform == "win32",
+                                env = self.env)
+        
         except OSError, e:
             self.error = str(e)
             print >> sys.stderr, e

Modified: grass/branches/develbranch_6/gui/wxpython/gui_core/goutput.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_core/goutput.py	2012-04-13 16:54:18 UTC (rev 51416)
+++ grass/branches/develbranch_6/gui/wxpython/gui_core/goutput.py	2012-04-13 17:11:55 UTC (rev 51417)
@@ -52,9 +52,9 @@
 wxCmdAbort,    EVT_CMD_ABORT    = NewEvent()
 wxCmdPrepare,  EVT_CMD_PREPARE  = NewEvent()
 
-def GrassCmd(cmd, stdout = None, stderr = None):
+def GrassCmd(cmd, env = None, stdout = None, stderr = None):
     """!Return GRASS command thread"""
-    return CommandThread(cmd,
+    return CommandThread(cmd, env = env,
                          stdout = stdout, stderr = stderr)
 
 class CmdThread(threading.Thread):
@@ -575,7 +575,8 @@
                 
                 # process GRASS command with argument
                 self.cmdThread.RunCmd(command, stdout = self.cmdStdOut, stderr = self.cmdStdErr,
-                                      onDone = onDone, onPrepare = onPrepare, userData = userData)
+                                      onDone = onDone, onPrepare = onPrepare, userData = userData,
+                                      env = os.environ.copy())
                 self.cmdOutputTimer.Start(50)
                 
                 # deactivate computational region and return to display settings



More information about the grass-commit mailing list