[GRASS-SVN] r72302 - grass/trunk/gui/wxpython/gmodeler

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Mar 2 13:29:28 PST 2018


Author: martinl
Date: 2018-03-02 13:29:28 -0800 (Fri, 02 Mar 2018)
New Revision: 72302

Modified:
   grass/trunk/gui/wxpython/gmodeler/frame.py
Log:
wxGUI/gmodeler: delete intermediate data when model finished

Modified: grass/trunk/gui/wxpython/gmodeler/frame.py
===================================================================
--- grass/trunk/gui/wxpython/gmodeler/frame.py	2018-03-02 21:19:55 UTC (rev 72301)
+++ grass/trunk/gui/wxpython/gmodeler/frame.py	2018-03-02 21:29:28 UTC (rev 72302)
@@ -387,6 +387,22 @@
 
         dlg.Destroy()
 
+    def _deleteIntermediateData(self):
+        """Delete intermediate data"""
+        rast, vect, rast3d, msg = self.model.GetIntermediateData()
+        if rast:
+            self._gconsole.RunCmd(['g.remove', '-f', 'type=raster',
+                                   'name=%s' % ','.join(rast)])
+        if rast3d:
+            self._gconsole.RunCmd(['g.remove', '-f', 'type=raster_3d',
+                                   'name=%s' % ','.join(rast3d)])
+        if vect:
+            self._gconsole.RunCmd(['g.remove', '-f', 'type=vector',
+                                   'name=%s' % ','.join(vect)])
+                
+        self.SetStatusText(_("%d intermediate maps deleted from current mapset") %
+                           int(len(rast) + len(rast3d) + len(vect)))
+
     def OnDeleteData(self, event):
         """Delete intermediate data"""
         rast, vect, rast3d, msg = self.model.GetIntermediateData()
@@ -405,25 +421,10 @@
             style=wx.YES_NO | wx.YES_DEFAULT | wx.ICON_QUESTION)
 
         ret = dlg.ShowModal()
+        dlg.Destroy()
         if ret == wx.ID_YES:
-            dlg.Destroy()
+            self._deleteIntermediateData()
 
-            if rast:
-                self._gconsole.RunCmd(['g.remove', '-f', 'type=raster',
-                                       'name=%s' % ','.join(rast)])
-            if rast3d:
-                self._gconsole.RunCmd(['g.remove', '-f', 'type=raster_3d',
-                                       'name=%s' % ','.join(rast3d)])
-            if vect:
-                self._gconsole.RunCmd(['g.remove', '-f', 'type=vector',
-                                       'name=%s' % ','.join(vect)])
-
-            self.SetStatusText(_("%d maps deleted from current mapset") %
-                               int(len(rast) + len(rast3d) + len(vect)))
-            return
-
-        dlg.Destroy()
-
     def OnModelNew(self, event):
         """Create new model"""
         Debug.msg(4, "ModelFrame.OnModelNew():")
@@ -617,6 +618,7 @@
         """Computation finished
         """
         self.SetStatusText('', 0)
+        
         # restore original files
         if hasattr(self.model, "fileInput"):
             for finput in self.model.fileInput:
@@ -631,6 +633,9 @@
                     fd.close()
             del self.model.fileInput
 
+        # delete intermediate data
+        self._deleteIntermediateData()
+
     def OnValidateModel(self, event, showMsg=True):
         """Validate entire model"""
         if self.model.GetNumItems() < 1:



More information about the grass-commit mailing list