osbuild/util/ostree: convert cli to return the completed process object

And also set stdout=subprocess.PIPE. This will allow for callers to
parse and use the output of the command, but has the side effect of
meaning less gets printed to the screen during run.

Co-authored-by: Luke Yang <luyang@redhat.com>
This commit is contained in:
Dusty Mabe 2023-11-27 16:14:43 -05:00 committed by Achilleas Koutsou
parent e605a3eea0
commit 2e6a3c96ce

View file

@ -199,11 +199,11 @@ def cli(*args, _input=None, **kwargs):
"""Thin wrapper for running the ostree CLI"""
args = list(args) + [f'--{k}={v}' for k, v in kwargs.items()]
print("ostree " + " ".join(args), file=sys.stderr)
subprocess.run(["ostree"] + args,
encoding="utf8",
stdout=sys.stderr,
input=_input,
check=True)
return subprocess.run(["ostree"] + args,
encoding="utf8",
stdout=subprocess.PIPE,
input=_input,
check=True)
def parse_input_commits(commits):