1   
 2   
 3   
 4   
 5   
 6   
 7   
 8   
 9   
10   
11   
12   
13   
14   
15   
16   
17   
18   
19   
20   
21   
22   
23   
24   
25  """Module containing classes for IO stream capture on slave processors.""" 
26   
27   
28 -class Redirect_text(object): 
 29      """Store the data of the IO streams, prepending a token to each line of written text.""" 
30   
31 -    def __init__(self, data, token='', stream=0): 
 32          """Set up the text redirection object. 
33   
34          @param data:        The data object to store all IO in. 
35          @type data:         list of lists 
36          @param token:       The string to add to the end of all newlines. 
37          @type token:        str 
38          @keyword stream:    The type of steam (0 for STDOUT and 1 for STDERR). 
39          @type stream:       int 
40          """ 
41   
42           
43          self.data = data 
44          self.token = token 
45          self.stream = stream 
 46   
47   
49          """Dummy flush method.""" 
 50   
51   
53          """Answer that this is not a TTY. 
54   
55          @return:    False, as this is not a TTY. 
56          @rtype:     bool 
57          """ 
58   
59          return False 
 60   
61   
62 -    def write(self, string): 
 63          """Replacement write() method. 
64           
65          This prepends the token to each line of STDOUT and STDERR and stores the result together with the stream number. 
66   
67          @param string:  The text to write. 
68          @type string:   str 
69          """ 
70   
71           
72          string = string.replace('\n', '\n' + self.token) 
73   
74           
75          self.data.append([string, self.stream]) 
  76