From c81bf986274689b9075f2e07716b46f606f0661f Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Fri, 13 Mar 2015 15:45:15 -0400 Subject: [PATCH] logging_subprocess: always log when a command fails Previously git clones could fail without any indication unless you edited the source to change `logger=None` to use a configured logger. Now a non-zero return code will always output a message to stderr and will display the executed command so it can be rerun for troubleshooting. --- bin/github-backup | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/github-backup b/bin/github-backup index f566ef5..ab293a6 100755 --- a/bin/github-backup +++ b/bin/github-backup @@ -1,5 +1,7 @@ #!/usr/bin/env python +from __future__ import print_function + import argparse import base64 import errno @@ -61,7 +63,13 @@ def logging_subprocess(popenargs, logger, stdout_log_level=logging.DEBUG, stderr check_io() # check again to catch anything after the process exits - return child.wait() + rc = child.wait() + + if rc != 0: + print(u'{} returned {}:'.format(popenargs[0], rc), file=sys.stderr) + print('\t', u' '.join(popenargs), file=sys.stderr) + + return rc def mkdir_p(*args):