report-error: Handle the case no logfile exists

If the task fails early, no error log may exist. Currently we crash in
that case, this handles the situation more gracefully.

(From OE-Core rev: 1e6bfcab47f532677f87683ba2f5e5fb905e9ba5)

(From OE-Core rev: 8e52fea95441f88ab366c3c32b869cb30cc386b7)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2014-12-20 11:20:33 +00:00
parent 7461790c39
commit 9ffc238025

View File

@@ -44,11 +44,14 @@ python errorreport_handler () {
task = e.task
taskdata={}
log = e.data.getVar('BB_LOGFILE', True)
logFile = open(log, 'r')
taskdata['package'] = e.data.expand("${PF}")
taskdata['task'] = task
taskdata['log'] = logFile.read()
logFile.close()
if log:
logFile = open(log, 'r')
taskdata['log'] = logFile.read()
logFile.close()
else:
taskdata['log'] = "No Log"
jsondata = json.loads(errorreport_getdata(e))
jsondata['failures'].append(taskdata)
errorreport_savedata(e, jsondata, "error-report.txt")