[OE-core] [PATCH v2] report-error: Catch un-readable log data
Michael Wood
michael.g.wood at intel.com
Tue Feb 3 14:20:12 UTC 2015
If a log data cannot be decoded to utf-8 or read then handle this
gracefully. This can happen if a log file contains binary or something
goes wrong with the file open process.
Signed-off-by: Michael Wood <michael.g.wood at intel.com>
---
meta/classes/report-error.bbclass | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/meta/classes/report-error.bbclass b/meta/classes/report-error.bbclass
index 8b30422..5f155e3 100644
--- a/meta/classes/report-error.bbclass
+++ b/meta/classes/report-error.bbclass
@@ -47,9 +47,13 @@ python errorreport_handler () {
taskdata['package'] = e.data.expand("${PF}")
taskdata['task'] = task
if log:
- logFile = open(log, 'r')
- taskdata['log'] = logFile.read()
- logFile.close()
+ try:
+ logFile = open(log, 'r')
+ taskdata['log'] = logFile.read().decode('utf-8')
+ logFile.close()
+ except:
+ taskdata['log'] = "Unable to read log file"
+
else:
taskdata['log'] = "No Log"
jsondata = json.loads(errorreport_getdata(e))
--
2.1.0
More information about the Openembedded-core
mailing list