From: Rishabh Dave Date: Wed, 29 Sep 2021 09:40:12 +0000 (+0530) Subject: qa/vstart_runner: add a helper method to run commands X-Git-Tag: v18.0.0~956^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=acc923c8a479bf4df00b1da1fa61a461b23e3dd2;p=ceph-ci.git 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 --- 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