mirror of
https://gitlab.com/libvirt/libvirt-python.git
synced 2025-08-04 12:21:57 +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"""
|
"""Run pkg-config to and return content associated with it"""
|
||||||
|
|
||||||
cmd = ["pkg-config"] + args + [mod]
|
cmd = ["pkg-config"] + args + [mod]
|
||||||
with subprocess.Popen(cmd,
|
output = subprocess.check_output(cmd, universal_newlines=True)
|
||||||
stdout=subprocess.PIPE,
|
for line in output.splitlines():
|
||||||
stderr=subprocess.STDOUT,
|
if line == "":
|
||||||
universal_newlines=True) as p:
|
|
||||||
|
|
||||||
line = p.stdout.readline()
|
|
||||||
if line is None or line == "":
|
|
||||||
if required:
|
if required:
|
||||||
args_str = " ".join(args)
|
args_str = " ".join(args)
|
||||||
raise Exception(f"Cannot determine '{args_str}' from "
|
raise Exception(f"Cannot determine '{args_str}' from "
|
||||||
@ -205,14 +201,11 @@ class my_sdist(sdist):
|
|||||||
|
|
||||||
authors = []
|
authors = []
|
||||||
cmd = ["git", "log", "--pretty=format:%aN <%aE>"]
|
cmd = ["git", "log", "--pretty=format:%aN <%aE>"]
|
||||||
with subprocess.Popen(cmd,
|
output = subprocess.check_output(cmd, universal_newlines=True)
|
||||||
stdout=subprocess.PIPE,
|
for line in output.splitlines():
|
||||||
stderr=subprocess.DEVNULL,
|
line = " " + line.strip()
|
||||||
universal_newlines=True) as p:
|
if line not in authors:
|
||||||
for line in p.stdout:
|
authors.append(line)
|
||||||
line = " " + line.strip()
|
|
||||||
if line not in authors:
|
|
||||||
authors.append(line)
|
|
||||||
|
|
||||||
authors.sort(key=str.lower)
|
authors.sort(key=str.lower)
|
||||||
self._gen_from_in("AUTHORS.in",
|
self._gen_from_in("AUTHORS.in",
|
||||||
@ -222,12 +215,9 @@ class my_sdist(sdist):
|
|||||||
|
|
||||||
def gen_changelog(self):
|
def gen_changelog(self):
|
||||||
cmd = ["git", "log", "--pretty=format:%H:%ct %an <%ae>%n%n%s%n%b%n"]
|
cmd = ["git", "log", "--pretty=format:%H:%ct %an <%ae>%n%n%s%n%b%n"]
|
||||||
with open("ChangeLog", "w") as f_out, \
|
with open("ChangeLog", "w") as f_out:
|
||||||
subprocess.Popen(cmd,
|
output = subprocess.check_output(cmd, universal_newlines=True)
|
||||||
stdout=subprocess.PIPE,
|
for line in output.splitlines():
|
||||||
stderr=subprocess.DEVNULL,
|
|
||||||
universal_newlines=True) as p:
|
|
||||||
for line in p.stdout:
|
|
||||||
m = re.match(r"([a-f0-9]+):(\d+)\s(.*)", line)
|
m = re.match(r"([a-f0-9]+):(\d+)\s(.*)", line)
|
||||||
if m:
|
if m:
|
||||||
t = time.gmtime(int(m.group(2)))
|
t = time.gmtime(int(m.group(2)))
|
||||||
|
Reference in New Issue
Block a user