spit out the contents of the STDERR, STDOUT and executed script if failure

This commit is contained in:
Martin A. Brown 2016-02-26 11:24:42 -08:00
parent c5e14d6ccf
commit ca43130a6d
1 changed files with 10 additions and 2 deletions

View File

@ -135,12 +135,20 @@ def execute(cmd, stdin=None, stdout=None, stderr=None,
env=env, preexec_fn=os.setsid)
result = proc.wait()
if result != 0:
logger.warning("Return code (%s) for process: %r", result, cmd)
logger.warning("Find STDOUT/STDERR in %s/%s*", logdir, prefix)
logger.error("Non-zero exit (%s) for process: %r", result, cmd)
logger.error("Find STDOUT/STDERR in %s/%s*", logdir, prefix)
if isinstance(stdout, int) and stdoutname:
os.close(stdout)
if result != 0:
with open(stdoutname) as f:
for line in f:
logger.debug("STDOUT: %s", line.rstrip())
if isinstance(stderr, int) and stderrname:
os.close(stderr)
if result != 0:
with open(stderrname) as f:
for line in f:
logger.debug("STDERR: %s", line.rstrip())
return result