[elbe-devel] [PATCH 1/8] elbeproject: cleanup licence file collection code
Torben Hohn
torben.hohn at linutronix.de
Mon Oct 14 16:57:27 CEST 2019
previous problems with incorrect encodings in /usr/share/doc/*/copyright
files lead to catching all Exceptions in the licence code.
Using the flag errors="replace" everywhere fixes these, and the catching
can now be removed.
Clean the code up.
Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
elbepack/elbeproject.py | 30 +++++++++---------------------
1 file changed, 9 insertions(+), 21 deletions(-)
diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
index 0c2bbb339..8be6c1dbc 100644
--- a/elbepack/elbeproject.py
+++ b/elbepack/elbeproject.py
@@ -571,27 +571,15 @@ class ElbeProject (object):
elbe_report(self.xml, self.buildenv, self.get_rpcaptcache(),
self.targetfs)
- # 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,
- os.path.join(self.builddir, "licence.xml"))
- except Exception:
- logging.exception("Error during generating licence.txt/xml")
- 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"))
+ # Collect Licence Files
+ lic_txt_fname = os.path.join(self.builddir, "licence.txt")
+ lic_xml_fname = os.path.join(self.builddir, "licence.xml")
+
+ with io.open(lic_txt_fname,
+ 'w+',
+ encoding='utf-8',
+ errors='replace') as f:
+ self.buildenv.rfs.write_licenses(f, lic_xml_fname)
# Use some handwaving to determine grub version
#
--
2.20.1
More information about the elbe-devel
mailing list