mirror of
https://gitlab.com/libvirt/libvirt-python.git
synced 2025-08-03 08:21:58 +03:00
setup: switch away fron subprocess.Popen()
Adopt subprocess.check_output() as more modern and higher-level way to invoke processes, checking that they succeed, and getting their output. Signed-off-by: Pino Toscano <ptoscano@redhat.com>
This commit is contained in:
committed by
Daniel P. Berrangé
parent
bf83c2b236
commit
41363417b7
32
setup.py
32
setup.py
@ -51,13 +51,9 @@ def get_pkgconfig_data(args, mod, required=True):
|
||||
"""Run pkg-config to and return content associated with it"""
|
||||
|
||||
cmd = ["pkg-config"] + args + [mod]
|
||||
with subprocess.Popen(cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=True) as p:
|
||||
|
||||
line = p.stdout.readline()
|
||||
if line is None or line == "":
|
||||
output = subprocess.check_output(cmd, universal_newlines=True)
|
||||
for line in output.splitlines():
|
||||
if line == "":
|
||||
if required:
|
||||
args_str = " ".join(args)
|
||||
raise Exception(f"Cannot determine '{args_str}' from "
|
||||
@ -205,14 +201,11 @@ class my_sdist(sdist):
|
||||
|
||||
authors = []
|
||||
cmd = ["git", "log", "--pretty=format:%aN <%aE>"]
|
||||
with subprocess.Popen(cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.DEVNULL,
|
||||
universal_newlines=True) as p:
|
||||
for line in p.stdout:
|
||||
line = " " + line.strip()
|
||||
if line not in authors:
|
||||
authors.append(line)
|
||||
output = subprocess.check_output(cmd, universal_newlines=True)
|
||||
for line in output.splitlines():
|
||||
line = " " + line.strip()
|
||||
if line not in authors:
|
||||
authors.append(line)
|
||||
|
||||
authors.sort(key=str.lower)
|
||||
self._gen_from_in("AUTHORS.in",
|
||||
@ -222,12 +215,9 @@ class my_sdist(sdist):
|
||||
|
||||
def gen_changelog(self):
|
||||
cmd = ["git", "log", "--pretty=format:%H:%ct %an <%ae>%n%n%s%n%b%n"]
|
||||
with open("ChangeLog", "w") as f_out, \
|
||||
subprocess.Popen(cmd,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.DEVNULL,
|
||||
universal_newlines=True) as p:
|
||||
for line in p.stdout:
|
||||
with open("ChangeLog", "w") as f_out:
|
||||
output = subprocess.check_output(cmd, universal_newlines=True)
|
||||
for line in output.splitlines():
|
||||
m = re.match(r"([a-f0-9]+):(\d+)\s(.*)", line)
|
||||
if m:
|
||||
t = time.gmtime(int(m.group(2)))
|
||||
|
Reference in New Issue
Block a user