]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
misc.sh(): Use Popen instead of check_output() 670/head
authorZack Cerza <zack@redhat.com>
Fri, 23 Oct 2015 22:26:49 +0000 (16:26 -0600)
committerZack Cerza <zack@redhat.com>
Fri, 23 Oct 2015 23:42:25 +0000 (17:42 -0600)
Signed-off-by: Zack Cerza <zack@redhat.com>
teuthology/misc.py

index ea5b3ab7ed082e3deb10400d277770dcdc730811..53caaa87043297f855eb0328be42fae4008644e0 100644 (file)
@@ -1307,11 +1307,18 @@ def sh(command):
     """
     log.debug(command)
     output = ''
-    try:
-        output = subprocess.check_output(command, stderr=subprocess.STDOUT,
-                                         shell=True)
-    except subprocess.CalledProcessError as e:
-        raise e
+    proc = subprocess.Popen(
+        args=command,
+        stdout=subprocess.PIPE,
+        stderr=subprocess.STDOUT,
+        shell=True)
+    output = proc.communicate()[0]
     if output.strip():
         log.debug(command + " output " + str(output))
+    if proc.returncode != 0:
+        raise subprocess.CalledProcessError(
+            returncode=proc.returncode,
+            cmd=command,
+            output=output,
+        )
     return output.decode('utf-8')