[GRASS-SVN] r64373 - in grass/trunk/gui/wxpython: core gmodeler gui_core lmgr modules vnet

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jan 30 10:32:32 PST 2015


Author: martinl
Date: 2015-01-30 10:32:32 -0800 (Fri, 30 Jan 2015)
New Revision: 64373

Modified:
   grass/trunk/gui/wxpython/core/gconsole.py
   grass/trunk/gui/wxpython/gmodeler/frame.py
   grass/trunk/gui/wxpython/gui_core/forms.py
   grass/trunk/gui/wxpython/lmgr/frame.py
   grass/trunk/gui/wxpython/modules/extensions.py
   grass/trunk/gui/wxpython/modules/mcalc_builder.py
   grass/trunk/gui/wxpython/modules/vclean.py
   grass/trunk/gui/wxpython/vnet/vnet_core.py
Log:
wxGUI: update onDone methods to pass event as argument


Modified: grass/trunk/gui/wxpython/core/gconsole.py
===================================================================
--- grass/trunk/gui/wxpython/core/gconsole.py	2015-01-30 18:29:50 UTC (rev 64372)
+++ grass/trunk/gui/wxpython/core/gconsole.py	2015-01-30 18:32:32 UTC (rev 64373)
@@ -457,7 +457,6 @@
         if command[0] in globalvar.grassCmd:
             # send GRASS command without arguments to GUI command interface
             # except ignored commands (event is emitted)
-
             if self._ignoredCmdPattern and \
               re.compile(self._ignoredCmdPattern).search(' '.join(command)) and \
               '--help' not in command and '--ui' not in command:
@@ -628,7 +627,7 @@
                          notification=event.notification)
 
         if event.onDone:
-            event.onDone(cmd=event.cmd, returncode=event.returncode)
+            event.onDone(event)
 
         self.cmdOutputTimer.Stop()
 
@@ -670,7 +669,8 @@
                     for lname in lnames:
                         if '@' not in lname:
                             lname += '@' + grass.gisenv()['MAPSET']
-                        self.mapCreated.emit(name=lname, ltype=prompt)
+                        if grass.find_file(lname, element=p.get('element'))['fullname']:
+                            self.mapCreated.emit(name=lname, ltype=prompt)
         if name == 'r.mask':
             self.updateMap.emit()
         

Modified: grass/trunk/gui/wxpython/gmodeler/frame.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/frame.py	2015-01-30 18:29:50 UTC (rev 64372)
+++ grass/trunk/gui/wxpython/gmodeler/frame.py	2015-01-30 18:32:32 UTC (rev 64373)
@@ -503,7 +503,7 @@
         """Run entire model"""
         self.model.Run(self._gconsole, self.OnDone, parent = self)
         
-    def OnDone(self, cmd, returncode):
+    def OnDone(self, event):
         """Computation finished
 
         .. todo::
@@ -1728,7 +1728,7 @@
         
         event.Skip()
 
-    def OnDone(self, cmd, returncode):
+    def OnDone(self, event):
         """Python script finished"""
         try_remove(self.filename)
         self.filename = None

Modified: grass/trunk/gui/wxpython/gui_core/forms.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/forms.py	2015-01-30 18:29:50 UTC (rev 64372)
+++ grass/trunk/gui/wxpython/gui_core/forms.py	2015-01-30 18:32:32 UTC (rev 64373)
@@ -629,13 +629,10 @@
         if event:
             event.Skip()
 
-    def OnDone(self, cmd, returncode):
+    def OnDone(self, event):
         """This function is launched from OnRun() when command is
         finished
