From: Loic Dachary Date: Wed, 28 Oct 2015 23:43:36 +0000 (+0900) Subject: misc: .sh must not log the output twice on error X-Git-Tag: 1.1.0~773^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F682%2Fhead;p=teuthology.git misc: .sh must not log the output twice on error Signed-off-by: Loic Dachary --- diff --git a/teuthology/misc.py b/teuthology/misc.py index 7b2e08ce4..f4043c768 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -1313,14 +1313,15 @@ def sh(command, log_limit=128): stderr=subprocess.STDOUT, shell=True) output = proc.communicate()[0] - if output.strip(): - if len(output) > log_limit: - log.debug(command + " output " + str(output)[:log_limit] + - "... (truncated to the first " + str(log_limit) + - " characters)") - else: - log.debug(command + " output " + str(output)) - if proc.returncode != 0: + if proc.returncode == 0: + if output.strip(): + if len(output) > log_limit: + log.debug(command + " output " + str(output)[:log_limit] + + "... (truncated to the first " + str(log_limit) + + " characters)") + else: + log.debug(command + " output " + str(output)) + else: log.debug(command + " failed with " + str(output)) raise subprocess.CalledProcessError( returncode=proc.returncode,