[GRASS-SVN] r32373 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jul 30 09:05:12 EDT 2008


Author: martinl
Date: 2008-07-30 09:05:12 -0400 (Wed, 30 Jul 2008)
New Revision: 32373

Modified:
   grass/trunk/gui/wxpython/gui_modules/gcmd.py
Log:
wxGUI: do not run command twice, redirect stdout properly, update r32364

Modified: grass/trunk/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gcmd.py	2008-07-30 12:52:58 UTC (rev 32372)
+++ grass/trunk/gui/wxpython/gui_modules/gcmd.py	2008-07-30 13:05:12 UTC (rev 32373)
@@ -221,6 +221,7 @@
                     return ''
                 
                 r = conn.read(maxsize)
+                
                 if not r:
                     return self._close(which)
     
@@ -319,12 +320,6 @@
                     os.environ["GRASS_VERBOSE"] = str(verbose)
 
         #
-        # set message formatting
-        #
-        message_format = os.getenv("GRASS_MESSAGE_FORMAT")
-        os.environ["GRASS_MESSAGE_FORMAT"] = "gui"
-
-        #
         # create command thread
         #
         self.cmdThread = CommandThread(cmd, stdin,
@@ -366,11 +361,6 @@
             Debug.msg (3, "Command(): cmd='%s', wait=%s, returncode=?, alive=%s" % \
                            (' '.join(cmd), wait, self.cmdThread.isAlive()))
 
-        if message_format:
-            os.environ["GRASS_MESSAGE_FORMAT"] = message_format
-        else:
-            os.unsetenv("GRASS_MESSAGE_FORMAT")
-
         if verbose_orig:
             os.environ["GRASS_VERBOSE"] = verbose_orig
         else:
@@ -492,7 +482,17 @@
         self.aborted = False
 
         self.setDaemon(True)
+
+        # set message formatting
+        self.message_format = os.getenv("GRASS_MESSAGE_FORMAT")
+        os.environ["GRASS_MESSAGE_FORMAT"] = "gui"
         
+    def __del__(self):
+        if self.message_format:
+            os.environ["GRASS_MESSAGE_FORMAT"] = self.message_format
+        else:
+            os.unsetenv("GRASS_MESSAGE_FORMAT")
+        
     def run(self):
         if len(self.cmd) == 0:
             return
@@ -531,7 +531,7 @@
 	    if not subprocess.mswindows:
                 flags = fcntl.fcntl(out_fileno, fcntl.F_GETFL)
                 fcntl.fcntl(out_fileno, fcntl.F_SETFL, flags| os.O_NONBLOCK)
-                
+        
         # wait for the process to end, sucking in stuff until it does end
         while self.module.poll() is None:
             if self._want_abort: # abort running process



More information about the grass-commit mailing list