import signal
import os
import urllib
-import urllib2
import sys
-if sys.version_info[0] == 2:
- import StringIO
-else:
- from io import StringIO
+from io import StringIO, BytesIO
import gzip
-
import path
import log
import status
signal.alarm(300)
try:
headers = { 'Cache-Control': 'no-cache', 'Pragma': 'no-cache' }
- req = urllib2.Request(url=control_url + "/max_req_no", headers=headers)
- f = urllib2.urlopen(req)
+ req = urllib.request.Request(url=control_url + "/max_req_no", headers=headers)
+ f = urllib.request.urlopen(req)
count = int(f.readline().strip())
signal.alarm(0)
except Exception as e:
signal.alarm(300)
try:
headers = { 'Cache-Control': 'no-cache', 'Pragma': 'no-cache' }
- req = urllib2.Request(url=control_url + "/queue.gz", headers=headers)
- f = urllib2.urlopen(req)
+ req = urllib.request.Request(url=control_url + "/queue.gz", headers=headers)
+ f = urllib.request.urlopen(req)
signal.alarm(0)
except Exception as e:
signal.alarm(0)
log.error("can't fetch %s: %s" % (control_url + "/queue.gz", e))
sys.exit(1)
- sio = StringIO()
+ sio = BytesIO()
util.sendfile(f, sio)
f.close()
sio.seek(0)