Stop using .message attribute on exceptions

It does not exist on Python 3. Converting the exception to string works
identically.

The validate methods on many phases are simplified by not calling the
parent (which does not do anything).

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2018-05-14 09:28:58 +02:00
parent b2190c1c3f
commit 4544b454f8
6 changed files with 3 additions and 19 deletions

View File

@ -333,7 +333,7 @@ class Compose(kobo.log.LoggingBase):
try:
return (format % args).format(**args)
except KeyError as err:
raise RuntimeError('Failed to create image name: unknown format element: %s' % err.message)
raise RuntimeError('Failed to create image name: unknown format element: %s' % err)
def can_fail(self, variant, arch, deliverable):
"""Figure out if deliverable can fail on variant.arch.

View File

@ -54,10 +54,6 @@ class CreaterepoPhase(PhaseBase):
def validate(self):
errors = []
try:
super(CreaterepoPhase, self).validate()
except ValueError as exc:
errors = exc.message.split('\n')
if not self.compose.old_composes and self.compose.conf.get('createrepo_deltas'):
errors.append('Can not generate deltas without old compose')

View File

@ -69,10 +69,6 @@ class GatherPhase(PhaseBase):
def validate(self):
errors = []
try:
super(GatherPhase, self).validate()
except ValueError as exc:
errors = exc.message.split('\n')
if not Modulemd:
# Modules are not supported, check if we need them
@ -306,7 +302,7 @@ def _prepare_variant_as_lookaside(compose):
try:
graph.add_edge(variant, lookaside_variant)
except ValueError as e:
raise ValueError("There is a bad configuration in 'variant_as_lookaside': %s" % e.message)
raise ValueError("There is a bad configuration in 'variant_as_lookaside': %s" % e)
variant_processing_order = reversed(graph.prune_graph())
return list(variant_processing_order)

View File

@ -35,10 +35,6 @@ class ImageChecksumPhase(PhaseBase):
def validate(self):
errors = []
try:
super(ImageChecksumPhase, self).validate()
except ValueError as exc:
errors = exc.message.split('\n')
if self.one_file and len(self.checksums) != 1:
errors.append(MULTIPLE_CHECKSUMS_ERROR)

View File

@ -23,10 +23,6 @@ class OstreeInstallerPhase(PhaseLoggerMixin, ConfigGuardedPhase):
def validate(self):
errors = []
try:
super(OstreeInstallerPhase, self).validate()
except ValueError as exc:
errors = exc.message.split('\n')
if not self.compose.conf['ostree_installer_overwrite'] and not self.bi._skipped:
for variant in self.compose.get_variants():

View File

@ -375,7 +375,7 @@ def get_volid(compose, arch, variant=None, escape_spaces=False, disc_type=False)
base_product_version=base_product_version)
volid = (i % args).format(**args)
except KeyError as err:
raise RuntimeError('Failed to create volume id: unknown format element: %s' % err.message)
raise RuntimeError('Failed to create volume id: unknown format element: %s' % err)
volid = _apply_substitutions(compose, volid)
if len(volid) <= 32:
break