]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
qa/vstart_runner: add a helper method to run commands
authorRishabh Dave <ridave@redhat.com>
Wed, 29 Sep 2021 09:40:12 +0000 (15:10 +0530)
committerRishabh Dave <ridave@redhat.com>
Mon, 2 May 2022 14:55:19 +0000 (20:25 +0530)
It's more convenient to not to pass stdout, stdin, and stderr every
single time.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
qa/tasks/vstart_runner.py

index 1203a6769e6b6fb13e1bc8a3c71ef69e4873ac10..7fa426acdf459d1929cbd615155dedcd36a94578 100644 (file)
@@ -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