diff options
author | Ola x Nilsson <ola.x.nilsson@axis.com> | 2019-10-21 12:30:31 +0200 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2019-10-23 16:30:36 +0100 |
commit | a92ef13e3dc417c0dbb0543eccb3ed2223d02b92 (patch) | |
tree | 5f4ec7feaa534480cbf7251a861d883ea5bcb12c /meta/classes | |
parent | f3f15972494efad3688236d868d1b3eda2877207 (diff) | |
download | poky-a92ef13e3dc417c0dbb0543eccb3ed2223d02b92.tar.gz |
report-error.bbclass: Use with to control file handle lifetime
(From OE-Core rev: ab108dfc690fb95b66f1c6243ff165f0849fa2b1)
Signed-off-by: Ola x Nilsson <olani@axis.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/report-error.bbclass | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/meta/classes/report-error.bbclass b/meta/classes/report-error.bbclass index ea043b23e1..1a12db1206 100644 --- a/meta/classes/report-error.bbclass +++ b/meta/classes/report-error.bbclass | |||
@@ -78,19 +78,15 @@ python errorreport_handler () { | |||
78 | taskdata['task'] = task | 78 | taskdata['task'] = task |
79 | if log: | 79 | if log: |
80 | try: | 80 | try: |
81 | logFile = codecs.open(log, 'r', 'utf-8') | 81 | with codecs.open(log, encoding='utf-8') as logFile: |
82 | logdata = logFile.read() | 82 | logdata = logFile.read() |
83 | |||
84 | # Replace host-specific paths so the logs are cleaner | 83 | # Replace host-specific paths so the logs are cleaner |
85 | for d in ("TOPDIR", "TMPDIR"): | 84 | for d in ("TOPDIR", "TMPDIR"): |
86 | s = e.data.getVar(d) | 85 | s = e.data.getVar(d) |
87 | if s: | 86 | if s: |
88 | logdata = logdata.replace(s, d) | 87 | logdata = logdata.replace(s, d) |
89 | |||
90 | logFile.close() | ||
91 | except: | 88 | except: |
92 | logdata = "Unable to read log file" | 89 | logdata = "Unable to read log file" |
93 | |||
94 | else: | 90 | else: |
95 | logdata = "No Log" | 91 | logdata = "No Log" |
96 | 92 | ||