From 2a2a40d283e7c01cbc7cbad967af20d1bf047d7a Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Fri, 23 Oct 2015 16:26:49 -0600 Subject: [PATCH] misc.sh(): Use Popen instead of check_output() Signed-off-by: Zack Cerza --- teuthology/misc.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/teuthology/misc.py b/teuthology/misc.py index ea5b3ab7e..53caaa870 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -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') -- 2.47.3