Revision e4c82e52 mininet/node.py

View differences:

mininet/node.py
161 161
            os.kill( self.lastPid, signal.SIGINT )
162 162

  
163 163
    def monitor( self ):
164
        "Monitor the output of a command, returning (done?, data)."
164
        """Monitor and return the output of a command.
165
           Set self.waiting to False if command has completed."""
165 166
        assert self.waiting
166 167
        self.waitReadable()
167 168
        data = self.read( 1024 )
......
175 176
        # Look for sentinel/EOF
176 177
        if len( data ) > 0 and data[ -1 ] == chr( 127 ):
177 178
            self.waiting = False
178
            return True, data[ :-1 ]
179
            data = data[ :-1 ]
179 180
        elif chr( 127 ) in data:
180 181
            self.waiting = False
181
            return True, data.replace( chr( 127 ), '' )
182
        return False, data
182
            data = data.replace( chr( 127 ), '' )
183
        return data
183 184

  
184 185
    def waitOutput( self, verbose=False ):
185 186
        """Wait for a command to complete.
......
189 190
           verbose: print output interactively"""
190 191
        log = info if verbose else debug
191 192
        output = ''
192
        done = False
193
        while not done:
194
            done, data = self.monitor()
193
        while self.waiting:
194
            data = self.monitor()
195 195
            output += data
196 196
            log( data )
197 197
        return output

Also available in: Unified diff