aboutsummaryrefslogtreecommitdiffstats
path: root/utils/functest_utils.py
diff options
context:
space:
mode:
authorjose.lausuch <jose.lausuch@ericsson.com>2016-07-22 11:23:41 +0200
committerjose.lausuch <jose.lausuch@ericsson.com>2016-07-22 11:29:02 +0200
commitfd1c5c0636eff579af38c81ebb36a875f1a07328 (patch)
treeccdc3d63523b57a5913829c6f4654dd6a3608882 /utils/functest_utils.py
parent85cb44adbb5aa7b230f5c918ba593a1137304e3a (diff)
Fix execute_command function to show all the output
This function wasn't showing anything for some commands, like 'rally show images' and 'rally show flavors' JIRA: FUNCTEST-348 Change-Id: I75bf5f3504ea8ffea42c2fb237d6863c655259e1 Signed-off-by: jose.lausuch <jose.lausuch@ericsson.com>
Diffstat (limited to 'utils/functest_utils.py')
-rw-r--r--utils/functest_utils.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/utils/functest_utils.py b/utils/functest_utils.py
index b51a1c86..b46dc7dd 100644
--- a/utils/functest_utils.py
+++ b/utils/functest_utils.py
@@ -243,11 +243,8 @@ def execute_command(cmd, logger=None,
else:
print(msg_exec)
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
- while True:
- output = p.stdout.readline()
- line = output.replace('\n', '')
- if not line:
- break
+ for line in iter(p.stdout.readline, b''):
+ line = line.replace('\n', '')
if logger:
if info:
logger.info(line)
@@ -255,8 +252,9 @@ def execute_command(cmd, logger=None,
logger.debug(line)
else:
print line
- p.communicate()
- if p.returncode != 0:
+ p.stdout.close()
+ returncode = p.wait()
+ if returncode != 0:
if verbose:
if logger:
logger.error(error_msg)
@@ -265,7 +263,7 @@ def execute_command(cmd, logger=None,
if exit_on_error:
sys.exit(1)
- return p.returncode
+ return returncode
def get_deployment_dir(logger=None):