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

svn_grass at osgeo.org svn_grass at osgeo.org
Fri May 16 14:41:10 EDT 2008


Author: martinl
Date: 2008-05-16 14:41:10 -0400 (Fri, 16 May 2008)
New Revision: 31377

Modified:
   grass/trunk/gui/wxpython/gui_modules/goutput.py
   grass/trunk/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 (sync'ed with devbr6)

Modified: grass/trunk/gui/wxpython/gui_modules/goutput.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/goutput.py	2008-05-16 18:40:49 UTC (rev 31376)
+++ grass/trunk/gui/wxpython/gui_modules/goutput.py	2008-05-16 18:41:10 UTC (rev 31377)
@@ -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/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2008-05-16 18:40:49 UTC (rev 31376)
+++ grass/trunk/gui/wxpython/wxgui.py	2008-05-16 18:41:10 UTC (rev 31377)
@@ -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