From acc923c8a479bf4df00b1da1fa61a461b23e3dd2 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Wed, 29 Sep 2021 15:10:12 +0530 Subject: [PATCH] qa/vstart_runner: add a helper method to run commands It's more convenient to not to pass stdout, stdin, and stderr every single time. Signed-off-by: Rishabh Dave --- qa/tasks/vstart_runner.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/qa/tasks/vstart_runner.py b/qa/tasks/vstart_runner.py index 1203a6769e6..7fa426acdf4 100644 --- a/qa/tasks/vstart_runner.py +++ b/qa/tasks/vstart_runner.py @@ -129,6 +129,13 @@ def respawn_in_path(lib_path, python_paths): sys.path.insert(0, p) +def launch_subprocess(args, cwd=None, env=None, shell=True, + executable='/bin/bash'): + return subprocess.Popen(args, cwd=cwd, env=env, shell=shell, + executable=executable, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, stdin=subprocess.PIPE) + + # Let's use some sensible defaults if os.path.exists("./CMakeCache.txt") and os.path.exists("./bin"): @@ -461,10 +468,7 @@ sudo() { args, usr_args = self._perform_checks_and_adjustments(args, omit_sudo, shell) - subproc = subprocess.Popen(args, stdout=subprocess.PIPE, - stderr=subprocess.PIPE, - stdin=subprocess.PIPE, cwd=cwd, env=env, - shell=shell, executable='/bin/bash') + subproc = launch_subprocess(args, cwd, env, shell) if stdin: # Hack: writing to stdin is not deadlock-safe, but it "always" works