[GRASS-SVN] r31375 - in grass/branches/develbranch_6/gui/wxpython: . gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Fri May 16 14:39:44 EDT 2008


Author: martinl
Date: 2008-05-16 14:39:44 -0400 (Fri, 16 May 2008)
New Revision: 31375

Modified:
   grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
   grass/branches/develbranch_6/gui/wxpython/wxgui.py
Log:
wxGUI: enable stderr redirection in GMFrame.__init__(). This can be useful when GUI crashes during initialization, traceback is printed to sys.stderr.

Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py	2008-05-16 18:37:23 UTC (rev 31374)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/goutput.py	2008-05-16 18:39:44 UTC (rev 31375)
@@ -64,10 +64,6 @@
                                    self.parent.notebook,
                                    pageid)
 
-        if Debug.get_level() == 0:
-            # don't redirect when debugging is enabled
-            sys.stderr = self.cmd_stderr
-
         # buttons
         self.console_clear = wx.Button(parent=self, id=wx.ID_CLEAR)
         self.console_save  = wx.Button(parent=self, id=wx.ID_SAVE)
@@ -101,6 +97,19 @@
         self.SetAutoLayout(True)
         self.SetSizer(boxsizer1)
 
+    def Redirect(self):
+        """Redirect stderr
+
+        @return True redirected
+        @return False failed
+        """
+        if Debug.get_level() == 0:
+            # don't redirect when debugging is enabled
+            sys.stderr = self.cmd_stderr
+            return True
+
+        return False
+
     def WriteLog(self, line, style=None, wrap=None):
         """Generic method for writing log message in 
         given style

Modified: grass/branches/develbranch_6/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/wxgui.py	2008-05-16 18:37:23 UTC (rev 31374)
+++ grass/branches/develbranch_6/gui/wxpython/wxgui.py	2008-05-16 18:39:44 UTC (rev 31375)
@@ -178,6 +178,9 @@
         if self.curr_page and not self.curr_page.maptree.mapdisplay.IsShown():
             self.curr_page.maptree.mapdisplay.Show()
 
+        # redirect stderr to log area    
+        self.goutput.Redirect()
+
     def __doLayout(self):
         """Do Layout (unused bacause of aui manager...)"""
         # self.panel = wx.Panel(self,-1, style= wx.EXPAND)



More information about the grass-commit mailing list