Browse Source

wxGUI/modeler: implement cleanup()

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@42337 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 15 years ago
parent
commit
8187fda8b6
1 changed files with 21 additions and 3 deletions
  1. 21 3
      gui/wxpython/gui_modules/gmodeler.py

+ 21 - 3
gui/wxpython/gui_modules/gmodeler.py

@@ -810,14 +810,32 @@ import os
 import grass.script as grass
 import atexit
 """)
- 
+        
+        # cleanup()
+        rast, vect, rast3d, msg = self.model.GetIntermediateData()
         fd.write(
 r"""
 
 def cleanup():
-    pass
 """)
-
+        if rast:
+            fd.write(
+r"""    grass.run_command('g.remove',
+                      rast=%s)
+""" % ','.join(map(lambda x: "'" + x + "'", rast)))
+        if vect:
+            fd.write(
+r"""    grass.run_command('g.remove',
+                      vect = %s)
+""" % ','.join(map(lambda x: "'" + x + "'", vect)))
+        if rast3d:
+            fd.write(
+r"""    grass.run_command('g.remove',
+                      rast3d = %s)
+""" % ','.join(map(lambda x: "'" + x + "'", rast3d)))
+        if not rast and not vect and not rast3d:
+            fd.write('    pass\n')
+        
         fd.write("\ndef main():\n")
         for action in self.model.GetActions():
             task = menuform.GUI().ParseCommand(cmd = action.GetLog(string = False),