mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 19:04:45 +00:00
Bug 1575135 - Change get_cmd_output to emit unicode strings. r=nalexander
Because most calling places in python configure don't actually want to deal with encodings, although in practical terms they should, make get_cmd_output handle it itself. Places that explicitly do want bytes can keep using subprocess directly. Differential Revision: https://phabricator.services.mozilla.com/D42604 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
cce0006157
commit
16c5b7db29
@ -71,7 +71,7 @@ def pkg_check_modules(var, package_desc, when=always,
|
||||
return True
|
||||
log.info("no")
|
||||
log_writer = log.warning if allow_missing else log.error
|
||||
with LineIO(lambda l: log_writer(l), 'replace') as o:
|
||||
with LineIO(lambda l: log_writer(l)) as o:
|
||||
o.write(stdout)
|
||||
if not allow_missing:
|
||||
sys.exit(1)
|
||||
|
@ -603,7 +603,6 @@ def check_compiler(compiler, language, target):
|
||||
@imports(_from='__builtin__', _import='open')
|
||||
@imports('json')
|
||||
@imports('os')
|
||||
@imports(_from='mozbuild.util', _import='system_encoding')
|
||||
def get_vc_paths(topsrcdir):
|
||||
def vswhere(args):
|
||||
program_files = (os.environ.get('PROGRAMFILES(X86)') or
|
||||
@ -614,9 +613,7 @@ def get_vc_paths(topsrcdir):
|
||||
'Installer', 'vswhere.exe')
|
||||
if not os.path.exists(vswhere):
|
||||
return []
|
||||
return json.loads(
|
||||
check_cmd_output(vswhere, '-format', 'json', *args)
|
||||
.decode(system_encoding, 'replace'))
|
||||
return json.loads(check_cmd_output(vswhere, '-format', 'json', *args))
|
||||
|
||||
for install in vswhere(['-products', '*', '-requires', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64']):
|
||||
path = install['installationPath']
|
||||
|
@ -26,6 +26,7 @@ def configure_error(message):
|
||||
@imports(_from='__builtin__', _import='unicode')
|
||||
@imports('subprocess')
|
||||
@imports(_from='mozbuild.shellutil', _import='quote')
|
||||
@imports(_from='mozbuild.util', _import='system_encoding')
|
||||
def get_cmd_output(*args, **kwargs):
|
||||
# subprocess on older Pythons can't handle unicode keys or values in
|
||||
# environment dicts. Normalize automagically so callers don't have to
|
||||
@ -53,6 +54,8 @@ def get_cmd_output(*args, **kwargs):
|
||||
close_fds=os.name != 'nt',
|
||||
**kwargs)
|
||||
stdout, stderr = proc.communicate()
|
||||
stdout = stdout.decode(system_encoding, 'replace')
|
||||
stderr = stderr.decode(system_encoding, 'replace')
|
||||
return proc.wait(), stdout, stderr
|
||||
|
||||
|
||||
@ -75,7 +78,7 @@ def check_cmd_output(*args, **kwargs):
|
||||
for out, desc in ((stdout, 'output'), (stderr, 'error output')):
|
||||
if out:
|
||||
log.debug('Its %s was:', desc)
|
||||
with LineIO(lambda l: log.debug('| %s', l), 'replace') as o:
|
||||
with LineIO(lambda l: log.debug('| %s', l)) as o:
|
||||
o.write(out)
|
||||
if onerror:
|
||||
return onerror()
|
||||
|
Loading…
Reference in New Issue
Block a user