示例#1
0
def run(cmd, quiet=False, abandon_output=True):
    proc = Popen(split(cmd), stdout=PIPE, stderr=STDOUT)
    buf = Buffer(abandon_output=abandon_output)
    line = proc.stdout.readline()
    while len(line):
        buf.put(line)
        if not quiet:
            print(line, end='')
        line = proc.stdout.readline()
    # Process could probably close the descriptor before exiting.
    proc.wait()
    if proc.returncode != 0:
        raise Exception('Process exited with a non-zero return code.  ' +
                        'Last output of the program:\n\n' +
                        '---------- Start of exception log --\n' +
                        buf.get_short().strip() +
                        '\n---------- End of exception log --\n')
    return buf.get_long()
示例#2
0
def run(cmd, quiet = False, abandon_output = True):
    proc = Popen(split(cmd), stdout = PIPE, stderr = STDOUT)
    buf = Buffer(abandon_output = abandon_output)
    line = proc.stdout.readline()
    while len(line):
        buf.put(line)
        if not quiet:
            print(line, end = '')
        line = proc.stdout.readline()
    # Process could probably close the descriptor before exiting.
    proc.wait()
    if proc.returncode != 0:
        raise Exception('Process exited with a non-zero return code.  ' +
                'Last output of the program:\n\n' +
                '---------- Start of exception log --\n' +
                buf.get_short().strip() +
                '\n---------- End of exception log --\n')
    return buf.get_long()