Port some code to Python3

This commit is contained in:
Vincent Ricard 2020-12-28 22:31:49 +01:00 committed by Josh Matthews
parent f73370088b
commit a627dde0d0
24 changed files with 1439 additions and 2341 deletions

View file

@ -749,7 +749,7 @@ install them, let us know by filing a bug!")
# Shorten hash
# NOTE: Partially verifies the hash, but it will still pass if it's, e.g., a tree
git_sha = subprocess.check_output([
'git', 'rev-parse', '--short', git_sha
'git', 'rev-parse', '--short', git_sha.decode('ascii')
])
else:
# This is a regular commit
@ -999,7 +999,7 @@ install them, let us know by filing a bug!")
toolchain = self.rust_toolchain()
status = subprocess.call(
["rustup", "run", toolchain.encode("utf-8"), "rustc", "--version"],
["rustup", "run", toolchain, "rustc", "--version"],
stdout=open(os.devnull, "wb"),
stderr=subprocess.STDOUT,
)

View file

@ -775,7 +775,11 @@ def setup_uwp_signing(ms_app_store, publisher):
def run_powershell_cmd(cmd):
try:
return subprocess.check_output(['powershell.exe', '-NoProfile', '-Command', cmd])
return (
subprocess
.check_output(['powershell.exe', '-NoProfile', '-Command', cmd])
.decode('utf-8')
)
except subprocess.CalledProcessError:
print("ERROR: PowerShell command failed: ", cmd)
exit(1)
@ -841,6 +845,7 @@ def build_uwp(platforms, dev, msbuild_dir, ms_app_store):
.replace("%%PACKAGE_PLATFORMS%%", '|'.join(platforms))
.replace("%%CONFIGURATION%%", Configuration)
.replace("%%SOLUTION%%", path.join(os.getcwd(), 'support', 'hololens', 'ServoApp.sln'))
.encode('utf-8')
)
build_file.close()
# Generate an appxbundle.

View file

@ -243,7 +243,8 @@ class PostBuildCommands(CommandBase):
media_stack=None, **kwargs):
self.ensure_bootstrapped(rustup_components=["rust-docs"])
rustc_path = check_output(
["rustup" + BIN_SUFFIX, "which", "--toolchain", self.rust_toolchain(), "rustc"])
["rustup" + BIN_SUFFIX, "which", "--toolchain", self.rust_toolchain(), "rustc"]
).decode('utf-8')
assert path.basename(path.dirname(rustc_path)) == "bin"
toolchain_path = path.dirname(path.dirname(rustc_path))
rust_docs = path.join(toolchain_path, "share", "doc", "rust", "html")

View file

@ -585,7 +585,10 @@ class MachCommands(CommandBase):
def format(outputs, description, file=sys.stdout):
formatted = "%s %s:\n%s" % (len(outputs), description, "\n".join(outputs))
file.write(formatted.encode("utf-8"))
if file == sys.stdout:
file.write(formatted)
else:
file.write(formatted.encode("utf-8"))
if log_intermittents:
with open(log_intermittents, "wb") as file: