]> git.pld-linux.org Git - projects/pld-builder.new.git/commitdiff
- more python 3.x fixes
authorMarcin Krol <mk@furud.net>
Mon, 22 Mar 2021 22:49:23 +0000 (23:49 +0100)
committerMarcin Krol <mk@furud.net>
Mon, 22 Mar 2021 22:49:23 +0000 (23:49 +0100)
13 files changed:
PLD_Builder/bqueue.py
PLD_Builder/chroot.py
PLD_Builder/file_sender.py
PLD_Builder/install.py
PLD_Builder/load_balancer.py
PLD_Builder/mailer.py
PLD_Builder/notify.py
PLD_Builder/pipeutil.py
PLD_Builder/request_fetcher.py
PLD_Builder/rpm_builder.py
PLD_Builder/srpm_builder.py
PLD_Builder/util.py
PLD_Builder/wrap.py

index 3ab19c36118c296975833c2cecfa5cc693c7c818..aaa249c074ccf0e81cf7907e3ef215df21f56031 100644 (file)
@@ -128,7 +128,7 @@ class B_Queue:
         fcntl.flock(self.fd, fcntl.LOCK_UN)
 
     def write_signed(self, name):
-        sio = StringIO.StringIO()
+        sio = StringIO()
         self._write_to(sio)
         sio.seek(0)
         sio.write(gpg.sign(sio.read()))
index a489ac3cd01206a68c01e7eb09ab7420652c3893..f91e1c60369c6d0511f9391753430ba5e597d877 100644 (file)
@@ -49,7 +49,7 @@ def run(cmd, user = "builder", logfile = None, logstdout = None):
 
 def cp(file, outfile, user="builder", rm=False):
     m = md5()
-    m.update(str(random.sample(range(100000), 500)))
+    m.update(str(random.sample(range(100000), 500)).encode('utf-8'))
     digest = m.hexdigest()
 
     marker_start = "--- FILE BEGIN DIGEST %s ---" % digest
index 933eedfcbb021f738b3f798d6352d6e434b0ce27..c6cc459f47ee7876fffde1e324fb7b840bf5b21a 100644 (file)
@@ -17,6 +17,7 @@ import log
 import loop
 import status
 import lock
+import util
 
 retries_times = [5 * 60, 5 * 60, 10 * 60, 10 * 60, 30 * 60, 60 * 60]
 
@@ -168,7 +169,7 @@ def flush_queue(dir):
             return cmp(x['Type'], y['Type'])
         else:
             return rc
-    q.sort(mycmp)
+    q.sort(key=util.cmp_to_key(mycmp))
 
     error = None
     # copy of q
index f6f071978b07b5ecd564c9c8d2b0b7445c7515ff..edb4ae90c4fb003946a67508bf5869ca717a9d4a 100644 (file)
@@ -79,7 +79,7 @@ def upgrade_from_batch(r, b):
             b.log_line("upgrade would need removal of %s" % k)
             return False
     b.log_line("upgrading packages")
-    logbuf = StringIO.StringIO()
+    logbuf = StringIO()
     res = chroot.run("rpm -Fvh %s" % ' '.join(b.files), user = "root", logfile = b.logfile)
     if res != 0:
         b.log_line("package upgrade failed")
index 019c1844fb786c69e8cb94e45a9a366149ffdea4..43d85d56dc2ab4e503e1a3f58960351247d66abd 100644 (file)
@@ -10,6 +10,7 @@ import log
 import status
 import lock
 import loop
+import util
 
 import rpm_builder
 
@@ -40,7 +41,7 @@ def builders_order():
     def mycmp(b1, b2):
         return cmp(bs[b1], bs[b2])
 
-    bl.sort(mycmp)
+    bl.sort(key=util.cmp_to_key(mycmp))
 
     f.seek(0)
     f.truncate(0)
index 56a9f14d9bae7c969ea21fa6bb80a0ef1fa00ae9..0c6ea27fd9d5e6436c26ed7a2bf9e3c59aedb187 100644 (file)
@@ -21,7 +21,7 @@ def recode(s):
 class Message:
     def __init__(self):
         self.headers = {}
-        self.body = StringIO.StringIO()
+        self.body = StringIO()
         self.set_std_headers()
 
     def set_header(self, n, v):
