]> TLD Linux GIT Repositories - tld-builder.git/commitdiff
- more python 3.x fixes
authorMarcin Krol <hawk@tld-linux.org>
Mon, 22 Mar 2021 22:28:40 +0000 (23:28 +0100)
committerMarcin Krol <hawk@tld-linux.org>
Mon, 22 Mar 2021 22:28:40 +0000 (23:28 +0100)
TLD_Builder/file_sender.py
TLD_Builder/load_balancer.py
TLD_Builder/rpm_builder.py
TLD_Builder/srpm_builder.py
TLD_Builder/util.py

index 2a0c1200e0c8fbf93df1b2962fc696dc29041043..18ee8d8da4425c2ae6ec11b1a97f280ad932640a 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(key=mycmp)
+    q.sort(key=util.cmp_to_key(mycmp))
 
     error = None
     # copy of q
index 9560ed68d48054ef66af604a2e5670015e529dd9..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(key=mycmp)
+    bl.sort(key=util.cmp_to_key(mycmp))
 
     f.seek(0)
     f.truncate(0)
index 80677d52de68a0146c26e04745b4ba95ed46a47e..239f5a38b67b5b0c6f654d7b50a31e7d8e5a399b 100644 (file)
@@ -51,7 +51,7 @@ def pick_request(q):
             return cmp(r1.time, r2.time)
         else:
             return pri_diff
-    q.requests.sort(key=mycmp)
+    q.requests.sort(key=util.cmp_to_key(mycmp))
     ret = q.requests[0]
     return ret
 
index 6b8ea545e90acd714dae3614b3ecd24d53d51b45..11f793b27494c7945f641c303401990f44507878 100644 (file)
@@ -42,7 +42,7 @@ def pick_request(q):
             return cmp(r1.time, r2.time)
         else:
             return pri_diff
-    q.requests.sort(key=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