PR#843: make py2 files parseable with py3

Merges #843
https://pagure.io/koji/pull-request/843
This commit is contained in:
Mike McLean 2018-05-03 15:57:00 -04:00
commit e4412e4d57
2 changed files with 15 additions and 15 deletions

View file

@ -1453,7 +1453,7 @@ class BuildMavenTask(BaseBuildTask):
st = os.lstat(filepath)
mtime = time.localtime(st.st_mtime)
info = zipfile.ZipInfo(filepath[roottrim:])
info.external_attr |= 0120000 << 16L # symlink file type
info.external_attr |= 0o120000 << 16 # symlink file type
info.compress_type = zipfile.ZIP_STORED
info.date_time = mtime[:6]
zfo.writestr(info, content)
@ -2100,7 +2100,7 @@ class ChainMavenTask(MultiPlatformTask):
del todo[package]
try:
results = self.wait(running.keys())
except (xmlrpclib.Fault, koji.GenericError), e:
except (xmlrpclib.Fault, koji.GenericError) as e:
# One task has failed, wait for the rest to complete before the
# chainmaven task fails. self.wait(all=True) should thrown an exception.
self.wait(all=True)
@ -2237,7 +2237,7 @@ class TagBuildTask(BaseTaskHandler):
#XXX - add more post tests
self.session.host.tagBuild(self.id,tag_id,build_id,force=force,fromtag=fromtag)
self.session.host.tagNotification(True, tag_id, fromtag, build_id, user_id, ignore_success)
except Exception, e:
except Exception as e:
exctype, value = sys.exc_info()[:2]
self.session.host.tagNotification(False, tag_id, fromtag, build_id, user_id, ignore_success, "%s: %s" % (exctype, value))
raise e
@ -2807,10 +2807,10 @@ class ImageTask(BaseTaskHandler):
self.ks = ksparser.KickstartParser(version)
try:
self.ks.readKickstart(kspath)
except IOError, e:
except IOError as e:
raise koji.LiveCDError("Failed to read kickstart file "
"'%s' : %s" % (kspath, e))
except kserrors.KickstartError, e:
except kserrors.KickstartError as e:
raise koji.LiveCDError("Failed to parse kickstart file "
"'%s' : %s" % (kspath, e))
@ -3472,10 +3472,10 @@ class OzImageTask(BaseTaskHandler):
self.logger.debug('attempting to read kickstart: %s' % kspath)
try:
ks.readKickstart(kspath)
except IOError, e:
except IOError as e:
raise koji.BuildError("Failed to read kickstart file "
"'%s' : %s" % (kspath, e))
except kserrors.KickstartError, e:
except kserrors.KickstartError as e:
raise koji.BuildError("Failed to parse kickstart file "
"'%s' : %s" % (kspath, e))
return ks
@ -4416,7 +4416,7 @@ class BuildIndirectionImageTask(OzImageTask):
base_factory_image = _nvr_to_image(opts['base_image_build'], opts['arch'])
else:
base_factory_image = _task_to_image(int(opts['base_image_task']))
except Exception, e:
except Exception as e:
self.logger.exception(e)
raise
@ -4478,7 +4478,7 @@ class BuildIndirectionImageTask(OzImageTask):
image_id=base_factory_image.identifier,
parameters=params)
target.target_thread.join()
except Exception, e:
except Exception as e:
self.logger.debug("Exception encountered during target build")
self.logger.exception(e)
finally:
@ -5833,7 +5833,7 @@ if __name__ == "__main__":
# authenticate using SSL client certificates
session.ssl_login(options.cert, None,
options.serverca)
except koji.AuthError, e:
except koji.AuthError as e:
quit("Error: Unable to log in: %s" % e)
except xmlrpclib.ProtocolError:
quit("Error: Unable to connect to server %s" % (options.server))
@ -5853,9 +5853,9 @@ if __name__ == "__main__":
session.krb_login(principal=krb_principal,
keytab=options.keytab,
ccache=options.ccache)
except krbV.Krb5Error, e:
except krbV.Krb5Error as e:
quit("Kerberos authentication failed: '%s' (%s)" % (e.args[1], e.args[0]))
except socket.error, e:
except socket.error as e:
quit("Could not connect to Kerberos authentication service: '%s'" % e.args[1])
else:
quit("No username/password supplied and Kerberos missing or not configured")

View file

@ -122,18 +122,18 @@ def parse_task_params(method, params):
args, kwargs = koji.decode_args(*params)
if method not in LEGACY_SIGNATURES:
raise TypeError, "No legacy signature for %s" % method
raise TypeError("No legacy signature for %s" % method)
err = None
for argspec in LEGACY_SIGNATURES[method]:
try:
params = koji.util.apply_argspec(argspec, args, kwargs)
break
except koji.ParameterError, e:
except koji.ParameterError as e:
if not err:
err = e.message
else:
raise koji.ParameterError, "Invalid signature for %s: %s" % (method, err)
raise koji.ParameterError("Invalid signature for %s: %s" % (method, err))
return params