mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Fix unicode env issues for call()
This commit is contained in:
parent
926439acb2
commit
5ab760e698
1 changed files with 12 additions and 10 deletions
|
@ -116,16 +116,6 @@ def host_triple():
|
||||||
return "%s-%s" % (cpu_type, os_type)
|
return "%s-%s" % (cpu_type, os_type)
|
||||||
|
|
||||||
|
|
||||||
def call(*args, **kwargs):
|
|
||||||
"""Wrap `subprocess.call`, printing the command if verbose=True."""
|
|
||||||
verbose = kwargs.pop('verbose', False)
|
|
||||||
if verbose:
|
|
||||||
print(' '.join(args[0]))
|
|
||||||
# we have to use shell=True in order to get PATH handling
|
|
||||||
# when looking for the binary on Windows
|
|
||||||
return subprocess.call(*args, shell=sys.platform == 'win32', **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
def normalize_env(env):
|
def normalize_env(env):
|
||||||
# There is a bug in subprocess where it doesn't like unicode types in
|
# There is a bug in subprocess where it doesn't like unicode types in
|
||||||
# environment variables. Here, ensure all unicode are converted to
|
# environment variables. Here, ensure all unicode are converted to
|
||||||
|
@ -144,6 +134,18 @@ def normalize_env(env):
|
||||||
return normalized_env
|
return normalized_env
|
||||||
|
|
||||||
|
|
||||||
|
def call(*args, **kwargs):
|
||||||
|
"""Wrap `subprocess.call`, printing the command if verbose=True."""
|
||||||
|
verbose = kwargs.pop('verbose', False)
|
||||||
|
if verbose:
|
||||||
|
print(' '.join(args[0]))
|
||||||
|
if 'env' in kwargs:
|
||||||
|
kwargs['env'] = normalize_env(kwargs['env'])
|
||||||
|
# we have to use shell=True in order to get PATH handling
|
||||||
|
# when looking for the binary on Windows
|
||||||
|
return subprocess.call(*args, shell=sys.platform == 'win32', **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def check_call(*args, **kwargs):
|
def check_call(*args, **kwargs):
|
||||||
"""Wrap `subprocess.check_call`, printing the command if verbose=True.
|
"""Wrap `subprocess.check_call`, printing the command if verbose=True.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue