mirror of
https://github.com/josegonzalez/python-github-backup.git
synced 2025-12-05 16:18:02 +01:00
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:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user