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

Torben Hohn torben.hohn at linutronix.de
Tue Dec 19 14:08:33 CET 2017


On Mon, Dec 18, 2017 at 05:21:46PM +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>

Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>

> ---
>  elbepack/elbeproject.py | 20 ++++++++++++++++----
>  1 file changed, 16 insertions(+), 4 deletions(-)
> 
> diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
> index 2232b4c1..fc4bc412 100644
> --- a/elbepack/elbeproject.py
> +++ b/elbepack/elbeproject.py
> @@ -297,10 +297,22 @@ 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
> +        lic_err = False
> +        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
> +        finally:
> +            f.close()
> +        if lic_err:
> +            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/20171219/d2dbae1c/attachment.sig>


More information about the elbe-devel mailing list