diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-06-26 14:03:52 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-06-26 14:03:52 +0400 |
commit | 283abdf3b2de08c9e5be764a02e89120fe7b67da (patch) | |
tree | 55e438859ab4c2f53a09be09c35013d832253f56 /build_files/scons/tools/btools.py | |
parent | 0503dc3d021bbb98a0b3a5fa9878f0a0436adcee (diff) |
Fix compilation error with scons and older pythons
Diffstat (limited to 'build_files/scons/tools/btools.py')
-rw-r--r-- | build_files/scons/tools/btools.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/build_files/scons/tools/btools.py b/build_files/scons/tools/btools.py index d22adfda5f6..83daef7c00b 100644 --- a/build_files/scons/tools/btools.py +++ b/build_files/scons/tools/btools.py @@ -14,6 +14,21 @@ import sys Variables = SCons.Variables BoolVariable = SCons.Variables.BoolVariable +def get_command_output(*popenargs, **kwargs): + if hasattr(subprocess, "check_output"): + return subprocess.check_output(*popenargs, **kwargs) + if 'stdout' in kwargs: + raise ValueError('stdout argument not allowed, it will be overridden.') + process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs) + output, unused_err = process.communicate() + retcode = process.poll() + if retcode: + cmd = kwargs.get("args") + if cmd is None: + cmd = popenargs[0] + raise + return output + def get_version(): import re @@ -57,7 +72,7 @@ def get_version(): def get_hash(): try: - build_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).strip() + build_hash = get_command_output(['git', 'rev-parse', '--short', 'HEAD']).strip() except OSError: build_hash = None print("WARNING: could not use git to retrieve current Blender repository hash...") |