Merge pull request #1197 from dirkmueller/python3

Python 2.6+ / 3.x style except clauses
This commit is contained in:
Jimmy Berry 2017-10-18 20:50:02 -05:00 committed by GitHub
commit 3349bd964a
21 changed files with 63 additions and 63 deletions

View File

@ -367,7 +367,7 @@ class ReviewBot(object):
node = ET.fromstring(''.join(m)).find('devel') node = ET.fromstring(''.join(m)).find('devel')
if node is not None: if node is not None:
return node.get('project'), node.get('package', None) return node.get('project'), node.get('package', None)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code != 404: if e.code != 404:
raise e raise e
return None, None return None, None
@ -387,7 +387,7 @@ class ReviewBot(object):
else: else:
return False return False
states = set([review.get('state') for review in root.findall('review') if review.get(by_what) == reviewer]) states = set([review.get('state') for review in root.findall('review') if review.get(by_what) == reviewer])
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
print('ERROR in URL %s [%s]' % (url, e)) print('ERROR in URL %s [%s]' % (url, e))
if not states: if not states:
return None return None
@ -644,7 +644,7 @@ class CommandLineInterface(cmdln.Cmdln):
while True: while True:
try: try:
workfunc() workfunc()
except Exception, e: except Exception as e:
self.logger.exception(e) self.logger.exception(e)
if interval: if interval:

View File

@ -67,7 +67,7 @@ class ToolBase(object):
def retried_GET(self, url): def retried_GET(self, url):
try: try:
return http_GET(url) return http_GET(url)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if 500 <= e.code <= 599: if 500 <= e.code <= 599:
print 'Retrying {}'.format(url) print 'Retrying {}'.format(url)
time.sleep(1) time.sleep(1)
@ -195,7 +195,7 @@ class CommandLineInterface(cmdln.Cmdln):
while True: while True:
try: try:
workfunc() workfunc()
except Exception, e: except Exception as e:
logger.exception(e) logger.exception(e)
if interval: if interval:

View File

