]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
misc: .sh must not log the output twice on error 682/head
authorLoic Dachary <ldachary@redhat.com>
Wed, 28 Oct 2015 23:43:36 +0000 (08:43 +0900)
committerLoic Dachary <ldachary@redhat.com>
Wed, 28 Oct 2015 23:47:25 +0000 (08:47 +0900)
Signed-off-by: Loic Dachary <ldachary@redhat.com>
teuthology/misc.py

index 7b2e08ce41bd37658b18483d319dfce244fb0d11..f4043c7680db47a80a119fb64c40d1fa9bacde29 100644 (file)
@@ -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,