Bug 1316249: tooltool: specify binary mode in all open(..) calls; r=gps

From upstream https://github.com/mozilla/build-tooltool/pull/33

MozReview-Commit-ID: FRex4g9OB2x

--HG--
extra : rebase_source : 55561f663aff6ff3bc58cdcd94add8c623069389
This commit is contained in:
Dustin J. Mitchell 2016-11-10 15:08:38 +00:00
parent 8f4e370c9d
commit bee82aef38

View File

@ -346,7 +346,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) as f:
with open(manifest_file, "rb") as f:
manifest.load(f)
log.debug("loaded manifest from file '%s'" % manifest_file)
return manifest
@ -755,7 +755,7 @@ def _authorize(req, auth_file):
if auth_file:
log.debug("using bearer token in %s" % auth_file)
req.add_unredirected_header('Authorization',
'Bearer %s' % (open(auth_file).read().strip()))
'Bearer %s' % (open(auth_file, "rb").read().strip()))
def _send_batch(base_url, auth_file, batch, region):
@ -781,7 +781,7 @@ def _s3_upload(filename, file):
conn = cls(host, port)
try:
req_path = "%s?%s" % (url.path, url.query) if url.query else url.path
conn.request('PUT', req_path, open(filename),
conn.request('PUT', req_path, open(filename, "rb"),
{'Content-type': 'application/octet-stream'})
resp = conn.getresponse()
resp_body = resp.read()