'output_prepare must be called prior to calling this'

def process_output(self, stdout=True, final_read=False):

    if stdout:
        (pipe, buf, tee) = (self.sp.stdout, self.stdout_file, self.stdout_tee)
    else:
        (pipe, buf, tee) = (self.sp.stderr, self.stderr_file, self.stderr_tee)
    if final_read:
        data = []
        while select.select([pipe], [], [], 0)[0]:
            data.append(os.read(pipe.fileno(), 1024))
            if (len(data[(-1)]) == 0):
                break
        data = ''.join(data)
    else:
        data = os.read(pipe.fileno(), 1024)
    buf.write(data)
    tee.write(data)
