[elbe-devel] [PATCH v4] handle licence generation exceptions
Manuel Traut
manut at linutronix.de
Mon Dec 18 17:21:46 CET 2017
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 | 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
More information about the elbe-devel
mailing list