mailr14090 - /branches/gui_testing/gui/controller.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by edward on August 03, 2011 - 18:37:
Author: bugman
Date: Wed Aug  3 18:37:17 2011
New Revision: 14090

URL: http://svn.gna.org/viewcvs/relax?rev=14090&view=rev
Log:
The relax controller log window can now distinguish between STDOUT and STDERR 
messages.

STDOUT and STDERR are now being sent to separate instances of Redirect_text, 
and added to the log
queue with a flag specifying which is which.


Modified:
    branches/gui_testing/gui/controller.py

Modified: branches/gui_testing/gui/controller.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/gui_testing/gui/controller.py?rev=14090&r1=14089&r2=14090&view=diff
==============================================================================
--- branches/gui_testing/gui/controller.py (original)
+++ branches/gui_testing/gui/controller.py Wed Aug  3 18:37:17 2011
@@ -95,9 +95,8 @@
         sizer.Add(self.log_panel, 1, wx.EXPAND|wx.ALL, 0)
 
         # IO redirection.
-        redir = Redirect_text(self.log_panel, self.log_queue)
-        sys.stdout = redir
-        sys.stderr = redir
+        sys.stdout = Redirect_text(self.log_panel, self.log_queue, stream=0)
+        sys.stderr = Redirect_text(self.log_panel, self.log_queue, stream=1)
 
         # Initial update of the controller.
         self.update_controller()
@@ -528,8 +527,11 @@
             if self.log_queue.empty():
                 break
 
+            # Get the data.
+            msg, stream = self.log_queue.get()
+
             # Add the text.
-            string = string + self.log_queue.get()
+            string = string + msg
 
         # Return the concatenated text.
         return string
@@ -597,18 +599,21 @@
 class Redirect_text(object):
     """The IO redirection to text control object."""
 
-    def __init__(self, control, log_queue):
+    def __init__(self, control, log_queue, stream=0):
         """Set up the text redirection object.
 
         @param control:         The text control object to redirect IO to.
         @type control:          wx.TextCtrl instance
         @param log_queue:       The queue of log messages.
         @type log_queue:        Queue.Queue instance
+        @keyword stream:        The type of steam (0 for STDOUT and 1 for 
STDERR).
+        @type stream:           int
         """
 
         # Store the args.
         self.control = control
         self.log_queue = log_queue
+        self.stream = stream
 
 
     def write(self, string):
@@ -618,12 +623,15 @@
         @type string:   str
         """
 
-        # Debugging.
+        # Debugging print out to the terminal.
         if status.debug:
-            sys.__stdout__.write(string)
+            if self.stream == 0:
+                sys.__stdout__.write(string)
+            else:
+                sys.__stderr__.write(string)
 
         # Add the text to the queue.
-        self.log_queue.put(string)
+        self.log_queue.put([string, self.stream])
 
         # Call the log control write method one the GUI is responsive.
         wx.CallAfter(self.control.write)




Related Messages


Powered by MHonArc, Updated Wed Aug 03 19:20:02 2011