From 90e89153ad56b37c24ba84ec1ade4dd4984a4059 Mon Sep 17 00:00:00 2001 From: Marcin Krol Date: Sun, 2 May 2021 15:13:14 +0200 Subject: [PATCH] - substitute cmp for python3 --- TLD_Builder/file_sender.py | 4 ++-- TLD_Builder/load_balancer.py | 2 +- TLD_Builder/rpm_builder.py | 4 ++-- TLD_Builder/srpm_builder.py | 4 ++-- TLD_Builder/util.py | 3 +++ 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/TLD_Builder/file_sender.py b/TLD_Builder/file_sender.py index 0560458..b28980e 100644 --- a/TLD_Builder/file_sender.py +++ b/TLD_Builder/file_sender.py @@ -163,9 +163,9 @@ def flush_queue(dir): d = read_name_val(f) if d != None: q.append(d) def mycmp(x, y): - rc = cmp(x['Time'], y['Time']) + rc = util.cmp(x['Time'], y['Time']) if rc == 0 and 'Type' in x and 'Type' in y: - return cmp(x['Type'], y['Type']) + return util.cmp(x['Type'], y['Type']) else: return rc q.sort(key=util.cmp_to_key(mycmp)) diff --git a/TLD_Builder/load_balancer.py b/TLD_Builder/load_balancer.py index 43d85d5..459034b 100644 --- a/TLD_Builder/load_balancer.py +++ b/TLD_Builder/load_balancer.py @@ -39,7 +39,7 @@ def builders_order(): log.alert("found strange lock in got-lock: %s" % b) def mycmp(b1, b2): - return cmp(bs[b1], bs[b2]) + return util.cmp(bs[b1], bs[b2]) bl.sort(key=util.cmp_to_key(mycmp)) diff --git a/TLD_Builder/rpm_builder.py b/TLD_Builder/rpm_builder.py index 65ab8e2..666f7d6 100644 --- a/TLD_Builder/rpm_builder.py +++ b/TLD_Builder/rpm_builder.py @@ -45,9 +45,9 @@ def pick_request(q): def mycmp(r1, r2): if r1.kind != 'group' or r2.kind != 'group': raise Exception("non-group requests") - pri_diff = cmp(r1.priority, r2.priority) + pri_diff = util.cmp(r1.priority, r2.priority) if pri_diff == 0: - return cmp(r1.time, r2.time) + return util.cmp(r1.time, r2.time) else: return pri_diff q.requests.sort(key=util.cmp_to_key(mycmp)) diff --git a/TLD_Builder/srpm_builder.py b/TLD_Builder/srpm_builder.py index 510b1f7..d761466 100644 --- a/TLD_Builder/srpm_builder.py +++ b/TLD_Builder/srpm_builder.py @@ -33,9 +33,9 @@ def pick_request(q): def mycmp(r1, r2): if r1.kind != 'group' or r2.kind != 'group': raise Exception("non-group requests") - pri_diff = cmp(r1.priority, r2.priority) + pri_diff = util.cmp(r1.priority, r2.priority) if pri_diff == 0: - return cmp(r1.time, r2.time) + return util.cmp(r1.time, r2.time) else: return pri_diff q.requests.sort(key=util.cmp_to_key(mycmp)) diff --git a/TLD_Builder/util.py b/TLD_Builder/util.py index b6bcc24..602bad1 100644 --- a/TLD_Builder/util.py +++ b/TLD_Builder/util.py @@ -112,3 +112,6 @@ def to_str(s): return s else: raise TypeError("Expected bytes or string, but got %s." % type(s)) + +def cmp(a, b): + return (a > b) - (a < b) -- 2.46.0