Skip to content

Commit

Permalink
Bug 1632348 - Convert mach artifact to python 3. r=rstewart
Browse files Browse the repository at this point in the history
  • Loading branch information
glandium committed Apr 24, 2020
1 parent af3e688 commit 84e3f86
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
1 change: 0 additions & 1 deletion mach
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ py2commands="
analyze
android
android-emulator
artifact
awsy-test
browsertime
cargo
Expand Down
2 changes: 1 addition & 1 deletion python/mozbuild/mozbuild/action/tooltool.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ def open_manifest(manifest_file):
"""I know how to take a filename and load it into a Manifest object"""
if os.path.exists(manifest_file):
manifest = Manifest()
with open(manifest_file, "rb") as f:
with open(manifest_file, "r" if PY3 else "rb") as f:
manifest.load(f)
log.debug("loaded manifest from file '%s'" % manifest_file)
return manifest
Expand Down
2 changes: 1 addition & 1 deletion python/mozbuild/mozbuild/artifact_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def fetch(self, url, force=False):
if len(fname) not in (32, 40, 56, 64, 96, 128):
raise TypeError()
binascii.unhexlify(fname)
except TypeError:
except (TypeError, binascii.Error):
# We download to a temporary name like HASH[:16]-basename to
# differentiate among URLs with the same basenames. We used to then
# extract the build ID from the downloaded artifact and use it to make a
Expand Down
2 changes: 1 addition & 1 deletion python/mozbuild/mozbuild/artifact_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def __init__(self, task_id, artifact_name):
# Keep a sha256 of each downloaded file, for the chain-of-trust
# validation.
if artifact_manifest is not None:
with open(local) as fh:
with open(local, 'rb') as fh:
h = hashlib.sha256()
while True:
data = fh.read(1024 * 1024)
Expand Down
11 changes: 7 additions & 4 deletions python/mozbuild/mozbuild/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,7 @@ def run_hg(self, *args, **kwargs):
env = kwargs.get('env', {})
env['HGPLAIN'] = '1'
kwargs['env'] = ensure_subprocess_env(env)
kwargs['universal_newlines'] = True
return subprocess.check_output([self._hg] + list(args),
**kwargs)

Expand Down Expand Up @@ -979,11 +980,11 @@ def _get_hg_revisions_from_git(self):
self._git, 'rev-list', '--topo-order',
'--max-count={num}'.format(num=NUM_REVISIONS_TO_QUERY),
'HEAD',
], cwd=self._topsrcdir)
], universal_newlines=True, cwd=self._topsrcdir)

hg_hash_list = subprocess.check_output([
self._git, 'cinnabar', 'git2hg'
] + rev_list.splitlines(), cwd=self._topsrcdir)
] + rev_list.splitlines(), universal_newlines=True, cwd=self._topsrcdir)

zeroes = "0" * 40

Expand Down Expand Up @@ -1201,7 +1202,8 @@ def install_from_revset(self, revset, distdir):
elif self._git:
revset = subprocess.check_output([
self._git, 'rev-parse', '%s^{commit}' % revset],
stderr=open(os.devnull, 'w'), cwd=self._topsrcdir).strip()
stderr=open(os.devnull, 'w'), universal_newlines=True,
cwd=self._topsrcdir).strip()
else:
# Fallback to the exception handling case from both hg and git
raise subprocess.CalledProcessError()
Expand All @@ -1215,7 +1217,8 @@ def install_from_revset(self, revset, distdir):

if revision is None and self._git:
revision = subprocess.check_output(
[self._git, 'cinnabar', 'git2hg', revset], cwd=self._topsrcdir).strip()
[self._git, 'cinnabar', 'git2hg', revset], universal_newlines=True,
cwd=self._topsrcdir).strip()

if revision == "0" * 40 or revision is None:
raise ValueError('revision specification must resolve to a commit known to hg')
Expand Down

0 comments on commit 84e3f86

Please sign in to comment.