X-Git-Url: https://git.tld-linux.org/?a=blobdiff_plain;f=TLD_Builder%2Frpm_builder.py;h=666f7d6744134dfb2153c63a03a774c58149291a;hb=90e89153ad56b37c24ba84ec1ade4dd4984a4059;hp=e33a7e1ff325a55557ec5607b479d022c8d61a73;hpb=9ea122b00e3a99b16246e1e38576916a2e25c0aa;p=tld-builder.git diff --git a/TLD_Builder/rpm_builder.py b/TLD_Builder/rpm_builder.py index e33a7e1..666f7d6 100644 --- a/TLD_Builder/rpm_builder.py +++ b/TLD_Builder/rpm_builder.py @@ -9,7 +9,6 @@ import time import datetime import string import urllib -import urllib2 from config import config, init_conf from bqueue import B_Queue @@ -46,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)) @@ -62,12 +61,12 @@ def check_skip_build(r, b): while not good: try: headers = { 'Cache-Control': 'no-cache', 'Pragma': 'no-cache' } - req = urllib2.Request(url=src_url, headers=headers) - f = urllib2.urlopen(req) + req = urllib.request.Request(url=src_url, headers=headers) + f = urllib.request.urlopen(req) good = True - except urllib2.HTTPError as error: + except urllib.error.HTTPError as error: return False - except urllib2.URLError as error: + except urllib.error.URLError as error: # see errno.h try: errno = error.errno @@ -92,10 +91,10 @@ def fetch_src(r, b): while not good: try: headers = { 'Cache-Control': 'no-cache', 'Pragma': 'no-cache' } - req = urllib2.Request(url=src_url, headers=headers) - f = urllib2.urlopen(req) + req = urllib.request.Request(url=src_url, headers=headers) + f = urllib.request.urlopen(req) good = True - except urllib2.HTTPError as error: + except urllib.error.HTTPError as error: # fail in a way where cron job will retry msg = "unable to fetch url %s, http code: %d" % (src_url, error.code) b.log_line(msg) @@ -107,7 +106,7 @@ def fetch_src(r, b): msg = "in queue for more than 6 hours, download failing" b.log_line(msg) return False - except urllib2.URLError as error: + except urllib.error.URLError as error: errno = 0 if isinstance(error.args[0], IOError): errno = error.args[0].errno