@ -237,16 +237,16 @@ class ABIChecker(ReviewBot.ReviewBot):
try: try:
# compute list of common repos to find out what to compare # compute list of common repos to find out what to compare
myrepos = self.findrepos(src_project, src_srcinfo, dst_project, dst_srcinfo) myrepos = self.findrepos(src_project, src_srcinfo, dst_project, dst_srcinfo)
except NoBuildSuccess, e: except NoBuildSuccess as e:
self.logger.info(e) self.logger.info(e)
self.text_summary += "**Error**: %s\n"%e self.text_summary += "**Error**: %s\n"%e
self.reports.append(report) self.reports.append(report)
return False return False
except NotReadyYet, e: except NotReadyYet as e:
self.logger.info(e) self.logger.info(e)
self.reports.append(report) self.reports.append(report)
return None return None
except SourceBroken, e: except SourceBroken as e:
self.logger.error(e) self.logger.error(e)
self.text_summary += "**Error**: %s\n"%e self.text_summary += "**Error**: %s\n"%e
self.reports.append(report) self.reports.append(report)
@ -271,21 +271,21 @@ class ABIChecker(ReviewBot.ReviewBot):
dst_srcinfo = origin_srcinfo dst_srcinfo = origin_srcinfo
if new_repo_map is not None: if new_repo_map is not None:
myrepos = new_repo_map myrepos = new_repo_map
except MaintenanceError, e: except MaintenanceError as e:
self.text_summary += "**Error**: %s\n\n"%e self.text_summary += "**Error**: %s\n\n"%e
self.logger.error('%s', e) self.logger.error('%s', e)
self.reports.append(report) self.reports.append(report)
return False return False
except NoBuildSuccess, e: except NoBuildSuccess as e:
self.logger.info(e) self.logger.info(e)
self.text_summary += "**Error**: %s\n"%e self.text_summary += "**Error**: %s\n"%e
self.reports.append(report) self.reports.append(report)
return False return False
except NotReadyYet, e: except NotReadyYet as e:
self.logger.info(e) self.logger.info(e)
self.reports.append(report) self.reports.append(report)
return None return None
except SourceBroken, e: except SourceBroken as e:
self.logger.error(e) self.logger.error(e)
self.text_summary += "**Error**: %s\n"%e self.text_summary += "**Error**: %s\n"%e
self.reports.append(report) self.reports.append(report)
@ -304,16 +304,16 @@ class ABIChecker(ReviewBot.ReviewBot):
# nothing to fetch, so no libs # nothing to fetch, so no libs
if dst_libs is None: if dst_libs is None:
continue continue
except DistUrlMismatch, e: except DistUrlMismatch as e:
self.logger.error("%s/%s %s/%s: %s"%(dst_project, dst_package, mr.dstrepo, mr.arch, e)) self.logger.error("%s/%s %s/%s: %s"%(dst_project, dst_package, mr.dstrepo, mr.arch, e))
if ret == True: # need to check again if ret == True: # need to check again
ret = None ret = None
continue continue
except MissingDebugInfo, e: except MissingDebugInfo as e:
missing_debuginfo.append(str(e)) missing_debuginfo.append(str(e))
ret = False ret = False
continue continue
except FetchError, e: except FetchError as e:
self.logger.error(e) self.logger.error(e)
if ret == True: # need to check again if ret == True: # need to check again
ret = None ret = None
@ -325,16 +325,16 @@ class ABIChecker(ReviewBot.ReviewBot):
if dst_libs: if dst_libs:
self.text_summary += "*Warning*: the submission does not contain any libs anymore\n\n" self.text_summary += "*Warning*: the submission does not contain any libs anymore\n\n"
continue continue
except DistUrlMismatch, e: except DistUrlMismatch as e:
self.logger.error("%s/%s %s/%s: %s"%(src_project, src_package, mr.srcrepo, mr.arch, e)) self.logger.error("%s/%s %s/%s: %s"%(src_project, src_package, mr.srcrepo, mr.arch, e))
if ret == True: # need to check again if ret == True: # need to check again
ret = None ret = None
continue continue
except MissingDebugInfo, e: except MissingDebugInfo as e:
missing_debuginfo.append(str(e)) missing_debuginfo.append(str(e))
ret = False ret = False
continue continue
except FetchError, e: except FetchError as e:
self.logger.error(e) self.logger.error(e)
if ret == True: # need to check again if ret == True: # need to check again
ret = None ret = None
@ -530,7 +530,7 @@ class ABIChecker(ReviewBot.ReviewBot):
self.text_summary = '' self.text_summary = ''
try: try:
ret = ReviewBot.ReviewBot.check_one_request(self, req) ret = ReviewBot.ReviewBot.check_one_request(self, req)
except Exception, e: except Exception as e:
import traceback import traceback
self.logger.error("unhandled exception in ABI checker") self.logger.error("unhandled exception in ABI checker")
self.logger.error(traceback.format_exc()) self.logger.error(traceback.format_exc())
@ -572,7 +572,7 @@ class ABIChecker(ReviewBot.ReviewBot):
request = self.session.query(DB.Request).filter(DB.Request.id == reqid).one() request = self.session.query(DB.Request).filter(DB.Request.id == reqid).one()
if request.state == 'done': if request.state == 'done':
return True return True
except sqlalchemy.orm.exc.NoResultFound, e: except sqlalchemy.orm.exc.NoResultFound as e:
pass pass
return False return False
@ -586,7 +586,7 @@ class ABIChecker(ReviewBot.ReviewBot):
self.session.flush() self.session.flush()
request.state = state request.state = state
request.result = result request.result = result
except sqlalchemy.orm.exc.NoResultFound, e: except sqlalchemy.orm.exc.NoResultFound as e:
request = DB.Request(id = req.reqid, request = DB.Request(id = req.reqid,
state = state, state = state,
result = result, result = result,
@ -771,7 +771,7 @@ class ABIChecker(ReviewBot.ReviewBot):
h = None h = None
try: try:
h = self.ts.hdrFromFdno(fd) h = self.ts.hdrFromFdno(fd)
except rpm.error, e: except rpm.error as e:
if str(e) == "public key not available": if str(e) == "public key not available":
print str(e) print str(e)
if str(e) == "public key not trusted": if str(e) == "public key not trusted":
@ -786,7 +786,7 @@ class ABIChecker(ReviewBot.ReviewBot):
[ 'view=cpioheaders' ]) [ 'view=cpioheaders' ])
try: try:
r = osc.core.http_GET(u) r = osc.core.http_GET(u)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
raise FetchError('failed to fetch header information: %s'%e) raise FetchError('failed to fetch header information: %s'%e)
tmpfile = NamedTemporaryFile(prefix="cpio-", delete=False) tmpfile = NamedTemporaryFile(prefix="cpio-", delete=False)
for chunk in r: for chunk in r:
@ -831,7 +831,7 @@ class ABIChecker(ReviewBot.ReviewBot):
'srcmd5' : rev } 'srcmd5' : rev }
url = osc.core.makeurl(self.apiurl, ('build', src_project, '_result'), query) url = osc.core.makeurl(self.apiurl, ('build', src_project, '_result'), query)
return ET.parse(osc.core.http_GET(url)).getroot() return ET.parse(osc.core.http_GET(url)).getroot()
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code != 404: if e.code != 404:
self.logger.error('ERROR in URL %s [%s]' % (url, e)) self.logger.error('ERROR in URL %s [%s]' % (url, e))
raise raise

View File

@ -37,7 +37,7 @@ class Config(object):
try: try:
entry = self.session.query(DB.Config).filter(DB.Config.key == key).one() entry = self.session.query(DB.Config).filter(DB.Config.key == key).one()
entry.value = value entry.value = value
except sqlalchemy.orm.exc.NoResultFound, e: except sqlalchemy.orm.exc.NoResultFound as e:
entry = DB.Config(key=key, value=value) entry = DB.Config(key=key, value=value)
self.session.add(entry) self.session.add(entry)
self.session.commit() self.session.commit()
@ -46,7 +46,7 @@ class Config(object):
try: try:
entry = self.session.query(DB.Config).filter(DB.Config.key == key).one() entry = self.session.query(DB.Config).filter(DB.Config.key == key).one()
return entry.value return entry.value
except sqlalchemy.orm.exc.NoResultFound, e: except sqlalchemy.orm.exc.NoResultFound as e:
pass pass
return default return default
@ -56,7 +56,7 @@ class Config(object):
self.session.delete(entry) self.session.delete(entry)
self.session.commit() self.session.commit()
return True return True
except sqlalchemy.orm.exc.NoResultFound, e: except sqlalchemy.orm.exc.NoResultFound as e:
pass pass
return False return False

View File

@ -147,7 +147,7 @@ class BiArchTool(ToolBase.ToolBase):
try: try:
x = ET.fromstring(self.cached_GET(self.makeurl(['source', self.project, pkg, '_history'], {'rev':'1'}))) x = ET.fromstring(self.cached_GET(self.makeurl(['source', self.project, pkg, '_history'], {'rev':'1'})))
# catch deleted packages # catch deleted packages
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code == 404: if e.code == 404:
continue continue
raise e raise e
@ -188,7 +188,7 @@ class BiArchTool(ToolBase.ToolBase):
self.http_PUT(pkgmetaurl, data=ET.tostring(pkgmeta)) self.http_PUT(pkgmetaurl, data=ET.tostring(pkgmeta))
if self.caching: if self.caching:
self._invalidate__cached_GET(pkgmetaurl) self._invalidate__cached_GET(pkgmetaurl)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
logger.error('failed to update %s: %s', pkg, e) logger.error('failed to update %s: %s', pkg, e)
def add_explicit_disable(self, wipebinaries=False): def add_explicit_disable(self, wipebinaries=False):
@ -225,7 +225,7 @@ class BiArchTool(ToolBase.ToolBase):
'cmd' : 'wipe', 'cmd' : 'wipe',
'arch': self.arch, 'arch': self.arch,
'package' : pkg })) 'package' : pkg }))
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
logger.error('failed to update %s: %s', pkg, e) logger.error('failed to update %s: %s', pkg, e)
@ -236,7 +236,7 @@ class BiArchTool(ToolBase.ToolBase):
pkgmetaurl = self.makeurl(['source', self.project, pkg, '_meta']) pkgmetaurl = self.makeurl(['source', self.project, pkg, '_meta'])
try: try:
pkgmeta = ET.fromstring(self.cached_GET(pkgmetaurl)) pkgmeta = ET.fromstring(self.cached_GET(pkgmetaurl))
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
# catch deleted packages # catch deleted packages
if e.code == 404: if e.code == 404:
continue continue
@ -303,7 +303,7 @@ class BiArchTool(ToolBase.ToolBase):
'cmd' : 'wipe', 'cmd' : 'wipe',
'arch': self.arch, 'arch': self.arch,
'package' : pkg })) 'package' : pkg }))
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
logger.error('failed to update %s: %s', pkg, e) logger.error('failed to update %s: %s', pkg, e)
class CommandLineInterface(ToolBase.CommandLineInterface): class CommandLineInterface(ToolBase.CommandLineInterface):