index ed5df8b432346997c8f960fffe44967ac39d8d87..e13c05235f2ba80a6d05be69ba2a8d681ded61aa 100644 (file)
@@ -14,12 +14,12 @@ from config import config
 
 class Notifier:
     def __init__(self, g):
-        self.xml = StringIO.StringIO()
+        self.xml = StringIO()
         self.xml.write("<notification group-id='%s' builder='%s'>\n" % \
                         (g.id, config.builder))
 
     def send(self, r):
-        sio = StringIO.StringIO()
+        sio = StringIO()
         self.xml.write("</notification>\n")
         self.xml.seek(0)
         sio.write(gpg.sign(self.xml.read()))
index 9a3ca23cf2f927daae4128aacccf1ba78d07d318..a3e78c9a1d7be8ff7b819a12d58c43c0ea5fdbe2 100644 (file)
@@ -9,9 +9,9 @@ else:
     from io import StringIO
 
 def rw_pipe(buf_, infd, outfd):
-    buf = StringIO.StringIO()
+    buf = StringIO()
     buf.write(buf_.read())
-    ret = StringIO.StringIO()
+    ret = StringIO()
     pos = 0
     rd_fin = 0
     wr_fin = 0
index 609ec711bcf644425bc247a671e6df4a45e44339..fc9f49dac3c21a26719070d4af7d39dd9b97f604 100644 (file)
@@ -73,7 +73,7 @@ def fetch_queue(control_url):
         signal.alarm(0)
         log.error("can't fetch %s: %s" % (control_url + "/queue.gz", e))
         sys.exit(1)
-    sio = StringIO.StringIO()
+    sio = StringIO()
     util.sendfile(f, sio)
     f.close()
     sio.seek(0)
index 59bd9ef60fcee54e6844f71884c0f7cbc124a344..0126161422a75f028e6bf3c9b5b1d6c62c13eee1 100644 (file)
@@ -51,7 +51,7 @@ def pick_request(q):
             return cmp(r1.time, r2.time)
         else:
             return pri_diff
-    q.requests.sort(mycmp)
+    q.requests.sort(key=util.cmp_to_key(mycmp))
     ret = q.requests[0]
     return ret
 
index 2d75720efcae65856bb4f11fb702615cfb8dc552..bee5f98c040b487affcb09a16f316af8ab2f0bc8 100644 (file)
@@ -42,7 +42,7 @@ def pick_request(q):
             return cmp(r1.time, r2.time)
         else:
             return pri_diff
-    q.requests.sort(mycmp)
+    q.requests.sort(key=util.cmp_to_key(mycmp))
     ret = q.requests[0]
     q.requests = q.requests[1:]
     return ret
index 67bd9a1be30d230f7be2c0bdf4d9a32b4a1c3ba3..05cf076753ee6ec6ce8ccc4804bbf4f6b01c256c 100644 (file)
@@ -76,3 +76,22 @@ def find_last_section(log):
             last_section = m.group(1)
     f.close()
     return last_section
+
+def cmp_to_key(mycmp):
+    'Convert a cmp= function into a key= function'
+    class K:
+        def __init__(self, obj, *args):
+            self.obj = obj
+        def __lt__(self, other):
+            return mycmp(self.obj, other.obj) < 0
+        def __gt__(self, other):
+            return mycmp(self.obj, other.obj) > 0
+        def __eq__(self, other):
+            return mycmp(self.obj, other.obj) == 0
+        def __le__(self, other):
+            return mycmp(self.obj, other.obj) <= 0
+        def __ge__(self, other):
+            return mycmp(self.obj, other.obj) >= 0
+        def __ne__(self, other):
+            return mycmp(self.obj, other.obj) != 0
+    return K
index 7391d4d681c48f76ed100537083571793d13c1ac..e343e169c7f3207c6798bc0e4701d73719a87ac6 100644 (file)
@@ -48,7 +48,7 @@ def wrap(main):
         exctype, value = sys.exc_info()[:2]
         if exctype == SystemExit:
             sys.exit(value)
-        s = StringIO.StringIO()
+        s = StringIO()
         traceback.print_exc(file = s, limit = 20)
 
         log.alert("fatal python exception")
This page took 0.530251 seconds and 4 git commands to generate.