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]
|
||||
if workdir == '':
|
||||
workdir = '.'
|
||||
version = fallback
|
||||
try:
|
||||
p = subprocess.Popen(['git', 'describe'], cwd=workdir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
(stdo, _) = p.communicate()
|
||||
if p.returncode == 0:
|
||||
version = stdo.decode().strip()
|
||||
version = subprocess.check_output(['git', 'describe'], cwd=workdir).decode().strip()
|
||||
except Exception:
|
||||
pass
|
||||
version = fallback
|
||||
with open(infile) as f:
|
||||
newdata = f.read().replace('@VERSION@', version)
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue