[elbe-devel] [PATCH v3] handle licence generation exceptions

Torben Hohn torben.hohn at linutronix.de
Mon Dec 18 17:07:44 CET 2017


On Mon, Dec 18, 2017 at 04:19:55PM +0100, Manuel Traut wrote:
> The code might raise execptions, see comments inline.
> As long as the code is not reworked:
> 
> https://github.com/Linutronix/elbe/issues/133
> 
> a strict handling needs to be introduced to enable image builds even if
> licence generation throws some errors.
> 
> Signed-off-by: Manuel Traut <manut at linutronix.de>
> ---
>  elbepack/elbeproject.py | 19 +++++++++++++++----
>  1 file changed, 15 insertions(+), 4 deletions(-)
> 
> diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
> index 2232b4c1..6d2b23fe 100644
> --- a/elbepack/elbeproject.py
> +++ b/elbepack/elbeproject.py
> @@ -297,10 +297,21 @@ class ElbeProject (object):
>          elbe_report( self.xml, self.buildenv, self.get_rpcaptcache(),
>                  reportpath, self.targetfs )
>  
> -        # Licenses
> -        f = io.open( os.path.join( self.builddir, "licence.txt" ), "w+", encoding='utf-8' )
> -        self.buildenv.rfs.write_licenses(f, self.log, os.path.join( self.builddir, "licence.xml"))
> -        f.close()
> +        # the current license code raises an exception that interrupts the hole
> +        # build if a licence can't be converted to utf-8. Exception handling can
> +        # be removed as soon as the licence code is more stable
> +        try:
> +            f = io.open( os.path.join( self.builddir, "licence.txt" ), "w+", encoding='utf-8' )
> +            self.buildenv.rfs.write_licenses(f, self.log, os.path.join( self.builddir, "licence.xml"))
> +        except Exception as e:
> +            self.log.printo( "error during generating licence.txt/xml" )
> +            self.log.printo( sys.exc_info()[0] )
> +            lic_err = True

you only set lic_err here.
where is lic_err = False before  the try block ?

> +        finally:
> +            f.close()
> +        if lic_err:
              ^^^^^^^^^^^^
this will throw a NameError, when no exception occured above.

> +            os.remove (os.path.join( self.builddir, "licence.txt" ))
> +            os.remove (os.path.join( self.builddir, "licence.xml" ))
>  
>          # Use some handwaving to determine grub version
>          # jessie and wheezy grubs are 2.0 but differ in behaviour
> -- 
> 2.15.1
> 
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Mit freundlichen Grüßen
Torben Hohn

Linutronix GmbH

Standort: Bremen

Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Firmensitz / Registered Office: D-88690 Uhldingen, Bahnhofstr. 3
Registergericht / Local District Court: Amtsgericht Freiburg i. Br.; HRB
Nr. / Trade register no.: 700 806

Geschäftsführer / Managing Directors: Heinz Egger, Thomas Gleixner

Eine Bitte von uns: Sollten Sie diese E-Mail irrtümlich erhalten haben,
benachrichtigen Sie uns in diesem Falle bitte sobald wie es Ihnen
möglich ist, durch Antwort-Mail. Vielen Dank!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: Digital signature
URL: <http://lists.linutronix.de/pipermail/elbe-devel/attachments/20171218/96143b52/attachment.sig>


More information about the elbe-devel mailing list