mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 15:19:41 +00:00
[build] Convert output bytes to UTF-8 in gn_run_binary
The encoding parameter was not available on older versions of python. Change-Id: I5ba56286d1ec1ac616daaac6006f5e9b0167d01d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/195680 Auto-Submit: Alexander Thomas <athom@google.com> Commit-Queue: Alexander Thomas <athom@google.com> Commit-Queue: Alexander Aprelev <aam@google.com> Reviewed-by: Alexander Aprelev <aam@google.com>
This commit is contained in:
parent
2ab4ef2a13
commit
30127ac12d
|
@ -21,17 +21,18 @@ import subprocess
|
||||||
# Run a command, swallowing the output unless there is an error.
|
# Run a command, swallowing the output unless there is an error.
|
||||||
def run_command(command):
|
def run_command(command):
|
||||||
try:
|
try:
|
||||||
subprocess.check_output(command,
|
subprocess.check_output(command, stderr=subprocess.STDOUT)
|
||||||
encoding="UTF-8",
|
|
||||||
stderr=subprocess.STDOUT,
|
|
||||||
universal_newlines=True)
|
|
||||||
return 0
|
return 0
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
return ("Command failed: " + ' '.join(command) + "\n" + "output: " +
|
return ("Command failed: " + ' '.join(command) + "\n" + "output: " +
|
||||||
e.output)
|
_decode(e.output))
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
return ("Command failed: " + ' '.join(command) + "\n" + "output: " +
|
return ("Command failed: " + ' '.join(command) + "\n" + "output: " +
|
||||||
e.strerror)
|
_decode(e.strerror))
|
||||||
|
|
||||||
|
|
||||||
|
def _decode(bytes):
|
||||||
|
return bytes.decode("utf-8")
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
|
|
Loading…
Reference in a new issue