View File

@ -139,7 +139,7 @@ class CheckSource(ReviewBot.ReviewBot):
def staging_group(self, project): def staging_group(self, project):
try: try:
return self.staging_api(project).cstaging_group return self.staging_api(project).cstaging_group
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code != 404: if e.code != 404:
raise e raise e
@ -176,7 +176,7 @@ class CheckSource(ReviewBot.ReviewBot):
try: try:
xml = ET.parse(osc.core.http_GET(url)).getroot() xml = ET.parse(osc.core.http_GET(url)).getroot()
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
self.logger.error('ERROR in URL %s [%s]' % (url, e)) self.logger.error('ERROR in URL %s [%s]' % (url, e))
return ret return ret

View File

@ -123,7 +123,7 @@ class FactorySourceChecker(ReviewBot.ReviewBot):
u = osc.core.makeurl(self.apiurl, [ 'source', project, package, '_history' ], { 'limit': self.history_limit }) u = osc.core.makeurl(self.apiurl, [ 'source', project, package, '_history' ], { 'limit': self.history_limit })
try: try:
r = osc.core.http_GET(u) r = osc.core.http_GET(u)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
self.logger.debug("package has no history!?") self.logger.debug("package has no history!?")
return None return None

View File

@ -199,7 +199,7 @@ def remind_comment(apiurl, repeat_age, request_id, project, package=None):
# Repeat notification so remove old comment. # Repeat notification so remove old comment.
try: try:
comment_api.delete(comment['id']) comment_api.delete(comment['id'])
except HTTPError, e: except HTTPError as e:
if e.code == 403: if e.code == 403:
# Gracefully skip when previous reminder was by another user. # Gracefully skip when previous reminder was by another user.
print(' unable to remove previous reminder') print(' unable to remove previous reminder')

View File

@ -128,7 +128,7 @@ class FccFreezer(object):
l = ET.tostring(flink) l = ET.tostring(flink)
try: try:
http_PUT(url, data=l) http_PUT(url, data=l)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
raise e raise e
class FccSubmitter(object): class FccSubmitter(object):
@ -225,7 +225,7 @@ class FccSubmitter(object):
def check_multiple_specfiles(self, project, package): def check_multiple_specfiles(self, project, package):
try: try:
url = makeurl(self.apiurl, ['source', project, package], { 'expand': '1' } ) url = makeurl(self.apiurl, ['source', project, package], { 'expand': '1' } )
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code == 404: if e.code == 404:
return None return None
raise e raise e

View File

@ -79,7 +79,7 @@ def bug_owner(apiurl, package, entity='person'):
def bug_meta_get(bugzilla_api, bug_id): def bug_meta_get(bugzilla_api, bug_id):
try: try:
bug = bugzilla_api.getbug(bug_id) bug = bugzilla_api.getbug(bug_id)
except Fault, e: except Fault as e:
print('bug_meta_get(): ' + str(e)) print('bug_meta_get(): ' + str(e))
return None return None
return bug.component return bug.component
@ -382,7 +382,7 @@ def main(args):
try: try:
bug_id = bug_create(bugzilla_api, meta, owner, cc, summary, message) bug_id = bug_create(bugzilla_api, meta, owner, cc, summary, message)
break break
except Fault, e: except Fault as e:
if 'There is no component named' in e.faultString: if 'There is no component named' in e.faultString:
print('Invalid component {}, fallback to default'.format(meta[1])) print('Invalid component {}, fallback to default'.format(meta[1]))
meta = (meta[0], bugzilla_defaults[1], meta[2]) meta = (meta[0], bugzilla_defaults[1], meta[2])

View File

@ -93,7 +93,7 @@ class Leaper(ReviewBot.ReviewBot):
root = ET.parse(osc.core.http_GET(osc.core.makeurl(self.apiurl,['source', project], root = ET.parse(osc.core.http_GET(osc.core.makeurl(self.apiurl,['source', project],
query=query))).getroot() query=query))).getroot()
packages = [i.get('name') for i in root.findall('entry')] packages = [i.get('name') for i in root.findall('entry')]
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
# in case the project doesn't exist yet (like sle update) # in case the project doesn't exist yet (like sle update)
if e.code != 404: if e.code != 404:
raise e raise e

View File

