Use subprocess.Popen, hoping for Windows portability

Replaces use of subprocess.check_output
This commit is contained in:
David Neto 2016-02-23 17:58:31 -05:00
Родитель b6ccd0d891
Коммит b38ac4bae6
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -34,8 +34,10 @@ def describe(dir):
"""Runs 'git describe' in dir. If successful, returns the output; otherwise,
returns 'unknown hash, <date>'."""
try:
return subprocess.check_output(["git", "describe"], cwd=dir).rstrip()
except subprocess.CalledProcessError:
p = subprocess.Popen(["git", "describe"], stdout=subprocess.PIPE, cwd=dir)
(stdout, _) = p.communicate()
return stdout.rstrip()
except:
return 'unknown hash, ' + datetime.date.today().isoformat()
def main():