diff options
Diffstat (limited to 'batch-stabilize.py')
-rwxr-xr-x | batch-stabilize.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/batch-stabilize.py b/batch-stabilize.py index 155af38..81f97ba 100755 --- a/batch-stabilize.py +++ b/batch-stabilize.py @@ -26,19 +26,23 @@ def print_and_log(message, log): log.flush() def run_command(args, cwd, log): - try: - message = "Running %r in %s...\n" % (args, cwd) - sys.stdout.write(message) - log.write(message) + message = "Running %r in %s...\n" % (args, cwd) + returncode = 0 + sys.stdout.write(message) + log.write(message) - cmd = subprocess.Popen(args, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - output = cmd.communicate()[0] - log.write("Finished with exit code %d\n" % cmd.returncode) - log.write(output) - return (cmd.returncode, output) + try: + output = subprocess.check_output(args, cwd=cwd, + stderr=subprocess.STDOUT, universal_newlines=True) + except subprocess.CalledProcessError as e: + output = e.output + returncode = e.returncode finally: + log.write("Finished with exit code %d\n" % returncode) + log.write(output) log.flush() + return (returncode, output) def save_state(done_bugs): with open('batch-stabilize.state', 'wb') as state_file: pickle.dump(done_bugs, state_file) |