]> code.ossystems Code Review - openembedded-core.git/commitdiff
report-error: Catch un-readable log data
authorMichael Wood <michael.g.wood@intel.com>
Tue, 3 Feb 2015 14:20:12 +0000 (14:20 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 3 Feb 2015 14:29:56 +0000 (14:29 +0000)
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@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes/report-error.bbclass

index 8b30422edfa7e06e1744e98b57b1a94f1f32993c..5f155e332b2db400e64add1fbfa9f21891c6dd3e 100644 (file)
@@ -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))