Browse Source

wxGUI: do not run command twice, redirect stdout properly, fix https://trac.osgeo.org/grass/changeset/32373

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@32374 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 17 years ago
parent
commit
85ab176dc7
1 changed files with 9 additions and 5 deletions
  1. 9 5
      gui/wxpython/gui_modules/goutput.py

+ 9 - 5
gui/wxpython/gui_modules/goutput.py

@@ -71,7 +71,6 @@ class CmdThread(threading.Thread):
         while True:
         while True:
             requestId, callable, args, kwds = self.requestQ.get()
             requestId, callable, args, kwds = self.requestQ.get()
             self.requestCmd = callable(*args, **kwds)
             self.requestCmd = callable(*args, **kwds)
-            self.requestCmd.start()
             self.resultQ.put((requestId, self.requestCmd.run()))
             self.resultQ.put((requestId, self.requestCmd.run()))
 
 
             event = wxCmdDone(aborted=self.requestCmd.aborted,
             event = wxCmdDone(aborted=self.requestCmd.aborted,
@@ -81,7 +80,7 @@ class CmdThread(threading.Thread):
 
 
     def abort(self):
     def abort(self):
         self.requestCmd.abort()
         self.requestCmd.abort()
-        
+    
 class GMConsole(wx.Panel):
 class GMConsole(wx.Panel):
     """
     """
     Create and manage output console for commands entered on the
     Create and manage output console for commands entered on the
@@ -411,6 +410,8 @@ class GMConsole(wx.Panel):
         
         
     def OnCmdDone(self, event):
     def OnCmdDone(self, event):
         """Command done (or aborted)"""
         """Command done (or aborted)"""
+        time.sleep(.1) # wait for stdout
+        
         if event.aborted:
         if event.aborted:
             # Thread aborted (using our convention of None return)
             # Thread aborted (using our convention of None return)
             self.WriteLog(_('Please note that the data are left in incosistent stage '
             self.WriteLog(_('Please note that the data are left in incosistent stage '
@@ -475,9 +476,13 @@ class GMStdout:
     def write(self, s):
     def write(self, s):
         if len(s) == 0 or s == '\n':
         if len(s) == 0 or s == '\n':
             return
             return
+        
         s = s.replace('\n', os.linesep)
         s = s.replace('\n', os.linesep)
         
         
         for line in s.split(os.linesep):
         for line in s.split(os.linesep):
+            if len(line) == 0:
+                continue
+            
             evt = wxCmdOutput(text=line + os.linesep,
             evt = wxCmdOutput(text=line + os.linesep,
                               type='')
                               type='')
             wx.PostEvent(self.parent.cmd_output, evt)
             wx.PostEvent(self.parent.cmd_output, evt)
@@ -509,7 +514,6 @@ class GMStderr:
         for line in s.split(os.linesep):
         for line in s.split(os.linesep):
             if len(line) == 0:
             if len(line) == 0:
                 continue
                 continue
-
             if 'GRASS_INFO_PERCENT' in line:
             if 'GRASS_INFO_PERCENT' in line:
                 value = int(line.rsplit(':', 1)[1].strip())
                 value = int(line.rsplit(':', 1)[1].strip())
                 if value >= 0 and value < 100:
                 if value >= 0 and value < 100:
@@ -527,8 +531,8 @@ class GMStderr:
                 self.message = line.split(':', 1)[1].strip()
                 self.message = line.split(':', 1)[1].strip()
             elif 'GRASS_INFO_END' in line:
             elif 'GRASS_INFO_END' in line:
                 self.printMessage = True
                 self.printMessage = True
-            elif not self.type:
-                if len(line) > 0:
+            elif self.type == '':
+                if len(line) == 0:
                     continue
                     continue
                 evt = wxCmdOutput(text=line,
                 evt = wxCmdOutput(text=line,
                                   type='')
                                   type='')