return
try:
self.requests = request.parse_requests(body)
- except Exception, e:
+ except Exception as e:
log.panic("error parsing %s: %s" % (self.name, e))
pass
req.add_header('X-Filename', os.path.basename(src))
f = urllib2.urlopen(req)
f.close()
- except Exception, e:
+ except Exception as e:
problems[src] = e
return e
return 0
if m:
return not post_file(src, target)
log.alert("unsupported protocol: %s" % target)
- except OSError, e:
+ except OSError as e:
problems[src] = e
log.error("send_file(%s, %s): %s" % (src, target, e))
return False
gpg_run = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
try:
d_stdout, d_stderr = gpg_run.communicate(buf.encode('utf-8'))
- except OSError, e:
+ except OSError as e:
log.error("gnupg run, does gpg binary exist? : %s" % e)
raise
gpg_run = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
try:
d_stdout, d_stderr = gpg_run.communicate(buf.encode('utf-8'))
- except OSError, e:
+ except OSError as e:
log.error("gnupg run failed, does gpg binary exist? : %s" % e)
raise
gpg_run = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, close_fds=True)
try:
d_stdout, d_stderr = gpg_run.communicate(buf.encode('utf-8'))
- except OSError, e:
+ except OSError as e:
log.error("gnupg signing failed, does gpg binary exist? : %s" % e)
raise
f = os.popen(send_sendmail, "w")
try:
self.write_to(f)
- except IOError, e:
+ except IOError as e:
log.alert("sending email message failed: %s" % e)
f.close()
return False
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()
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)
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)
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)
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:
self.send_response(200)
self.end_headers()
- except Exception, e:
+ except Exception as e:
self.send_error(500, "%s: %s" % (filename, e))
self.end_headers()
log.error("request_handler_server: [%s]: exception: %s\n%s" % (self.client_address[0], e, traceback.format_exc()))
certfile = config.request_handler_server_ssl_cert,
ca_certs = "/etc/certs/ca-certificates.crt",
server_side=True)
- except Exception, e:
+ except Exception as e:
log.notice("request_handler_server: can't start server on [%s:%d], ssl=%s: %s" % (host, port, str(srv_ssl), e))
print >> sys.stderr, "ERROR: Can't start server on [%s:%d], ssl=%s: %s" % (host, port, str(srv_ssl), e)
sys.exit(1)
def pick_request(q):
def mycmp(r1, r2):
if r1.kind != 'group' or r2.kind != 'group':
- raise Exception, "non-group requests"
+ raise Exception("non-group requests")
pri_diff = cmp(r1.priority, r2.priority)
if pri_diff == 0:
return cmp(r1.time, r2.time)
req = urllib2.Request(url=src_url, headers=headers)
f = urllib2.urlopen(req)
good = True
- except urllib2.HTTPError, error:
+ except urllib2.HTTPError as error:
return False
- except urllib2.URLError, error:
+ except urllib2.URLError as error:
# see errno.h
try:
errno = error.errno
req = urllib2.Request(url=src_url, headers=headers)
f = urllib2.urlopen(req)
good = True
- except urllib2.HTTPError, error:
+ except urllib2.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)
queue_time = time.time() - r.time
# 6 hours
if error.code != 404 or (queue_time >= 0 and queue_time < (6 * 60 * 60)):
- raise IOError, msg
+ raise IOError(msg)
else:
msg = "in queue for more than 6 hours, download failing"
b.log_line(msg)
return False
- except urllib2.URLError, error:
+ except urllib2.URLError as error:
errno = 0
if isinstance(error.args[0], IOError):
errno = error.args[0].errno
else:
try:
print("error.errno: %s" % str(error.errno))
- except Exception, e:
+ except Exception as e:
print("error.errno: exception %s" % e)
try:
print("error.reason %s" % str(error.reason))
- except Exception, e:
+ except Exception as e:
print("error.reason exception %s" % e)
raise
try:
bytes = util.sendfile(f, o)
- except IOError, e:
+ except IOError as e:
b.log_line("error: unable to write to `%s': %s" % (b.src_rpm, e))
raise
def main():
if len(sys.argv) < 2:
- raise Exception, "fatal: need to have builder name as first arg"
+ raise Exception("fatal: need to have builder name as first arg")
return main_for(sys.argv[1])
if __name__ == '__main__':
req = urllib2.Request(url, data)
f = urllib2.urlopen(req)
f.close()
-except Exception, e:
+except Exception as e:
print >> sys.stderr, "Problem while sending request via HTTP: %s: %s" % (url, e)
sys.exit(1)
print >> sys.stdout, "Request queued via HTTP."