@ -87,7 +87,7 @@ class Manager42(object):
self.lookup = {} self.lookup = {}
try: try:
self.lookup = yaml.safe_load(self._load_lookup_file(project)) self.lookup = yaml.safe_load(self._load_lookup_file(project))
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code != 404: if e.code != 404:
raise raise
@ -119,7 +119,7 @@ class Manager42(object):
def retried_GET(self, url): def retried_GET(self, url):
try: try:
return http_GET(url) return http_GET(url)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if 500 <= e.code <= 599: if 500 <= e.code <= 599:
logger.warn('Retrying {}'.format(url)) logger.warn('Retrying {}'.format(url))
time.sleep(1) time.sleep(1)
@ -136,7 +136,7 @@ class Manager42(object):
query=query))) query=query)))
packages = [i.get('name') for i in root.findall('entry')] packages = [i.get('name') for i in root.findall('entry')]
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code == 404: if e.code == 404:
logger.error("{}: {}".format(project, e)) logger.error("{}: {}".format(project, e))
packages = [] packages = []
@ -161,7 +161,7 @@ class Manager42(object):
for package in sorted(packages): for package in sorted(packages):
try: try:
self.check_one_package(package) self.check_one_package(package)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
logger.error("Failed to check {}: {}".format(package, e)) logger.error("Failed to check {}: {}".format(package, e))
pass pass
@ -179,7 +179,7 @@ class Manager42(object):
query['deleted'] = 1 query['deleted'] = 1
return self.cached_GET(makeurl(self.apiurl, return self.cached_GET(makeurl(self.apiurl,
['source', project, package, '_history'], query)) ['source', project, package, '_history'], query))
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code == 404: if e.code == 404:
return None return None
raise raise

View File

@ -177,7 +177,7 @@ class AcceptCommand(object):
url = self.api.makeurl(['build', project], query) url = self.api.makeurl(['build', project], query)
try: try:
http_POST(url) http_POST(url)
except urllib2.HTTPError, err: except urllib2.HTTPError as err:
# failed to wipe isos but we can just continue # failed to wipe isos but we can just continue
pass pass
@ -229,7 +229,7 @@ class AcceptCommand(object):
print "Deleting package %s from project %s" % (spec[:-5], project) print "Deleting package %s from project %s" % (spec[:-5], project)
try: try:
http_DELETE(url) http_DELETE(url)
except urllib2.HTTPError, err: except urllib2.HTTPError as err:
if err.code == 404: if err.code == 404:
# the package link was not yet created, which was likely a mistake from earlier # the package link was not yet created, which was likely a mistake from earlier
pass pass

View File

