[GRASS-SVN] r30617 - in grass/trunk/gui/wxpython: . gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Mar 18 09:11:15 EDT 2008


Author: martinl
Date: 2008-03-18 09:11:15 -0400 (Tue, 18 Mar 2008)
New Revision: 30617

Modified:
   grass/trunk/gui/wxpython/gui_modules/gcmd.py
   grass/trunk/gui/wxpython/gui_modules/render.py
   grass/trunk/gui/wxpython/wxgui.py
Log:
wxGUI: do not execute zero-length commands
some cosmetics in error messages (writing settings into workspace file)


Modified: grass/trunk/gui/wxpython/gui_modules/gcmd.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gcmd.py	2008-03-18 12:26:55 UTC (rev 30616)
+++ grass/trunk/gui/wxpython/gui_modules/gcmd.py	2008-03-18 13:11:15 UTC (rev 30617)
@@ -503,20 +503,23 @@
         
     def run(self):
         """Run command"""
+        if len(self.cmd) == 0:
+            return
+
         self.startTime = time.time()
         # TODO: wx.Exectute/wx.Process (?)
-        self.module = Popen(self.cmd,
-                            stdin=subprocess.PIPE,
-                            stdout=subprocess.PIPE,
-                            stderr=subprocess.PIPE)
-
+        try:
+            self.module = Popen(self.cmd,
+                                stdin=subprocess.PIPE,
+                                stdout=subprocess.PIPE,
+                                stderr=subprocess.PIPE)
+        except OSError, e:
+            raise CmdError(self.cmd[0], str(e))
+        
         if self.stdin: # read stdin if requested ...
             self.module.stdin.write(self.stdin)
             self.module.stdin.close()
 
-        if not self.module:
-            return
-
         # redirect standard outputs...
         if self.stdout or self.stderr:
             self.__redirect_stream()

Modified: grass/trunk/gui/wxpython/gui_modules/render.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/render.py	2008-03-18 12:26:55 UTC (rev 30616)
+++ grass/trunk/gui/wxpython/gui_modules/render.py	2008-03-18 13:11:15 UTC (rev 30617)
@@ -83,6 +83,8 @@
 
         @return name of file with rendered image or None
         """
+        if len(self.cmdlist) == 0:
+            return
 
         Debug.msg (3, "MapLayer.Render(): type=%s" % \
                    (self.type))
@@ -143,7 +145,10 @@
         if not self.name:
             return ''
 
-        return self.name.split('@')[1]
+        try:
+            return self.name.split('@')[1]
+        except IndexError:
+            return self.name
 
     def GetCmd(self, string=False):
         """

Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2008-03-18 12:26:55 UTC (rev 30616)
+++ grass/trunk/gui/wxpython/wxgui.py	2008-03-18 13:11:15 UTC (rev 30617)
@@ -750,10 +750,9 @@
         try:
             file = open(filename, "w")
         except IOError:
-            dlg = wx.MessageDialog(self, _("Unable to open workspace file <%s> for writing.") % filename,
-                                   _("Error"), wx.OK | wx.ICON_ERROR)
-            dlg.ShowModal()
-            dlg.Destroy()
+            wx.MessageBox(parent=self,
+                          message=_("Unable to open workspace file <%s> for writing.") % filename,
+                          caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
             return False
 
         try:
@@ -774,17 +773,16 @@
             self.indent =- 4
             file.write('%s</gxw>\n' % (' ' * self.indent))
             del self.indent
-        except:
-            dlg = wx.MessageDialog(self, _("Writing current settings to workspace file failed."),
-                                   _("Error"), wx.OK | wx.ICON_ERROR)
-            dlg.ShowModal()
-            dlg.Destroy()
+        except StandardError, e:
+            file.close()
+            wx.MessageBox(parent=self, message=_("Writing current settings to workspace file failed (%s)." % e),
+                          caption=_("Error"), style=wx.OK | wx.ICON_ERROR | wx.CENTRE)
             return False
 
         file.close()
-
+        
         return True
-
+    
     def OnWorkspaceClose(self, event=None):
         """Close file with workspace definition
 



More information about the grass-commit mailing list