]> TLD Linux GIT Repositories - tld-builder.git/blobdiff - TLD_Builder/request_fetcher.py
- merged PLD changes, now it works with python 3.x
[tld-builder.git] / TLD_Builder / request_fetcher.py
index 9877cde771572ba4e7a23ca73fa2e2251a639ee2..6122612142a2b31bac411ee22b14e68da0e2d57c 100644 (file)
@@ -5,8 +5,11 @@ import signal
 import os
 import urllib
 import urllib2
-import StringIO
 import sys
+if sys.version_info[0] == 2:
+    import StringIO
+else:
+    from io import StringIO
 import gzip
 
 import path
@@ -33,7 +36,7 @@ def has_new(control_url):
     cnt_f = open(path.last_req_no_file)
     try:
         last_count = int(string.strip(cnt_f.readline()))
-    except ValueError, e:
+    except ValueError as e:
         last_count = 0
 
     cnt_f.close()
@@ -47,7 +50,7 @@ def has_new(control_url):
         f = urllib2.urlopen(req)
         count = int(string.strip(f.readline()))
         signal.alarm(0)
-    except Exception, e:
+    except Exception as e:
         signal.alarm(0)
         log.error("can't fetch %s: %s" % (control_url + "/max_req_no", e))
         sys.exit(1)
@@ -66,7 +69,7 @@ def fetch_queue(control_url):
         req = urllib2.Request(url=control_url + "/queue.gz", headers=headers)
         f = urllib2.urlopen(req)
         signal.alarm(0)
-    except Exception, e:
+    except Exception as e:
         signal.alarm(0)
         log.error("can't fetch %s: %s" % (control_url + "/queue.gz", e))
         sys.exit(1)
@@ -77,7 +80,7 @@ def fetch_queue(control_url):
     f = gzip.GzipFile(fileobj = sio)
     try:
         fdata = f.read()
-    except struct.error, e:
+    except struct.error as e:
         log.alert("corrupted fetched queue.gz file")
         sys.exit(1)
     (signers, body) = gpg.verify_sig(fdata)
@@ -99,7 +102,7 @@ def handle_reqs(builder, reqs):
     q.read()
     for r in reqs:
         if r.kind != 'group':
-            raise Exception, 'handle_reqs: fatal: huh? %s' % r.kind
+            raise Exception('handle_reqs: fatal: huh? %s' % r.kind)
         need_it = 0
         for b in r.batches:
             if builder in b.builders: