tests/functional: replace 'run_cmd' with subprocess helpers

The 'run_cmd' helper is re-implementing a convenient helper that
already exists in the form of the 'run' and 'check_call' methods
provided by 'subprocess'.

Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Message-ID: <20241217155953.3950506-29-berrange@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
This commit is contained in:
Daniel P. Berrangé 2024-12-17 15:59:49 +00:00 committed by Thomas Huth
parent 3bb4c8b613
commit 37e9b19c34
6 changed files with 41 additions and 30 deletions

View file

@ -14,7 +14,6 @@ from urllib.parse import urlparse
import zipfile
from .asset import Asset
from .cmd import run_cmd
def tar_extract(archive, dest_dir, member=None):
@ -52,9 +51,11 @@ def deb_extract(archive, dest_dir, member=None):
cwd = os.getcwd()
os.chdir(dest_dir)
try:
(stdout, stderr, ret) = run_cmd(['ar', 't', archive])
file_path = stdout.split()[2]
run_cmd(['ar', 'x', archive, file_path])
proc = run(['ar', 't', archive],
check=True, capture_output=True, encoding='utf8')
file_path = proc.stdout.split()[2]
check_call(['ar', 'x', archive, file_path],
stdout=DEVNULL, stderr=DEVNULL)
tar_extract(file_path, dest_dir, member)
finally:
os.chdir(cwd)