diff options
author | Mariano Lopez <mariano.lopez@linux.intel.com> | 2015-10-01 10:40:46 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-10-07 00:11:20 +0100 |
commit | 1f9945266ad8f780f4ba14e66759a218d9f95762 (patch) | |
tree | 0e8e7b782751900c588a628a42c88e17feeb7296 /meta | |
parent | b25af33734b229cb991b1e8a1afccd863cba43bb (diff) | |
download | poky-1f9945266ad8f780f4ba14e66759a218d9f95762.tar.gz |
report-error.bbclass: Support Unicode reports
Currently error-report doesn't manage Unicode because
the files are opened with the default codec.
This patch changes the codec of the files to UTF-8,
this way the reports will include Unicode characters.
This is useful for the qemu output when doing the
testimage task.
[YOCTO #8225]
(From OE-Core rev: afb5308770de776181da5b44f9dc30922836bc38)
Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r-- | meta/classes/report-error.bbclass | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/meta/classes/report-error.bbclass b/meta/classes/report-error.bbclass index 040c29ea24..82b5bcd690 100644 --- a/meta/classes/report-error.bbclass +++ b/meta/classes/report-error.bbclass | |||
@@ -9,22 +9,25 @@ | |||
9 | ERR_REPORT_DIR ?= "${LOG_DIR}/error-report" | 9 | ERR_REPORT_DIR ?= "${LOG_DIR}/error-report" |
10 | 10 | ||
11 | def errorreport_getdata(e): | 11 | def errorreport_getdata(e): |
12 | import codecs | ||
12 | logpath = e.data.getVar('ERR_REPORT_DIR', True) | 13 | logpath = e.data.getVar('ERR_REPORT_DIR', True) |
13 | datafile = os.path.join(logpath, "error-report.txt") | 14 | datafile = os.path.join(logpath, "error-report.txt") |
14 | with open(datafile) as f: | 15 | with codecs.open(datafile, 'r', 'utf-8') as f: |
15 | data = f.read() | 16 | data = f.read() |
16 | return data | 17 | return data |
17 | 18 | ||
18 | def errorreport_savedata(e, newdata, file): | 19 | def errorreport_savedata(e, newdata, file): |
19 | import json | 20 | import json |
21 | import codecs | ||
20 | logpath = e.data.getVar('ERR_REPORT_DIR', True) | 22 | logpath = e.data.getVar('ERR_REPORT_DIR', True) |
21 | datafile = os.path.join(logpath, file) | 23 | datafile = os.path.join(logpath, file) |
22 | with open(datafile, "w") as f: | 24 | with codecs.open(datafile, 'w', 'utf-8') as f: |
23 | json.dump(newdata, f, indent=4, sort_keys=True) | 25 | json.dump(newdata, f, indent=4, sort_keys=True) |
24 | return datafile | 26 | return datafile |
25 | 27 | ||
26 | python errorreport_handler () { | 28 | python errorreport_handler () { |
27 | import json | 29 | import json |
30 | import codecs | ||
28 | 31 | ||
29 | logpath = e.data.getVar('ERR_REPORT_DIR', True) | 32 | logpath = e.data.getVar('ERR_REPORT_DIR', True) |
30 | datafile = os.path.join(logpath, "error-report.txt") | 33 | datafile = os.path.join(logpath, "error-report.txt") |
@@ -53,8 +56,8 @@ python errorreport_handler () { | |||
53 | taskdata['task'] = task | 56 | taskdata['task'] = task |
54 | if log: | 57 | if log: |
55 | try: | 58 | try: |
56 | logFile = open(log, 'r') | 59 | logFile = codecs.open(log, 'r', 'utf-8') |
57 | logdata = logFile.read().decode('utf-8') | 60 | logdata = logFile.read() |
58 | logFile.close() | 61 | logFile.close() |
59 | except: | 62 | except: |
60 | logdata = "Unable to read log file" | 63 | logdata = "Unable to read log file" |