Print command debugging information only once

When debugging is turned on and a command is run that fails or with
`print_on_success` on, the output for the command execution ends up
being printed twice. This change ensures that only one set of output
is printed at any point.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
This commit is contained in:
Steve Kuznetsov 2017-01-25 14:44:11 -05:00
parent 1aa39dc089
commit 459b377a3d
No known key found for this signature in database
GPG key ID: 366E054B30FC03A2

View file

@ -413,12 +413,6 @@ def run_command(command, print_on_success=False):
If command fails, print status code and command output.
"""
(status, output) = getstatusoutput(command)
# ISSUE 253 - allow for better debug output
debug("Command: %s" % command)
debug("Status code: %s" % status)
debug("Command output: %s\n" % output)
if status > 0:
msgs = [
"Error running command: %s\n" % command,
@ -431,6 +425,11 @@ def run_command(command, print_on_success=False):
print("Command: %s\n" % command)
print("Status code: %s\n" % status)
print("Command output: %s\n" % output)
else:
debug("Command: %s" % command)
debug("Status code: %s" % status)
debug("Command output: %s\n" % output)
return output