Use subprocess.check_output() instead of Popen().communicate()
This commit is contained in:
parent
e4faf396e6
commit
093bdcafc9
|
@ -6,14 +6,10 @@ def generate(infile, outfile, fallback):
|
||||||
workdir = os.path.split(infile)[0]
|
workdir = os.path.split(infile)[0]
|
||||||
if workdir == '':
|
if workdir == '':
|
||||||
workdir = '.'
|
workdir = '.'
|
||||||
version = fallback
|
|
||||||
try:
|
try:
|
||||||
p = subprocess.Popen(['git', 'describe'], cwd=workdir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
version = subprocess.check_output(['git', 'describe'], cwd=workdir).decode().strip()
|
||||||
(stdo, _) = p.communicate()
|
|
||||||
if p.returncode == 0:
|
|
||||||
version = stdo.decode().strip()
|
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
version = fallback
|
||||||
with open(infile) as f:
|
with open(infile) as f:
|
||||||
newdata = f.read().replace('@VERSION@', version)
|
newdata = f.read().replace('@VERSION@', version)
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue