[GRASS-SVN] r50570 - in grass/trunk: gui/wxpython/core gui/wxpython/gui_core lib/python

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Jan 30 15:32:16 EST 2012


Author: martinl
Date: 2012-01-30 12:32:16 -0800 (Mon, 30 Jan 2012)
New Revision: 50570

Modified:
   grass/trunk/gui/wxpython/core/gcmd.py
   grass/trunk/gui/wxpython/gui_core/forms.py
   grass/trunk/gui/wxpython/gui_core/goutput.py
   grass/trunk/lib/python/core.py
   grass/trunk/lib/python/task.py
Log:
wxGUI: attempt to catch error when getting interface description


Modified: grass/trunk/gui/wxpython/core/gcmd.py
===================================================================
--- grass/trunk/gui/wxpython/core/gcmd.py	2012-01-30 20:22:25 UTC (rev 50569)
+++ grass/trunk/gui/wxpython/core/gcmd.py	2012-01-30 20:32:16 UTC (rev 50570)
@@ -140,7 +140,7 @@
         self.value = value
 
     def __str__(self):
-        return str(self.value)
+        return self.value
 
 class Popen(subprocess.Popen):
     """!Subclass subprocess.Popen"""

Modified: grass/trunk/gui/wxpython/gui_core/forms.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/forms.py	2012-01-30 20:22:25 UTC (rev 50569)
+++ grass/trunk/gui/wxpython/gui_core/forms.py	2012-01-30 20:32:16 UTC (rev 50570)
@@ -2010,8 +2010,8 @@
             global _blackList
             self.grass_task = gtask.parse_interface(gcmd.GetRealCmd(cmd[0]),
                                                     blackList = _blackList)
-        except (grass.ScriptError, ValueError), e: 
-            raise gcmd.GException(e.value)
+        except (grass.ScriptError, ValueError), e:
+            raise gcmd.GException(e)
         
         # if layer parameters previously set, re-insert them into dialog
         if completed is not None:

Modified: grass/trunk/gui/wxpython/gui_core/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/goutput.py	2012-01-30 20:22:25 UTC (rev 50569)
+++ grass/trunk/gui/wxpython/gui_core/goutput.py	2012-01-30 20:32:16 UTC (rev 50570)
@@ -528,7 +528,13 @@
             
             else:
                 # other GRASS commands (r|v|g|...)
-                task = GUI(show = None).ParseCommand(command)
+                try:
+                    task = GUI(show = None).ParseCommand(command)
+                except GException, e:
+                    GError(parent = self,
+                           message = unicode(e),
+                           showTraceback = False)
+                    return
                 
                 hasParams = False
                 if task:

Modified: grass/trunk/lib/python/core.py
===================================================================
--- grass/trunk/lib/python/core.py	2012-01-30 20:22:25 UTC (rev 50569)
+++ grass/trunk/lib/python/core.py	2012-01-30 20:32:16 UTC (rev 50570)
@@ -61,9 +61,9 @@
 class ScriptError(Exception):
     def __init__(self, msg):
         self.value = msg
-    
+        
     def __str__(self):
-        return repr(self.value)
+        return self.value
         
 raise_on_error = False # raise exception instead of calling fatal()
 debug_level = 0        # DEBUG level

Modified: grass/trunk/lib/python/task.py
===================================================================
--- grass/trunk/lib/python/task.py	2012-01-30 20:22:25 UTC (rev 50569)
+++ grass/trunk/lib/python/task.py	2012-01-30 20:32:16 UTC (rev 50570)
@@ -433,6 +433,7 @@
     try:
         cmdout, cmderr = Popen([cmd, '--interface-description'], stdout = PIPE,
                                stderr = PIPE).communicate()
+        
         # TODO: replace ugly hack bellow
         if not cmdout and sys.platform == 'win32':
             if os.path.splitext(cmd)[1] == '':
@@ -441,6 +442,11 @@
             os.chdir(os.path.join(os.getenv('GISBASE'), 'scripts'))
             cmdout, cmderr = Popen([sys.executable, cmd, '--interface-description'], stdout = PIPE,
                                    stderr = PIPE).communicate()
+        
+        if cmderr:
+            raise ScriptError, _("Unable to fetch interface description for command '%(cmd)s'."
+                                 "\n\nDetails: %(det)s") % { 'cmd' : cmd, 'det' : decode(cmderr) }
+    
     except OSError, e:
         raise ScriptError, _("Unable to fetch interface description for command '%(cmd)s'."
                              "\n\nDetails: %(det)s") % { 'cmd' : cmd, 'det' : e }



More information about the grass-commit mailing list