From 8550042402c8e7fea6e7cb5e0d453c7e6da234d3 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Thu, 29 Oct 2015 08:43:36 +0900 Subject: [PATCH] misc: .sh must not log the output twice on error Signed-off-by: Loic Dachary --- teuthology/misc.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/teuthology/misc.py b/teuthology/misc.py index 7b2e08ce41..f4043c7680 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, -- 2.39.5