[SCons] Use subprocess.check_output in getCommandOutput
This commit is contained in:
parent
d1df40af87
commit
086e640e46
2 changed files with 3 additions and 11 deletions
|
|
@ -1099,7 +1099,7 @@ if env['python_package'] in ('full','default'):
|
|||
ret = getCommandOutput(env['python_cmd'], threetotwo_cmd, '-l')
|
||||
else:
|
||||
ret = getCommandOutput('3to2' '-l')
|
||||
except OSError as err:
|
||||
except (OSError, subprocess.CalledProcessError) as err:
|
||||
if env['VERBOSE']:
|
||||
print 'Error checking for 3to2:'
|
||||
print err
|
||||
|
|
|
|||
|
|
@ -591,24 +591,16 @@ def getSpawn(env):
|
|||
|
||||
return ourSpawn
|
||||
|
||||
|
||||
def getCommandOutput(cmd, *args):
|
||||
"""
|
||||
Run a command with arguments and return its output.
|
||||
Substitute for subprocess.check_output which is only available
|
||||
in Python >= 2.7
|
||||
"""
|
||||
environ = dict(os.environ)
|
||||
if 'PYTHONHOME' in environ:
|
||||
# Can cause problems when trying to run a different Python interpreter
|
||||
del environ['PYTHONHOME']
|
||||
proc = subprocess.Popen([cmd] + list(args),
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
env=environ)
|
||||
data, err = proc.communicate()
|
||||
if proc.returncode:
|
||||
raise OSError(err)
|
||||
|
||||
data = subprocess.check_output([cmd] + list(args), stderr=subprocess.STDOUT, env=environ)
|
||||
return data.strip()
|
||||
|
||||
# Monkey patch for SCons Cygwin bug
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue