From 5a32a97af0338d14bae5ce4232cf3c671c750288 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= Date: Wed, 24 Aug 2016 09:36:54 +0200 Subject: [PATCH] avocado.core.html: Skip file on UnicodeDecodeError MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Users have reported failures of `lspci -vvnn` to be undecodable by utf-8. Let's only log the failure and leave it up to the user to locate the file on the disk. Signed-off-by: Lukáš Doktor --- avocado/core/html.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/avocado/core/html.py b/avocado/core/html.py index a51ff1fd..19e1b2b7 100644 --- a/avocado/core/html.py +++ b/avocado/core/html.py @@ -182,9 +182,9 @@ class ReportModel(object): sysinfo_dict['contents'] = sysinfo_file.read() sysinfo_dict['element_id'] = '%s_heading_%s' % (phase, s_id) sysinfo_dict['collapse_id'] = '%s_collapse_%s' % (phase, s_id) - except OSError: - sysinfo_dict[s_f] = ('Error reading sysinfo file %s' % - sysinfo_path) + except (OSError, UnicodeDecodeError) as details: + sysinfo_dict[s_f] = ('Error reading sysinfo file %s: %s' % + (sysinfo_path, details)) sysinfo_list.append(sysinfo_dict) s_id += 1 return sysinfo_list -- GitLab