[elbe-devel] [PATCH 1/1] Change exception.message to str()

Torben Hohn torben.hohn at linutronix.de
Fri Feb 7 09:47:10 CET 2020


On Wed, Feb 05, 2020 at 01:10:53AM +0100, Bastian Germann wrote:
> Am 03.02.20 um 02:24 schrieb Olivier Dion:
> > The 'message' attribute of an exception that inherit from
> > BaseException is not valid in Py3.  Thus, using the '__str__' method
> > of the exception instead to get the error message.
> > 
> > See the following traceback:
> > 
> > ----------------------------------------------------------------------
> > Traceback (most recent call last):
> > 
> > File "/home/olivier/linutronix/elbe/elbepack/debinstaller.py", \
> > line 237, in copy_kinitrd
> > download_kinitrd(tmp, suite, mirror)
> > File "/home/olivier/linutronix/elbe/elbepack/debinstaller.py", \
> > line 175, in download_kinitrd
> > download_release(tmp, base_url)
> > File "/home/olivier/linutronix/elbe/elbepack/debinstaller.py", \
> > line 160, in download_release
> > raise InvalidSignature('Failed to verify Release file')
> > elbepack.debinstaller.InvalidSignature: Failed to verify Release file
> > 
> > During handling of the above exception, another exception occurred:
> > 
> > Traceback (most recent call last):
> > File "/home/olivier/linutronix/elbe/elbe", line 55, in <module>
> > cmdmod.run_command(sys.argv[2:])
> > File "/home/olivier/linutronix/elbe/elbepack/commands/init.py", \
> > line 198, in run_command
> > copy_kinitrd(xml.node("/initvm"), out_path)
> > File "/home/olivier/linutronix/elbe/elbepack/debinstaller.py", \
> > line 251, in copy_kinitrd
> > raise NoKinitrdException('InvalidSignature %s' % e.message)
> > AttributeError: 'InvalidSignature' object has no attribute 'message'
> > ----------------------------------------------------------------------
> > 
> > Signed-off-by: Olivier Dion <dion at linutronix.de>
> 
> Reviewed-by: Bastian Germann <bage at linutronix.de>

merged to master, Thanks

> 
> > ---
> >  elbepack/commands/init.py |  5 +++--
> >  elbepack/debinstaller.py  |  6 +++---
> >  elbepack/egpg.py          | 10 +++++-----
> >  elbepack/soapclient.py    |  4 ++--
> >  4 files changed, 13 insertions(+), 12 deletions(-)
> > 
> > diff --git a/elbepack/commands/init.py b/elbepack/commands/init.py
> > index 724babf19..a97d45dfb 100644
> > --- a/elbepack/commands/init.py
> > +++ b/elbepack/commands/init.py
> > @@ -197,12 +197,13 @@ def run_command(argv):
> >          try:
> >              copy_kinitrd(xml.node("/initvm"), out_path)
> >          except NoKinitrdException as e:
> > +            msg = str(e)
> >              logging.error("Failure to download kernel/initrd debian Package:")
> >              logging.error("")
> > -            logging.error(e.message)
> > +            logging.error(msg)
> >              logging.error("")
> >              logging.error("Check Mirror configuration")
> > -            if 'SHA256SUMS' in e.message:
> > +            if 'SHA256SUMS' in msg:
> >                  logging.error("If you use debmirror please read "
> >                                "https://github.com/Linutronix/elbe/issues/188 "
> >                                "on how to work around the issue")
> > diff --git a/elbepack/debinstaller.py b/elbepack/debinstaller.py
> > index ffe4b5421..dd882d677 100644
> > --- a/elbepack/debinstaller.py
> > +++ b/elbepack/debinstaller.py
> > @@ -246,8 +246,8 @@ def copy_kinitrd(prj, target_dir):
> >                   os.path.join(target_dir, "vmlinuz"))
> >  
> >      except IOError as e:
> > -        raise NoKinitrdException('IoError %s' % e.message)
> > +        raise NoKinitrdException('IoError %s' % str(e))
> >      except InvalidSignature as e:
> > -        raise NoKinitrdException('InvalidSignature %s' % e.message)
> > +        raise NoKinitrdException('InvalidSignature %s' % str(e))
> >      except HashValidationFailed as e:
> > -        raise NoKinitrdException('HashValidationFailed %s' % e.message)
> > +        raise NoKinitrdException('HashValidationFailed %s' % str(e))
> > diff --git a/elbepack/egpg.py b/elbepack/egpg.py
> > index 55a624e99..7cfc881f7 100644
> > --- a/elbepack/egpg.py
> > +++ b/elbepack/egpg.py
> > @@ -167,9 +167,9 @@ def unsign_file(fname):
> >          return outfilename
> >  
> >      except IOError as ex:
> > -        print(ex.message)
> > +        print(str(ex))
> >      except Exception as ex:
> > -        print("Error checking the file %s: %s" % (fname, ex.message))
> > +        print("Error checking the file %s: %s" % (fname, str(ex)))
> >  
> >      return None
> >  
> > @@ -195,7 +195,7 @@ def sign(infile, outfile, fingerprint):
> >      try:
> >          key = ctx.get_key(fingerprint, 0)
> >      except Exception as ex:
> > -        print("no key with fingerprint %s: %s" % (fingerprint, ex.message))
> > +        print("no key with fingerprint %s: %s" % (fingerprint, str(ex)))
> >  
> >      unlock_key(key.fpr)
> >      ctx.signers_add(key)
> > @@ -210,7 +210,7 @@ def sign(infile, outfile, fingerprint):
> >          with open(outfile, 'w') as fd:
> >              fd.write(signature)
> >      except Exception as ex:
> > -        print("Error signing file %s" % ex.message)
> > +        print("Error signing file %s" % str(ex))
> >  
> >  
> >  def sign_file(fname, fingerprint):
> > @@ -219,7 +219,7 @@ def sign_file(fname, fingerprint):
> >      try:
> >          sign(fname, outfilename, fingerprint)
> >      except Exception as ex:
> > -        print("Error signing file %s" % ex.message)
> > +        print("Error signing file %s" % str(ex))
> >  
> >  
> >  def get_fingerprints():
> > diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
> > index d5b18c2ca..017e015af 100644
> > --- a/elbepack/soapclient.py
> > +++ b/elbepack/soapclient.py
> > @@ -103,7 +103,7 @@ class ElbeSoapClient(object):
> >  
> >                  print("get_file part %d failed, retry %d times" % (part, retry),
> >                        file=sys.stderr)
> > -                print(e.message, file=sys.stderr)
> > +                print(str(e), file=sys.stderr)
> >                  print(repr(e.line), file=sys.stderr)
> >  
> >                  if not retry:
> > @@ -596,7 +596,7 @@ class WaitProjectBusyAction(ClientAction):
> >              # code should be reworked as soon as it's clear what is going on
> >              # here
> >              except socket.error as e:
> > -                print(e.message, file=sys.stderr)
> > +                print(str(e), file=sys.stderr)
> >                  print("socket error during wait busy occured, retry..",
> >                        file=sys.stderr)
> >                  continue
> > 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner



More information about the elbe-devel mailing list