From 73a6fae2531701bc846e9dc5a03442074b878fa9 Mon Sep 17 00:00:00 2001 From: idziubenko Date: Fri, 15 Oct 2021 12:13:02 +0300 Subject: [PATCH] fixed crash on reading broken Xorg log --- pym/calculate/lib/utils/common.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pym/calculate/lib/utils/common.py b/pym/calculate/lib/utils/common.py index 2e3d755..9a8001d 100644 --- a/pym/calculate/lib/utils/common.py +++ b/pym/calculate/lib/utils/common.py @@ -306,9 +306,12 @@ def getVideoFromXorgLog(prefix="/", available_drivers=()): xorg_log_file = path.join(prefix, 'var/log/Xorg.%s.log' % display_number.group(1)) if path.exists(xorg_log_file): - matchStrs = [x.group(1) for x in [reDriverName.search(y) - for y in readLinesFile(xorg_log_file) - if "drv" in y and reDriver.search(y)] if x] + try: + matchStrs = [x.group(1) for x in [reDriverName.search(y) + for y in readLinesFile(xorg_log_file) + if "drv" in y and reDriver.search(y)] if x] + except UnicodeDecodeError as e: + return "" if matchStrs: reUnload = re.compile('UnloadModule: "(%s)"' %'|'.join(x for x in matchStrs))