-
-        :param returncode: command's return code (0 for success)
         """
-
         if hasattr(self, "btn_cancel"):
             self.btn_cancel.Enable(True)
 
@@ -652,7 +649,7 @@
                     self.get_dcmd is None and \
                     hasattr(self, "closebox") and \
                     self.closebox.IsChecked() and \
-                    (returncode == 0):
+                    (event.returncode == 0):
             # was closed also when aborted but better is leave it open
             wx.FutureCall(2000, self.Close)
 

Modified: grass/trunk/gui/wxpython/lmgr/frame.py
===================================================================
--- grass/trunk/gui/wxpython/lmgr/frame.py	2015-01-30 18:29:50 UTC (rev 64372)
+++ grass/trunk/gui/wxpython/lmgr/frame.py	2015-01-30 18:32:32 UTC (rev 64373)
@@ -496,7 +496,7 @@
         
         win.Show()
 
-    def OnDone(self, cmd, returncode):
+    def OnDone(self, event):
         """Command execution finished"""
         if hasattr(self, "model"):
             self.model.DeleteIntermediateData(log = self._gconsole)

Modified: grass/trunk/gui/wxpython/modules/extensions.py
===================================================================
--- grass/trunk/gui/wxpython/modules/extensions.py	2015-01-30 18:29:50 UTC (rev 64372)
+++ grass/trunk/gui/wxpython/modules/extensions.py	2015-01-30 18:32:32 UTC (rev 64373)
@@ -231,8 +231,8 @@
         if cmd:
             log.RunCmd(cmd, onDone = self.OnDone)
         
-    def OnDone(self, cmd, returncode):
-        if returncode == 0:
+    def OnDone(self, event):
+        if event.returncode == 0:
             if not os.getenv('GRASS_ADDON_BASE'):
                 SetAddOnPath(key = 'BASE')
             

Modified: grass/trunk/gui/wxpython/modules/mcalc_builder.py
===================================================================
--- grass/trunk/gui/wxpython/modules/mcalc_builder.py	2015-01-30 18:29:50 UTC (rev 64372)
+++ grass/trunk/gui/wxpython/modules/mcalc_builder.py	2015-01-30 18:32:32 UTC (rev 64373)
@@ -593,12 +593,12 @@
             RunCommand(self.cmd,
                        **params)
 
-    def OnDone(self, cmd, returncode):
+    def OnDone(self, event):
         """Add create map to the layer tree
 
         Sends the mapCreated signal from the grass interface.
         """
-        if returncode != 0:
+        if event.returncode != 0:
             return
         name = self.newmaptxt.GetValue().strip(' "') + '@' + grass.gisenv()['MAPSET']
         ltype = 'raster'

Modified: grass/trunk/gui/wxpython/modules/vclean.py
===================================================================
--- grass/trunk/gui/wxpython/modules/vclean.py	2015-01-30 18:29:50 UTC (rev 64372)
+++ grass/trunk/gui/wxpython/modules/vclean.py	2015-01-30 18:32:32 UTC (rev 64373)
@@ -440,7 +440,7 @@
         else:
             self.selected = -1
 
-    def OnDone(self, cmd, returncode):
+    def OnDone(self, event):
         """Command done"""
         self.SetStatusText('')
 

Modified: grass/trunk/gui/wxpython/vnet/vnet_core.py
===================================================================
--- grass/trunk/gui/wxpython/vnet/vnet_core.py	2015-01-30 18:29:50 UTC (rev 64372)
+++ grass/trunk/gui/wxpython/vnet/vnet_core.py	2015-01-30 18:32:32 UTC (rev 64373)
@@ -282,15 +282,15 @@
 
         return True
 
-    def _createTtbDone(self, cmd, returncode):
+    def _createTtbDone(self, event):
 
-        if returncode != 0:
+        if event.returncode != 0:
             GMessage(parent = self.guiparent,
                      message = _("Creation of turntable failed."))
             return
         else:
             params = {}
-            for c in cmd:
+            for c in event.cmd:
                 spl_c = c.split("=")
                 if len(spl_c) != 2:
                     continue
@@ -302,7 +302,7 @@
 
             self.vnet_data.SetParams(params, {})
 
-        self.ttbCreated.emit(returncode = returncode)
+        self.ttbCreated.emit(returncode = event.returncode)
 
     def SaveTmpLayer(self, layer_name):
         """Permanently saves temporary map of analysis result"""
@@ -460,24 +460,24 @@
         else:
             self.goutput.RunCmd(command = cmdParams, onDone = self._vnetPathRunAnDone)
 
-    def _vnetPathRunTurnsAnDone(self, cmd, returncode):
+    def _vnetPathRunTurnsAnDone(self, event):
         #TODO
         #self.tmp_maps.DeleteTmpMap(self.tmpTurnAn)
-        self._vnetPathRunAnDone(cmd, returncode)
+        self._vnetPathRunAnDone(event)
 
-    def _vnetPathRunAnDone(self, cmd, returncode):
+    def _vnetPathRunAnDone(self, event):
         """Called when v.net.path analysis is done"""
         try_remove(self.coordsTmpFile)
 
-        self._onDone(cmd, returncode)
+        self._onDone(event)
 
-    def _onDone(self, cmd, returncode):
-        for c in cmd:
+    def _onDone(self, event):
+        for c in event.cmd:
             if "output=" in c:
                 output = c.split("=")[1]
                 break  
 
-        self.onAnDone(cmd, returncode, output)
+        self.onAnDone(event.cmd, event.returncode, output)
 
     def _runTurnsAn(self, analysis, output, params, flags, catPts):
 
@@ -585,11 +585,11 @@
 
         try_remove(sqlFile)
 
-    def _runTurnsAnDone(self, cmd, returncode):
+    def _runTurnsAnDone(self, event):
         """Called when analysis is done"""
         #self.tmp_maps.DeleteTmpMap(self.tmpTurnAn) #TODO remove earlier (OnDone lambda?)
  
-        self._onDone(cmd, returncode)
+        self._onDone(event)
 
 
     def _runAn(self, analysis, output, params, flags, catPts):
@@ -691,7 +691,7 @@
         self._prepareCmd(cmdParams)
         self.goutput.RunCmd(command = cmdParams, onDone = self._runAnDone)
 
-    def _runAnDone(self, cmd, returncode):
+    def _runAnDone(self, event):
         """Called when analysis is done"""
         self.tmp_maps.DeleteTmpMap(self.tmpInPts) #TODO remove earlier (OnDone lambda?)
         self.tmp_maps.DeleteTmpMap(self.tmpInPtsConnected)
@@ -700,7 +700,7 @@
         if cmd[0] == "v.net.flow":
             self.tmp_maps.DeleteTmpMap(self.vnetFlowTmpCut)
 
-        self._onDone(cmd, returncode)
+        self._onDone(event)
 
     def _setInputParams(self, analysis, params, flags):
         """Return list of chosen values (vector map, layers). 



More information about the grass-commit mailing list