@ -54,8 +54,8 @@ class AdiCommand:
self.api.accept_status_comment(project, packages) self.api.accept_status_comment(project, packages)
try: try:
delete_project(self.api.apiurl, project, force=True) delete_project(self.api.apiurl, project, force=True)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
print e print(e)
pass pass
else: else:
print query_project, Fore.GREEN + 'ready:', ', '.join(['{}[{}]'.format( print query_project, Fore.GREEN + 'ready:', ', '.join(['{}[{}]'.format(

View File

@ -157,7 +157,7 @@ class CycleDetector(object):
# print('Generating _builddepinfo for (%s, %s, %s)' % (project, repository, arch)) # print('Generating _builddepinfo for (%s, %s, %s)' % (project, repository, arch))
url = makeurl(self.api.apiurl, ['build/%s/%s/%s/_builddepinfo' % (project, repository, arch)]) url = makeurl(self.api.apiurl, ['build/%s/%s/%s/_builddepinfo' % (project, repository, arch)])
root = http_GET(url).read() root = http_GET(url).read()
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
print('ERROR in URL %s [%s]' % (url, e)) print('ERROR in URL %s [%s]' % (url, e))
return root return root

View File

@ -44,7 +44,7 @@ class PrioCommand(object):
try: try:
osc.core.http_POST(url, data=message) osc.core.http_POST(url, data=message)
print reqid, r['by'], priority print reqid, r['by'], priority
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
print e print e

View File

@ -37,7 +37,7 @@ class RepairCommand(object):
staging_project = reviews[0] staging_project = reviews[0]
try: try:
data = self.api.get_prj_pseudometa(staging_project) data = self.api.get_prj_pseudometa(staging_project)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code == 404: if e.code == 404:
data = None data = None

View File

@ -152,7 +152,7 @@ class StagingAPI(object):
if data is not None: if data is not None:
return func(url, data=data) return func(url, data=data)
return func(url) return func(url)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if 500 <= e.code <= 599: if 500 <= e.code <= 599:
print 'Error {}, retrying {} in {}s'.format(e.code, url, retry_sleep_seconds) print 'Error {}, retrying {} in {}s'.format(e.code, url, retry_sleep_seconds)
time.sleep(retry_sleep_seconds) time.sleep(retry_sleep_seconds)
@ -290,7 +290,7 @@ class StagingAPI(object):
content = http_GET(url) content = http_GET(url)
for entry in ET.parse(content).getroot().findall('entry'): for entry in ET.parse(content).getroot().findall('entry'):
filelist.append(entry.attrib['name']) filelist.append(entry.attrib['name'])
except urllib2.HTTPError, err: except urllib2.HTTPError as err:
if err.code == 404: if err.code == 404:
# The package we were supposed to query does not exist # The package we were supposed to query does not exist
# we can pass this up and return the empty filelist # we can pass this up and return the empty filelist
@ -394,7 +394,7 @@ class StagingAPI(object):
try: try:
url = self.makeurl(['source', prj, '_project', '_frozenlinks'], {'meta': '1'}) url = self.makeurl(['source', prj, '_project', '_frozenlinks'], {'meta': '1'})
root = ET.parse(http_GET(url)).getroot() root = ET.parse(http_GET(url)).getroot()
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code == 404: if e.code == 404:
return None return None
packages = root.findall('./frozenlink/package') packages = root.findall('./frozenlink/package')
@ -1468,7 +1468,7 @@ class StagingAPI(object):
url = self.makeurl(['build', project, repository, arch, '_repository', "%s?view=fileinfo" % rpm]) url = self.makeurl(['build', project, repository, arch, '_repository', "%s?view=fileinfo" % rpm])
try: try:
return ET.parse(http_GET(url)).getroot().find('version').text return ET.parse(http_GET(url)).getroot().find('version').text
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code == 404: if e.code == 404:
return None return None
raise raise
@ -1764,7 +1764,7 @@ class StagingAPI(object):
node = ET.fromstring(''.join(m)).find('devel') node = ET.fromstring(''.join(m)).find('devel')
if node is not None: if node is not None:
return node.get('project') return node.get('project')
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code == 404: if e.code == 404:
pass pass
return None return None

View File

@ -100,7 +100,7 @@ class StagingHelper(object):
url = makeurl(self.apiurl, ['source', project, pkg], query=query) url = makeurl(self.apiurl, ['source', project, pkg], query=query)
try: try:
root = ET.parse(http_GET(url)).getroot() root = ET.parse(http_GET(url)).getroot()
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if e.code == 404: if e.code == 404:
continue continue
raise raise

View File

@ -457,7 +457,7 @@ class ToTestBase(object):
def totest(self): def totest(self):
try: try:
current_snapshot = self.get_current_snapshot() current_snapshot = self.get_current_snapshot()
except NotFoundException, e: except NotFoundException as e:
# nothing in :ToTest (yet) # nothing in :ToTest (yet)
logger.warn(e) logger.warn(e)
current_snapshot = None current_snapshot = None
@ -769,7 +769,7 @@ class CommandlineInterface(cmdln.Cmdln):
try: try:
totest = self._setup_totest(project) totest = self._setup_totest(project)
totest.totest() totest.totest()
except Exception, e: except Exception as e:
logger.error(e) logger.error(e)
if opts.interval: if opts.interval:

View File

@ -99,7 +99,7 @@ class UpdateCrawler(object):
def retried_GET(self, url): def retried_GET(self, url):
try: try:
return http_GET(url) return http_GET(url)
except urllib2.HTTPError, e: except urllib2.HTTPError as e:
if 500 <= e.code <= 599: if 500 <= e.code <= 599:
print 'Retrying {}'.format(url) print 'Retrying {}'.format(url)
time.sleep(1) time.sleep(1)
@ -211,7 +211,7 @@ class UpdateCrawler(object):
))) )))
if root.get('project') is None and root.get('cicount'): if root.get('project') is None and root.get('cicount'):
return True return True
except urllib2.HTTPError, err: except urllib2.HTTPError as err:
# if there is no link, it can't be a link # if there is no link, it can't be a link
if err.code == 404: if err.code == 404:
return False return False