Use Py3-compatible exception handling
In once case we can completely drop try-except statements: it only logs the exception details but that will be logged again anyway. Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
ec39514fba
commit
439a7ce348
@ -238,11 +238,7 @@ def main():
|
|||||||
notifier=notifier)
|
notifier=notifier)
|
||||||
notifier.compose = compose
|
notifier.compose = compose
|
||||||
COMPOSE = compose
|
COMPOSE = compose
|
||||||
try:
|
|
||||||
run_compose(compose, create_latest_link=create_latest_link, latest_link_status=latest_link_status)
|
run_compose(compose, create_latest_link=create_latest_link, latest_link_status=latest_link_status)
|
||||||
except Exception, ex:
|
|
||||||
compose.log_error("Compose run failed: %s" % ex)
|
|
||||||
raise
|
|
||||||
|
|
||||||
|
|
||||||
def run_compose(compose, create_latest_link=True, latest_link_status=None):
|
def run_compose(compose, create_latest_link=True, latest_link_status=None):
|
||||||
@ -455,7 +451,7 @@ if __name__ == "__main__":
|
|||||||
except (Exception, KeyboardInterrupt) as ex:
|
except (Exception, KeyboardInterrupt) as ex:
|
||||||
if COMPOSE:
|
if COMPOSE:
|
||||||
tb_path = COMPOSE.paths.log.log_file("global", "traceback")
|
tb_path = COMPOSE.paths.log.log_file("global", "traceback")
|
||||||
COMPOSE.log_error("Exception: %s" % ex)
|
COMPOSE.log_error("Compose run failed: %s" % ex)
|
||||||
COMPOSE.log_error("Extended traceback in: %s" % tb_path)
|
COMPOSE.log_error("Extended traceback in: %s" % tb_path)
|
||||||
COMPOSE.log_critical("Compose failed: %s" % COMPOSE.topdir)
|
COMPOSE.log_critical("Compose failed: %s" % COMPOSE.topdir)
|
||||||
COMPOSE.write_status("DOOMED")
|
COMPOSE.write_status("DOOMED")
|
||||||
|
@ -663,7 +663,7 @@ class Pungi(PungiBase):
|
|||||||
self.add_package(dep, msg)
|
self.add_package(dep, msg)
|
||||||
added.add(dep)
|
added.add(dep)
|
||||||
|
|
||||||
except (yum.Errors.InstallError, yum.Errors.YumBaseError), ex:
|
except (yum.Errors.InstallError, yum.Errors.YumBaseError) as ex:
|
||||||
self.logger.warn("Unresolvable dependency %s in %s.%s (repo: %s)" % (r, po.name, po.arch, po.repoid))
|
self.logger.warn("Unresolvable dependency %s in %s.%s (repo: %s)" % (r, po.name, po.arch, po.repoid))
|
||||||
continue
|
continue
|
||||||
self.resolved_deps[req] = None
|
self.resolved_deps[req] = None
|
||||||
|
@ -68,7 +68,7 @@ def _link(local, target, logger, force=False):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
os.link(local, target)
|
os.link(local, target)
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
if e.errno != 18: # EXDEV
|
if e.errno != 18: # EXDEV
|
||||||
logger.error('Got an error linking from cache: %s' % e)
|
logger.error('Got an error linking from cache: %s' % e)
|
||||||
raise OSError(e)
|
raise OSError(e)
|
||||||
@ -129,7 +129,7 @@ def _doCheckSum(path, hash, logger):
|
|||||||
# Try to open the file, using binary flag.
|
# Try to open the file, using binary flag.
|
||||||
try:
|
try:
|
||||||
myfile = open(path, 'rb')
|
myfile = open(path, 'rb')
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
logger.error("Could not open file %s: %s" % (path, e))
|
logger.error("Could not open file %s: %s" % (path, e))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user