Bug 1632429: Makes mozrelease compatible with python 3 r=aki
authorMitchell Hentges <mhentges@mozilla.com>
Wed, 03 Jun 2020 18:16:09 +0000
changeset 597831 c30caac7237f136fe23f6415e311812670927d49
parent 597830 d1a3ae7eb7da9f9d2064cbf8c037c5b5a42183db
child 597832 c474b7ffe3af28e1f3ca7c7f3589647cdfa29a32
push id13310
push userffxbld-merge
push dateMon, 29 Jun 2020 14:50:06 +0000
treeherdermozilla-beta@15a59a0afa5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaki
bugs1632429
milestone79.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1632429: Makes mozrelease compatible with python 3 r=aki Differential Revision: https://phabricator.services.mozilla.com/D77962
python/mozrelease/mozrelease/chunking.py
python/mozrelease/mozrelease/update_verify.py
--- a/python/mozrelease/mozrelease/chunking.py
+++ b/python/mozrelease/mozrelease/chunking.py
@@ -13,16 +13,16 @@ class ChunkingError(Exception):
 
 def getChunk(things, chunks, thisChunk):
     if thisChunk > chunks:
         raise ChunkingError("thisChunk (%d) is greater than total chunks (%d)" %
                             (thisChunk, chunks))
     possibleThings = copy(things)
     nThings = len(possibleThings)
     for c in range(1, chunks + 1):
-        n = nThings / chunks
+        n = nThings // chunks
         # If our things aren't evenly divisible by the number of chunks
         # we need to append one more onto some of them
         if c <= (nThings % chunks):
             n += 1
         if c == thisChunk:
             return possibleThings[0:n]
         del possibleThings[0:n]
--- a/python/mozrelease/mozrelease/update_verify.py
+++ b/python/mozrelease/mozrelease/update_verify.py
@@ -3,16 +3,17 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, print_function
 
 import os
 import re
 
+import six
 from six import string_types
 
 from .chunking import getChunk
 
 
 class UpdateVerifyError(Exception):
     pass
 
@@ -103,25 +104,26 @@ class UpdateVerifyConfig(object):
             for key in self.key_write_order:
                 if key in self.global_keys and (first or key not in self.first_only_keys):
                     value = getattr(self, key)
                 elif key in self.release_keys:
                     value = releaseInfo[key]
                 else:
                     value = None
                 if value is not None:
-                    fh.write(key)
-                    fh.write("=")
+                    fh.write(six.ensure_binary(key))
+                    fh.write(b"=")
                     if isinstance(value, (list, tuple)):
-                        fh.write('"%s" ' % " ".join(value))
+                        binary_values = [six.ensure_binary(str(v)) for v in value]
+                        fh.write(b'"%s" ' % b" ".join(binary_values))
                     else:
-                        fh.write('"%s" ' % str(value))
+                        fh.write(b'"%s" ' % six.ensure_binary(str(value)))
             # Rewind one character to avoid having a trailing space
             fh.seek(-1, os.SEEK_CUR)
-            fh.write("\n")
+            fh.write(b"\n")
             first = False
 
     def addRelease(self, release=None, build_id=None, locales=[],
                    patch_types=['complete'], from_path=None,
                    ftp_server_from=None, ftp_server_to=None,
                    mar_channel_IDs=None, platform=None, updater_package=None):
         """Locales and patch_types can be passed as either a string or a list.
            If a string is passed, they will be converted to a list for internal