Use subprocess.check_output() instead of Popen().communicate()

pull/3205/head
Aleksey Filippov 7 years ago
parent e4faf396e6
commit 093bdcafc9
  1. 8
      test cases/common/72 build always/version_gen.py

@ -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…
Cancel
Save