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

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jul 29 20:01:04 EDT 2008


Author: martinl
Date: 2008-07-29 20:01:04 -0400 (Tue, 29 Jul 2008)
New Revision: 32365

Modified:
   grass/trunk/gui/wxpython/gui_modules/gcmd.py
   grass/trunk/gui/wxpython/gui_modules/goutput.py
   grass/trunk/gui/wxpython/gui_modules/menuform.py
Log:
wxGUI: abort re-implemented, update r32364

Modified: grass/trunk/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gcmd.py	2008-07-29 23:31:59 UTC (rev 32364)
+++ grass/trunk/gui/wxpython/gui_modules/gcmd.py	2008-07-30 00:01:04 UTC (rev 32365)
@@ -608,6 +608,7 @@
         self._want_abort = False
         self.aborted = False
         
+    def run(self):
         self.startTime = time.time()
         
         try:
@@ -647,6 +648,7 @@
         while self.module.poll() is None:
             if self._want_abort: # abort running process
                 self.module.kill()
+                self.aborted = True
                 return
             if self.stdout:
                 line = recv_some(self.module, e=0, stderr=0)
@@ -668,7 +670,6 @@
 
     def abort(self):
         """Abort running process, used by main thread to signal an abort"""
-        print 'a'
         self._want_abort = True
     
 # testing ...

Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py	2008-07-29 23:31:59 UTC (rev 32364)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py	2008-07-30 00:01:04 UTC (rev 32365)
@@ -62,7 +62,7 @@
         CmdThread.requestId += 1
 
         self.requestTime = time.time()
-
+        self.requestCmd = None
         self.requestQ.put((CmdThread.requestId, callable, args, kwds))
         
         return CmdThread.requestId
@@ -70,16 +70,16 @@
     def run(self):
         while True:
             requestId, callable, args, kwds = self.requestQ.get()
-            self.resultQ.put((requestId, callable(*args, **kwds)))
+            self.requestCmd = callable(*args, **kwds)
+            self.resultQ.put((requestId, self.requestCmd.run()))
 
-            event = wxCmdDone(aborted=False,
+            event = wxCmdDone(aborted=self.requestCmd.aborted,
                               time=self.requestTime,
                               pid=requestId)
             wx.PostEvent(self.parent, event)
 
     def abort(self):
-        # TODO
-        print self.resultQ.get_()
+        self.requestCmd.abort()
         
 class GMConsole(wx.Panel):
     """
@@ -140,7 +140,7 @@
         self.Bind(wx.EVT_BUTTON, self.ClearHistory, self.console_clear)
         self.Bind(wx.EVT_BUTTON, self.SaveHistory,  self.console_save)
 
-        self.Bind(EVT_CMD_ABORT, self.OnCmdDone)
+        self.Bind(EVT_CMD_ABORT, self.OnCmdAbort)
         
         self.__layout()
 
@@ -404,11 +404,13 @@
         """Update progress message info"""
         self.console_progressbar.SetValue(event.value)
 
+    def OnCmdAbort(self, event):
+        """Abort running command"""
+        self.cmdThread.abort()
+        
     def OnCmdDone(self, event):
         """Command done (or aborted)"""
         if event.aborted:
-            self.cmdThread.abort()
-            
             # Thread aborted (using our convention of None return)
             self.WriteLog(_('Please note that the data are left in incosistent stage '
                             'and can be corrupted'), self.cmd_output.StyleWarning)

Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2008-07-29 23:31:59 UTC (rev 32364)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2008-07-30 00:01:04 UTC (rev 32365)
@@ -773,9 +773,6 @@
 
     def OnRun(self, event):
         """Run the command"""
-        if not self.goutput.resultQ.empty():
-            return
-
         cmd = self.createCmd()
 
         if cmd == [] or cmd == None:



More information about the grass-commit mailing list