commit: 40f058957e72e82f4e54d2f453c02e51c62f37c5
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Tue Dec 23 16:29:12 2014 +0000
Commit: Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Mon Dec 29 14:57:12 2014 +0000
URL:
http://sources.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=40f05895
Fix subprocess handling in batch-stabilize
---
batch-stabilize.py | 22 +++++++++++++---------
1 file 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)