Browse Source

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)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@31377 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 17 years ago
parent
commit
5d3d36b56f
2 changed files with 16 additions and 4 deletions
  1. 13 4
      gui/wxpython/gui_modules/goutput.py
  2. 3 0
      gui/wxpython/wxgui.py

+ 13 - 4
gui/wxpython/gui_modules/goutput.py

@@ -64,10 +64,6 @@ class GMConsole(wx.Panel):
                                    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 @@ class GMConsole(wx.Panel):
         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

+ 3 - 0
gui/wxpython/wxgui.py

@@ -178,6 +178,9 @@ class GMFrame(wx.Frame):
         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)