refactor(modules): improve exception handling and simplify service usage
Enhancements - Replace bare `except:` with `except Exception:` in multiple modules- Cast step calculation to `int` for consistent type - Simplify `get_battery_icon_file` to return a string directly - Use `get_todo_service()` instead of module-level `todo_service` throughout todo widget - Remove unused `"zen": "zen-browser"` mapping entry Bug Fixes - Prevent bare exception swallowing by catching `Exception` explicitly - Ensure proper cleanup of timer IDs and other resources - Delete unused modules/osdd components New Features - None
This commit is contained in:
34 files changed
+682
-519
No files matched your search
@@ -518,7 +518,7 @@ class BluetoothConnections(Box):
|
||||
# Make sure other devices revealer is collapsed when closing
|
||||
try:
|
||||
self.other_devices_revealer.child_revealed = False
|
||||
except:
|
||||
except Exception:
|
||||
pass # Widget might already be destroyed
|
||||
|
||||
def close_bluetooth(self):
|
||||
|
||||
@@ -29,9 +29,9 @@ def get_battery_icon_file(
|
||||
Relative path to the battery icon file
|
||||
"""
|
||||
clamped = max(0, min(100, percentage))
|
||||
step = (clamped // 10) * 10
|
||||
step = int((clamped // 10) * 10)
|
||||
filename = f"battery-{step:03d}{'-charging' if is_charging else ''}.svg"
|
||||
return svg_file(f"battery/{filename}")
|
||||
return f"battery/{filename}"
|
||||
|
||||
|
||||
def set_bluetooth_enabled_with_fallback(client, enabled: bool):
|
||||
@@ -518,7 +518,7 @@ class BluetoothConnections(Box):
|
||||
# Make sure other devices revealer is collapsed when closing
|
||||
try:
|
||||
self.other_devices_revealer.child_revealed = False
|
||||
except:
|
||||
except Exception:
|
||||
pass # Widget might already be destroyed
|
||||
|
||||
def close_bluetooth(self):
|
||||
|
||||
@@ -911,7 +911,7 @@ class PlayerBox(Box):
|
||||
from gi.repository import GLib
|
||||
|
||||
GLib.source_remove(self._seekbar_timer_id)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
self._seekbar_timer_id = None
|
||||
|
||||
@@ -1041,7 +1041,7 @@ class PlayerBox(Box):
|
||||
from gi.repository import GLib
|
||||
|
||||
GLib.source_remove(self._seekbar_timer_id)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
self._seekbar_timer_id = None
|
||||
|
||||
|
||||
@@ -683,7 +683,7 @@ class ModusControlCenter(Window):
|
||||
if self._caffeine_process:
|
||||
try:
|
||||
self._caffeine_process.terminate()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
self._caffeine_process = None
|
||||
else:
|
||||
@@ -1193,5 +1193,5 @@ class ModusControlCenter(Window):
|
||||
logger.error(f"Failed to destroy control center: {e}")
|
||||
try:
|
||||
super().destroy()
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
@@ -114,7 +114,6 @@ class PerAppVolumeControl(Box):
|
||||
"visual studio code": "vscode",
|
||||
"telegram": "telegram-desktop",
|
||||
"pulse": "audio-card",
|
||||
"zen": "zen-browser",
|
||||
"pipewire": "audio-card",
|
||||
"alsa": "audio-card",
|
||||
"sink": "audio-speakers",
|
||||
@@ -323,7 +322,7 @@ class PerAppVolumeControl(Box):
|
||||
for connection in self._signal_connections:
|
||||
try:
|
||||
audio_service.disconnect(connection)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
self._signal_connections.clear()
|
||||
|
||||
@@ -556,7 +556,6 @@ class PlayerBoxStack(Box):
|
||||
self._update_all_player_buttons()
|
||||
|
||||
def on_new_player(self, mpris_manager, player):
|
||||
player_name = player.props.player_name
|
||||
|
||||
# if player_name in self.config.get("ignore", []):
|
||||
# return
|
||||
|
||||
@@ -699,7 +699,7 @@ class WifiConnections(Box):
|
||||
# Make sure other networks revealer is collapsed when closing
|
||||
try:
|
||||
self.other_networks_revealer.child_revealed = False
|
||||
except:
|
||||
except Exception:
|
||||
pass # Widget might already be destroyed
|
||||
|
||||
def close_wifi(self):
|
||||
|
||||
Reference in new issue
Block a user