From ef947ac57b86bb4ca49f0e45b63dc89f6eebaed8 Mon Sep 17 00:00:00 2001 From: Roberto Cabezas Date: Tue, 8 Sep 2026 11:48:12 -0300 Subject: [PATCH 01/10] Fix bare except clauses in sensors_python.py Bare `except:` blocks silently swallow KeyboardInterrupt/SystemExit along with real errors, making the process hard to interrupt and hiding bugs. Switch all 35 occurrences to `except Exception:`, which preserves existing behavior for actual sensor errors. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01FyR2qGEWt3ApGumu5ykE5X --- library/sensors/sensors_python.py | 70 +++++++++++++++---------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/library/sensors/sensors_python.py b/library/sensors/sensors_python.py index fc76af1bd..b73be57cc 100644 --- a/library/sensors/sensors_python.py +++ b/library/sensors/sensors_python.py @@ -39,13 +39,13 @@ # AMD GPU on Linux try: import pyamdgpuinfo -except: +except Exception: pyamdgpuinfo = None # AMD GPU on Windows try: import pyadl -except: +except Exception: pyadl = None PNIC_BEFORE = {} @@ -89,7 +89,7 @@ def sensors_fans(): try: max_rpm = int(bcat(base + '_max')) - except: + except Exception: max_rpm = False # Real maximum speed not found if not max_rpm: if current_rpm > 2200: @@ -101,7 +101,7 @@ def sensors_fans(): try: min_rpm = int(bcat(base + '_min')) - except: + except Exception: min_rpm = 0 # Approximated: min fan speed is 0 RPM percent = int((current_rpm - min_rpm) / (max_rpm - min_rpm) * 100) except (IOError, OSError) as err: @@ -124,21 +124,21 @@ class Cpu(sensors.Cpu): def percentage(interval: float) -> float: try: return psutil.cpu_percent(interval=interval) - except: + except Exception: return math.nan @staticmethod def frequency() -> float: try: return psutil.cpu_freq().current - except: + except Exception: return math.nan @staticmethod def load() -> Tuple[float, float, float]: # 1 / 5 / 15min avg (%): try: return psutil.getloadavg() - except: + except Exception: return math.nan, math.nan, math.nan @staticmethod @@ -158,7 +158,7 @@ def temperature() -> float: elif 'zenpower' in sensors_temps: # AMD CPU with zenpower (k10temp is in blacklist) cpu_temp = sensors_temps['zenpower'][0].current - except: + except Exception: # psutil.sensors_temperatures not available on Windows / MacOS pass return cpu_temp @@ -176,7 +176,7 @@ def fan_percent(fan_name: str = None) -> float: elif is_cpu_fan(entry.label) or is_cpu_fan(name): # Auto-detected fan return entry.percent - except: + except Exception: pass return math.nan @@ -251,30 +251,30 @@ def stats() -> Tuple[ try: memory_used_all = [item.memoryUsed for item in nvidia_gpus] memory_used_mb = sum(memory_used_all) / len(memory_used_all) - except: + except Exception: memory_used_mb = math.nan try: memory_total_all = [item.memoryTotal for item in nvidia_gpus] memory_total_mb = sum(memory_total_all) / len(memory_total_all) - except: + except Exception: memory_total_mb = math.nan try: memory_percentage = (memory_used_mb / memory_total_mb) * 100 - except: + except Exception: memory_percentage = math.nan try: load_all = [item.load for item in nvidia_gpus] load = (sum(load_all) / len(load_all)) * 100 - except: + except Exception: load = math.nan try: temperature_all = [item.temperature for item in nvidia_gpus] temperature = sum(temperature_all) / len(temperature_all) - except: + except Exception: temperature = math.nan return load, memory_percentage, memory_used_mb, memory_total_mb, temperature @@ -293,7 +293,7 @@ def fan_percent() -> float: for entry in entries: if "gpu" in (entry.label.lower() or name.lower()): return entry.percent - except: + except Exception: pass return math.nan @@ -307,7 +307,7 @@ def frequency() -> float: def is_available() -> bool: try: return len(GPUtil.getGPUs()) > 0 - except: + except Exception: return False @@ -323,30 +323,30 @@ def stats() -> Tuple[ try: memory_used_bytes = amd_gpu.query_vram_usage() memory_used = memory_used_bytes / 1024 / 1024 - except: + except Exception: memory_used_bytes = math.nan memory_used = math.nan try: memory_total_bytes = amd_gpu.memory_info["vram_size"] memory_total = memory_total_bytes / 1024 / 1024 - except: + except Exception: memory_total_bytes = math.nan memory_total = math.nan try: memory_percentage = (memory_used_bytes / memory_total_bytes) * 100 - except: + except Exception: memory_percentage = math.nan try: load = amd_gpu.query_load() * 100 - except: + except Exception: load = math.nan try: temperature = amd_gpu.query_temperature() - except: + except Exception: temperature = math.nan return load, memory_percentage, memory_used, memory_total, temperature @@ -355,12 +355,12 @@ def stats() -> Tuple[ try: load = amd_gpu.getCurrentUsage() - except: + except Exception: load = math.nan try: temperature = amd_gpu.getCurrentTemperature() - except: + except Exception: temperature = math.nan # GPU memory data not supported by pyadl @@ -386,7 +386,7 @@ def fan_percent() -> float: if pyadl: return pyadl.ADLManager.getInstance().getDevices()[0].getCurrentFanSpeed( pyadl.ADL_DEVICE_FAN_SPEED_TYPE_PERCENTAGE) - except: + except Exception: pass return math.nan @@ -401,7 +401,7 @@ def frequency() -> float: return pyadl.ADLManager.getInstance().getDevices()[0].getCurrentEngineClock() else: return math.nan - except: + except Exception: return math.nan @staticmethod @@ -413,7 +413,7 @@ def is_available() -> bool: return True else: return False - except: + except Exception: return False @@ -422,14 +422,14 @@ class Memory(sensors.Memory): def swap_percent() -> float: try: return psutil.swap_memory().percent - except: + except Exception: return math.nan @staticmethod def virtual_percent() -> float: try: return psutil.virtual_memory().percent - except: + except Exception: return math.nan @staticmethod @@ -438,7 +438,7 @@ def virtual_used() -> int: # In bytes # Do not use psutil.virtual_memory().used: from https://psutil.readthedocs.io/en/latest/#memory # "It is calculated differently depending on the platform and designed for informational purposes only" return psutil.virtual_memory().total - psutil.virtual_memory().available - except: + except Exception: return -1 @staticmethod @@ -447,7 +447,7 @@ def virtual_free() -> int: # In bytes # Do not use psutil.virtual_memory().free: from https://psutil.readthedocs.io/en/latest/#memory # "note that this doesn’t reflect the actual memory available (use available instead)." return psutil.virtual_memory().available - except: + except Exception: return -1 @@ -456,21 +456,21 @@ class Disk(sensors.Disk): def disk_usage_percent() -> float: try: return psutil.disk_usage("/").percent - except: + except Exception: return math.nan @staticmethod def disk_used() -> int: # In bytes try: return psutil.disk_usage("/").used - except: + except Exception: return -1 @staticmethod def disk_free() -> int: # In bytes try: return psutil.disk_usage("/").free - except: + except Exception: return -1 @@ -494,7 +494,7 @@ def stats(if_name, interval) -> Tuple[ uploaded = pnic_after[if_name].bytes_sent download_rate = (pnic_after[if_name].bytes_recv - PNIC_BEFORE[if_name].bytes_recv) / interval downloaded = pnic_after[if_name].bytes_recv - except: + except Exception: # Interface might not be in PNIC_BEFORE for now pass @@ -503,5 +503,5 @@ def stats(if_name, interval) -> Tuple[ logger.warning("Network interface '%s' not found. Check names in config.yaml." % if_name) return upload_rate, uploaded, download_rate, downloaded - except: + except Exception: return -1, -1, -1, -1 From 3a4a0d4c8d9b69dbd2f1552d144014b8e1de52b5 Mon Sep 17 00:00:00 2001 From: Roberto Cabezas Date: Tue, 8 Sep 2026 11:49:01 -0300 Subject: [PATCH 02/10] Fix bare except clauses in configure.py Same rationale as sensors_python.py: bare except: silently swallows KeyboardInterrupt/SystemExit along with real errors. Switch all 24 occurrences to except Exception:, preserving existing behavior. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01FyR2qGEWt3ApGumu5ykE5X --- configure.py | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/configure.py b/configure.py index f4689f723..527a95794 100755 --- a/configure.py +++ b/configure.py @@ -53,7 +53,7 @@ e)) try: sys.exit(0) - except: + except Exception: os._exit(0) from library.sensors.sensors_python import sensors_fans, is_cpu_fan @@ -382,10 +382,10 @@ def __init__(self): try: version = open(VERSION_FILE).readline() - except: + except Exception: try: version = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('utf-8') - except: + except Exception: version = "0.0.0" version_label = ttk.Label(self.window, text=version, foreground=DISABLED_TEXT_COLOR) @@ -431,7 +431,7 @@ def load_theme_preview(self): if theme_data and theme_data['display'].get("DISPLAY_SIZE", '3.5"') == _SIZE_2_1_INCH: # This is a circular screen: apply a circle mask over the preview theme_preview.paste(circular_mask, mask=circular_mask) - except: + except Exception: theme_preview = Image.open(MAIN_DIRECTORY / "res/docs/no-preview.png") finally: theme_preview.thumbnail((320, 480), Image.Resampling.LANCZOS) @@ -460,14 +460,14 @@ def load_config_values(self): try: self.theme_cb.set(self.config['config']['THEME']) - except: + except Exception: self.theme_cb.set("") self.load_theme_preview() try: self.hwlib_cb.set(hw_lib_map[self.config['config']['HW_SENSORS']]) - except: + except Exception: self.hwlib_cb.current(0) try: @@ -475,7 +475,7 @@ def load_config_values(self): self.eth_cb.current(0) else: self.eth_cb.set(self.config['config']['ETH']) - except: + except Exception: self.eth_cb.current(0) try: @@ -483,7 +483,7 @@ def load_config_values(self): self.wl_cb.current(0) else: self.wl_cb.set(self.config['config']['WLO']) - except: + except Exception: self.wl_cb.current(0) try: @@ -491,7 +491,7 @@ def load_config_values(self): self.com_cb.current(0) else: self.com_cb.set(self.config['config']['COM_PORT']) - except: + except Exception: self.com_cb.current(0) # Guess display size from theme in the configuration @@ -506,24 +506,24 @@ def load_config_values(self): if size == SIZE_2_x_INCH and self.config['display']['REVISION'] == 'TUR_USB': size = SIZE_2_8_INCH_NEWREV self.size_cb.set(size) - except: + except Exception: self.size_cb.current(0) # Guess model from revision and size revision = self.config['display']['REVISION'] try: self.model_cb.set(revision_and_size_to_model_map[(revision, size)]) - except: + except Exception: self.model_cb.current(0) try: self.orient_cb.set(reverse_map[self.config['display']['DISPLAY_REVERSE']]) - except: + except Exception: self.orient_cb.current(0) try: self.brightness_slider.set(int(self.config['display']['BRIGHTNESS'])) - except: + except Exception: self.brightness_slider.set(50) try: @@ -531,7 +531,7 @@ def load_config_values(self): self.cpu_fan_cb.current(0) else: self.cpu_fan_cb.set(self.config['config']['CPU_FAN']) - except: + except Exception: self.cpu_fan_cb.current(0) # Reload content on screen @@ -602,7 +602,7 @@ def on_theme_editor_click(self): # Load Python file with local python interpreter (useful for venvs) theme_editor = next(MAIN_DIRECTORY.glob("theme-editor.py")) subprocess.Popen([sys.executable, str(theme_editor), self.theme_cb.get()]) - except: + except Exception: # Load binary (for releases) or Python file with system interpreter theme_editor = next(MAIN_DIRECTORY.glob("theme-editor*")) if platform.system() == "Windows": @@ -620,7 +620,7 @@ def on_saverun_click(self): # Load Python file with local python interpreter (useful for venvs) main_file = next(MAIN_DIRECTORY.glob("main.py")) subprocess.Popen([sys.executable, str(main_file)]) - except: + except Exception: # Load binary (for releases) or Python file with system interpreter main_file = next(MAIN_DIRECTORY.glob("main*")) if platform.system() == "Windows": @@ -821,7 +821,7 @@ def validateCoord(self, coord: str): return True try: float(coord) - except: + except Exception: return False return True @@ -836,32 +836,32 @@ def load_config_values(self, config): try: self.ping_entry.insert(0, self.config['config']['PING']) - except: + except Exception: self.ping_entry.insert(0, "8.8.8.8") try: self.api_entry.insert(0, self.config['config']['WEATHER_API_KEY']) - except: + except Exception: pass try: self.lat_entry.insert(0, self.config['config']['WEATHER_LATITUDE']) - except: + except Exception: self.lat_entry.insert(0, "45.75") try: self.long_entry.insert(0, self.config['config']['WEATHER_LONGITUDE']) - except: + except Exception: self.long_entry.insert(0, "45.75") try: self.unit_cb.set(weather_unit_map[self.config['config']['WEATHER_UNITS']]) - except: + except Exception: self.unit_cb.set(0) try: self.lang_cb.set(weather_lang_map[self.config['config']['WEATHER_LANGUAGE']]) - except: + except Exception: self.lang_cb.set(weather_lang_map["en"]) def citysearch_show_warning(self, warning): @@ -880,7 +880,7 @@ def on_search_click(self): try: request = requests.get(OPENWEATHER_GEOAPI_URL, timeout=5, params={"appid": api_key, "lang": lang, "q": city, "limit": 10}) - except: + except Exception: self.citysearch_show_warning("Error fetching OpenWeatherMap Geo API") return From 9544a3570b65ed67a9e319787ac05e07fac95010 Mon Sep 17 00:00:00 2001 From: Roberto Cabezas Date: Tue, 8 Sep 2026 11:51:27 -0300 Subject: [PATCH 03/10] Fix bare except clauses in theme-editor.py Same rationale as sensors_python.py/configure.py: bare except: silently swallows KeyboardInterrupt/SystemExit along with real errors. Switch to except Exception:, preserving existing behavior. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01FyR2qGEWt3ApGumu5ykE5X --- theme-editor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/theme-editor.py b/theme-editor.py index 3704737c6..61665cefc 100755 --- a/theme-editor.py +++ b/theme-editor.py @@ -36,12 +36,12 @@ try: import tkinter from PIL import ImageTk, Image -except: +except Exception: print( "[ERROR] Tkinter dependency not installed. Please follow troubleshooting page: https://github.com/mathoudebine/turing-smart-screen-python/wiki/Troubleshooting#all-os-tkinter-dependency-not-installed") try: sys.exit(0) - except: + except Exception: os._exit(0) if len(sys.argv) != 2: @@ -53,7 +53,7 @@ print(" theme-editor.py Cyberpunk") try: sys.exit(0) - except: + except Exception: os._exit(0) import library.log @@ -134,7 +134,7 @@ def on_closing(): logger.debug("Exit Theme Editor...") try: sys.exit(0) - except: + except Exception: os._exit(0) From ba52b0611ea365dda1131fdef9cfebee5011594b Mon Sep 17 00:00:00 2001 From: Roberto Cabezas Date: Tue, 8 Sep 2026 11:51:27 -0300 Subject: [PATCH 04/10] Fix bare except clauses in library/stats.py Same rationale as sensors_python.py/configure.py: bare except: silently swallows KeyboardInterrupt/SystemExit along with real errors. Switch to except Exception:, preserving existing behavior. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01FyR2qGEWt3ApGumu5ykE5X --- library/stats.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/stats.py b/library/stats.py index 9abdc6f48..67f3908ff 100644 --- a/library/stats.py +++ b/library/stats.py @@ -61,7 +61,7 @@ logger.error("LibreHardwareMonitor integration is only available on Windows") try: sys.exit(0) - except: + except Exception: os._exit(0) elif HW_SENSORS == "STUB": logger.warning("Stub sensors, not real HW sensors") @@ -78,7 +78,7 @@ logger.error("Unsupported HW_SENSORS value in config.yaml") try: sys.exit(0) - except: + except Exception: os._exit(0) import library.sensors.sensors_custom as sensors_custom @@ -752,7 +752,7 @@ def stats(): lc_time = locale.getdefaultlocale()[0] else: lc_time = babel.dates.LC_TIME - except: + except Exception: lc_time = None if not lc_time: From d4da1d009f8176fc57e82a062011e9dae678b6c8 Mon Sep 17 00:00:00 2001 From: Roberto Cabezas Date: Tue, 8 Sep 2026 11:51:27 -0300 Subject: [PATCH 05/10] Fix bare except clauses in main.py Same rationale as sensors_python.py/configure.py: bare except: silently swallows KeyboardInterrupt/SystemExit along with real errors. Switch to except Exception:, preserving existing behavior. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01FyR2qGEWt3ApGumu5ykE5X --- main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index dad5251f6..88a1ae25c 100755 --- a/main.py +++ b/main.py @@ -59,12 +59,12 @@ e)) try: sys.exit(0) - except: + except Exception: os._exit(0) try: import pystray -except: +except Exception: # If pystray cannot be loaded do not stop the program, just ignore it. The tray icon will not be displayed. pass @@ -108,7 +108,7 @@ def clean_stop(tray_icon=None): # We force the exit to avoid waiting for other scheduled tasks: they may have a long delay! try: sys.exit(0) - except: + except Exception: os._exit(0) def on_signal_caught(signum, frame=None): @@ -122,7 +122,7 @@ def on_configure_tray(tray_icon, item): # Load Python file with local python interpreter (useful for venvs) configure_file = next(MAIN_DIRECTORY.glob("configure.py")) subprocess.Popen([sys.executable, str(configure_file)]) - except: + except Exception: # Load binary (for releases) or Python file with system interpreter configure_file = next(MAIN_DIRECTORY.glob("configure*")) if platform.system() == "Windows": @@ -191,7 +191,7 @@ def on_win32_wm_event(hWnd, msg, wParam, lParam): if platform.system() != "Darwin": tray_icon.run_detached() logger.info("Tray icon has been displayed") - except: + except Exception: tray_icon = None logger.warning("Tray icon is not supported on your platform") From 165044317fa0bdd0856e3c665d78301caac634c7 Mon Sep 17 00:00:00 2001 From: Roberto Cabezas Date: Tue, 8 Sep 2026 11:51:27 -0300 Subject: [PATCH 06/10] Fix bare except clauses in library/config.py Same rationale as sensors_python.py/configure.py: bare except: silently swallows KeyboardInterrupt/SystemExit along with real errors. Switch to except Exception:, preserving existing behavior. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01FyR2qGEWt3ApGumu5ykE5X --- library/config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/library/config.py b/library/config.py index c89200322..35de58cd2 100644 --- a/library/config.py +++ b/library/config.py @@ -59,11 +59,11 @@ def load_theme(): logger.info("Loading theme %s from %s" % (CONFIG_DATA['config']['THEME'], theme_path / "theme.yaml")) THEME_DATA = load_yaml(MAIN_DIRECTORY / theme_path / "theme.yaml") THEME_DATA['PATH'] = str(MAIN_DIRECTORY / theme_path) + "/" - except: + except Exception: logger.error("Theme not found or contains errors!") try: sys.exit(0) - except: + except Exception: os._exit(0) copy_default(THEME_DEFAULT, THEME_DATA) @@ -76,7 +76,7 @@ def check_theme_compatible(display_size: str): 'THEME'] + " is not compatible with your display revision " + CONFIG_DATA["display"]["REVISION"]) try: sys.exit(0) - except: + except Exception: os._exit(0) From f51d3b6d3e5bfae45d5e7cfcf9846b52c9c860b4 Mon Sep 17 00:00:00 2001 From: Roberto Cabezas Date: Tue, 8 Sep 2026 11:51:27 -0300 Subject: [PATCH 07/10] Fix bare except clauses in library/lcd/lcd_comm.py Same rationale as sensors_python.py/configure.py: bare except: silently swallows KeyboardInterrupt/SystemExit along with real errors. Switch to except Exception:, preserving existing behavior. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01FyR2qGEWt3ApGumu5ykE5X --- library/lcd/lcd_comm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/lcd/lcd_comm.py b/library/lcd/lcd_comm.py index 0e6f90b65..9522a7ce6 100644 --- a/library/lcd/lcd_comm.py +++ b/library/lcd/lcd_comm.py @@ -132,7 +132,7 @@ def openSerial(self): f"Configuration again and select the COM port manually") try: sys.exit(0) - except: + except Exception: os._exit(0) def closeSerial(self): From cf89b2fdcb0fed7c60c1f831b051197a244716ac Mon Sep 17 00:00:00 2001 From: Roberto Cabezas Date: Tue, 8 Sep 2026 11:51:27 -0300 Subject: [PATCH 08/10] Fix bare except clauses in library/lcd/lcd_comm_rev_c.py Same rationale as sensors_python.py/configure.py: bare except: silently swallows KeyboardInterrupt/SystemExit along with real errors. Switch to except Exception:, preserving existing behavior. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01FyR2qGEWt3ApGumu5ykE5X --- library/lcd/lcd_comm_rev_c.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/lcd/lcd_comm_rev_c.py b/library/lcd/lcd_comm_rev_c.py index 5de42bfa0..9f700712d 100644 --- a/library/lcd/lcd_comm_rev_c.py +++ b/library/lcd/lcd_comm_rev_c.py @@ -247,7 +247,7 @@ def _hello(self): if self.rom_version < 80 or self.rom_version > 100: logger.warning("ROM version %d may be invalid, use default ROM version 87" % self.rom_version) self.rom_version = 87 - except: + except Exception: logger.warning("Display returned invalid or unsupported ID, use default ROM version 87") self.rom_version = 87 From 0f956d082b3dfbf5137bad3ae96dda5be94fe6f0 Mon Sep 17 00:00:00 2001 From: Roberto Cabezas Date: Tue, 8 Sep 2026 11:51:27 -0300 Subject: [PATCH 09/10] Fix bare except clauses in library/pythoncheck.py Same rationale as sensors_python.py/configure.py: bare except: silently swallows KeyboardInterrupt/SystemExit along with real errors. Switch to except Exception:, preserving existing behavior. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01FyR2qGEWt3ApGumu5ykE5X --- library/pythoncheck.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/pythoncheck.py b/library/pythoncheck.py index 453839971..c8912fc9a 100644 --- a/library/pythoncheck.py +++ b/library/pythoncheck.py @@ -35,5 +35,5 @@ def check_python_version(): f"Python {MIN_PYTHON[0]}.{MIN_PYTHON[1]}-{MAX_PYTHON[0]}.{MAX_PYTHON[1]} required on platform {sys.platform}.") try: sys.exit(0) - except: + except Exception: os._exit(0) From 98d3ace4bde4f648e6c1e7c6b1e28c6d035ccd1d Mon Sep 17 00:00:00 2001 From: Roberto Cabezas Date: Tue, 8 Sep 2026 11:51:27 -0300 Subject: [PATCH 10/10] Fix bare except clauses in library/sensors/sensors_librehardwaremonitor.py Same rationale as sensors_python.py/configure.py: bare except: silently swallows KeyboardInterrupt/SystemExit along with real errors. Switch to except Exception:, preserving existing behavior. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01FyR2qGEWt3ApGumu5ykE5X --- library/sensors/sensors_librehardwaremonitor.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/library/sensors/sensors_librehardwaremonitor.py b/library/sensors/sensors_librehardwaremonitor.py index 473059c75..718adf96e 100644 --- a/library/sensors/sensors_librehardwaremonitor.py +++ b/library/sensors/sensors_librehardwaremonitor.py @@ -61,7 +61,7 @@ "config.yaml") try: sys.exit(0) - except: + except Exception: os._exit(0) handle = Hardware.Computer() @@ -201,7 +201,7 @@ def frequency() -> float: if frequencies: # Take mean of all core clock as "CPU clock" (as it is done in Windows Task Manager Performance tab) return mean(frequencies) - except: + except Exception: pass # Frequencies reading is not supported on this CPU @@ -236,7 +236,7 @@ def temperature() -> float: if sensor.SensorType == Hardware.SensorType.Temperature and str(sensor.Name).startswith( "Core") and sensor.Value is not None: return float(sensor.Value) - except: + except Exception: pass return math.nan @@ -251,7 +251,7 @@ def fan_percent(fan_name: str = None) -> float: if sensor.SensorType == Hardware.SensorType.Control and "#2" in str( sensor.Name) and sensor.Value is not None: # Is Motherboard #2 Fan always the CPU Fan ? return float(sensor.Value) - except: + except Exception: pass # No Fan Speed sensor for this CPU model @@ -331,7 +331,7 @@ def fps(cls) -> int: if int(sensor.Value) > 0: cls.prev_fps = int(sensor.Value) return cls.prev_fps - except: + except Exception: pass # No FPS sensor for this GPU model @@ -348,7 +348,7 @@ def fan_percent(cls) -> float: for sensor in gpu_to_use.Sensors: if sensor.SensorType == Hardware.SensorType.Control and sensor.Value is not None: return float(sensor.Value) - except: + except Exception: pass # No Fan Speed sensor for this GPU model @@ -367,7 +367,7 @@ def frequency(cls) -> float: # Keep only real core clocks, ignore effective core clocks if "Core" in str(sensor.Name) and "Effective" not in str(sensor.Name) and sensor.Value is not None: return float(sensor.Value) - except: + except Exception: pass # No Frequency sensor for this GPU model @@ -413,7 +413,7 @@ def swap_percent() -> float: swap_total = swap_used + swap_available try: percent_swap = swap_used / swap_total * 100.0 - except: + except Exception: # No swap / pagefile disabled percent_swap = 0.0