'Disconnect output redirection and return buffer.
Safe to call multiple times.'

def complete_output(self):

    if self.stdout0:
        sys.stdout = self.stdout0
        sys.stderr = self.stderr0
        self.stdout0 = None
        self.stderr0 = None
    return self.outputBuffer.getvalue()
