From b0649870eecaf7e00e4f4e122c2111016f1b8d59 Mon Sep 17 00:00:00 2001 From: gavin Date: Mon, 2 Mar 2020 19:32:25 +0530 Subject: [PATCH] fix: random failings from subprocesses and command formatting (#935) * fix: random failings from subprocesses async executions of muliple processes leads to various errors. eg: get-app operation runs a "git clone" at the same time "pip install" is run. This causes failures as the folder either doesnt exist or isnt complete. Proposed solution to this is to execute blocking subprocesseses * style: command logging format via exec_cmd --- bench/utils.py | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/bench/utils.py b/bench/utils.py index 10a25988..c37b0806 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -28,6 +28,7 @@ class color: green = '\033[92m' yellow = '\033[93m' red = '\033[91m' + silver = '\033[90m' def is_bench_directory(directory=os.path.curdir): @@ -172,26 +173,11 @@ def clone_apps_from(bench_path, clone_from, update_app=True): setup_app(app) def exec_cmd(cmd, cwd='.'): - from .cli import from_command_line - - is_async = False if from_command_line else True - if is_async: - stderr = stdout = subprocess.PIPE - else: - stderr = stdout = None - + import shlex logger.info(cmd) - - p = subprocess.Popen(cmd, cwd=cwd, shell=True, stdout=stdout, stderr=stderr, - universal_newlines=True) - - if is_async: - return_code = print_output(p) - else: - return_code = p.wait() - - if return_code > 0: - raise CommandFailedError(cmd) + cmd = shlex.split(cmd) + print("{0}$ {1}{2}".format(color.silver, cmd, color.nc)) + subprocess.call(cmd, cwd=cwd, universal_newlines=True) def which(executable, raise_err = False): from distutils.spawn import find_executable