Bug 1316249: tooltool: specify binary mode in all open(..) calls; r=gps
authorDustin J. Mitchell <dustin@mozilla.com>
Thu, 10 Nov 2016 15:08:38 +0000
changeset 348703 8d8337d3199c80c015caf726e9b205ca82cd8334
parent 348702 bc22ca7ff05bbe74b770f9c41ca7bcadfe188d98
child 348704 1fdb1f8a9ddd74fde0ce54694fb096e5317adce7
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1316249
milestone52.0a1
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
testing/docker/recipes/tooltool.py
--- a/testing/docker/recipes/tooltool.py
+++ b/testing/docker/recipes/tooltool.py
@@ -341,17 +341,17 @@ def execute(cmd):
         log.info(line.replace('\n', ' '))
     return process.wait() == 0
 
 
 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
     else:
         log.debug("tried to load absent file '%s' as manifest" % manifest_file)
         raise InvalidManifest(
             "manifest file '%s' does not exist" % manifest_file)
 
@@ -750,17 +750,17 @@ def _log_api_error(e):
     else:
         log.exception("Error making RelengAPI request:")
 
 
 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):
     url = urlparse.urljoin(base_url, 'upload')
     if region is not None:
         url += "?region=" + region
     req = urllib2.Request(url, json.dumps(batch), {'Content-Type': 'application/json'})
     _authorize(req, auth_file)
@@ -776,17 +776,17 @@ def _s3_upload(filename, file):
     # urllib2 does not support streaming, so we fall back to good old httplib
     url = urlparse.urlparse(file['put_url'])
     cls = httplib.HTTPSConnection if url.scheme == 'https' else httplib.HTTPConnection
     host, port = url.netloc.split(':') if ':' in url.netloc else (url.netloc, 443)
     port = int(port)
     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()
         conn.close()
         if resp.status != 200:
             raise RuntimeError("Non-200 return from AWS: %s %s\n%s" %
                                (resp.status, resp.reason, resp_body))
     except Exception: