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.
This commit is contained in:
Chris Adams
2015-03-13 15:45:15 -04:00
parent 040516325a
commit c81bf98627

View File

@@ -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):