report-error: Catch un-readable log data

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.

(From OE-Core rev: 787ffc5e12f1639aa5e0917bb23deced53a0478e)

Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Michael Wood 2015-02-03 14:20:12 +00:00 committed by Richard Purdie
parent 013f7e286d
commit bd84192866
1 changed files with 7 additions and 3 deletions

View 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))