refactor(src/window):improve error handling with logging
This commit is contained in:
26 files changed
+239
-211
No files matched your search
@@ -124,8 +124,8 @@ class BluetoothDeviceSlot(CenterBox):
|
||||
for sig_id in self._signal_ids:
|
||||
try:
|
||||
self.device.disconnect(sig_id)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
self._signal_ids.clear()
|
||||
self.device = None
|
||||
super().destroy()
|
||||
@@ -386,8 +386,8 @@ class BluetoothConnections(Box):
|
||||
self.parent.hide_controlcenter()
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
def update_scan_label(self):
|
||||
"""Update scanning state appearance"""
|
||||
@@ -485,8 +485,8 @@ class BluetoothConnections(Box):
|
||||
# Always show the other devices button, regardless of available devices
|
||||
self.other_devices_button.set_visible(True) # Always visible
|
||||
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
finally:
|
||||
self._update_in_progress = False
|
||||
|
||||
@@ -515,8 +515,8 @@ class BluetoothConnections(Box):
|
||||
|
||||
try:
|
||||
self.update_devices()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
return True # Continue monitoring
|
||||
|
||||
@@ -529,8 +529,8 @@ class BluetoothConnections(Box):
|
||||
# Simply trigger update_devices which has its own safety checks
|
||||
# Avoid forcing signal emissions to prevent race conditions
|
||||
self.update_devices()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
def on_client_changed(self, *_):
|
||||
"""Handle when the bluetooth client state changes"""
|
||||
@@ -547,14 +547,14 @@ class BluetoothConnections(Box):
|
||||
for sig_id in self._client_signal_ids:
|
||||
try:
|
||||
self.client.disconnect(sig_id)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
self._client_signal_ids.clear()
|
||||
# Collapse other devices revealer
|
||||
try:
|
||||
self.other_devices_revealer.child_revealed = False
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
def close_bluetooth(self):
|
||||
"""Called when Bluetooth panel is being closed"""
|
||||
|
||||
@@ -159,8 +159,8 @@ class BluetoothDeviceSlot(CenterBox):
|
||||
for sig_id in self._signal_ids:
|
||||
try:
|
||||
self.device.disconnect(sig_id)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"[Bluetooth] Failed to disconnect signal {sig_id}: {e}")
|
||||
self._signal_ids.clear()
|
||||
self.device = None
|
||||
super().destroy()
|
||||
@@ -200,8 +200,10 @@ class BluetoothDeviceSlot(CenterBox):
|
||||
]
|
||||
self.styles = new_styles
|
||||
self.dimage.set_property("style-classes", " ".join(self.styles))
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(
|
||||
f"[Bluetooth] Failed to update styles for {self.device.name}: {e}"
|
||||
)
|
||||
|
||||
if (
|
||||
hasattr(self.device, "battery_percentage")
|
||||
@@ -482,8 +484,8 @@ class BluetoothConnections(Box):
|
||||
self.parent.hide_controlcenter()
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"[Bluetooth] Failed to open bluetooth settings: {e}")
|
||||
|
||||
def update_scan_label(self):
|
||||
"""Update scanning state appearance"""
|
||||
@@ -529,7 +531,10 @@ class BluetoothConnections(Box):
|
||||
else:
|
||||
other_devices.append(device)
|
||||
new_other_addresses.add(device.address)
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
f"[Bluetooth] Failed to process device {device}: {e}"
|
||||
)
|
||||
continue
|
||||
|
||||
paired_changed = current_paired_addresses != new_paired_addresses
|
||||
@@ -591,8 +596,8 @@ class BluetoothConnections(Box):
|
||||
self.no_devices_label.set_visible(not has_any_devices)
|
||||
self.other_devices_button.set_visible(True) # Always visible
|
||||
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"[Bluetooth] Error during update_devices: {e}")
|
||||
finally:
|
||||
self._update_in_progress = False
|
||||
|
||||
@@ -618,8 +623,8 @@ class BluetoothConnections(Box):
|
||||
|
||||
try:
|
||||
self.update_devices()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"[Bluetooth] Error during periodic refresh: {e}")
|
||||
|
||||
return True
|
||||
|
||||
@@ -630,8 +635,8 @@ class BluetoothConnections(Box):
|
||||
|
||||
try:
|
||||
self.update_devices()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"[Bluetooth] Error during forced device refresh: {e}")
|
||||
|
||||
def on_client_changed(self, *_):
|
||||
"""Handle when the bluetooth client state changes"""
|
||||
@@ -648,13 +653,15 @@ class BluetoothConnections(Box):
|
||||
for sig_id in self._client_signal_ids:
|
||||
try:
|
||||
self.client.disconnect(sig_id)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(
|
||||
f"[Bluetooth] Failed to disconnect client signal {sig_id}: {e}"
|
||||
)
|
||||
self._client_signal_ids.clear()
|
||||
try:
|
||||
self.other_devices_revealer.child_revealed = False
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"[Bluetooth] Failed to hide other devices revealer: {e}")
|
||||
|
||||
def close_bluetooth(self):
|
||||
"""Called when Bluetooth panel is being closed"""
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import weakref
|
||||
|
||||
from fabric.utils import (
|
||||
bulk_connect,
|
||||
)
|
||||
from fabric.utils import bulk_connect, logger
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.button import Button
|
||||
from fabric.widgets.image import Image
|
||||
@@ -81,8 +79,8 @@ class PlayerBoxStack(Box):
|
||||
for obj, handler_id in self._signal_connections:
|
||||
try:
|
||||
obj.disconnect(handler_id)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
self._signal_connections.clear()
|
||||
super().destroy()
|
||||
|
||||
@@ -565,8 +563,8 @@ class PlayerBox(Box):
|
||||
for obj, handler_id in self._signal_connections:
|
||||
try:
|
||||
obj.disconnect(handler_id)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
super().destroy()
|
||||
|
||||
def _on_player_next(self, *_):
|
||||
@@ -586,8 +584,8 @@ class PlayerBox(Box):
|
||||
self.play_pause_icon.dynamic_file(
|
||||
"player/play.svg" if status == "paused" else "player/Pause.svg"
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
def _on_playback_change(self, *_):
|
||||
if self.exit or self.player is None:
|
||||
@@ -634,7 +632,7 @@ class PlayerBox(Box):
|
||||
if self.seek_bar.get_adjustment().get_upper() > 0:
|
||||
self.seek_bar.set_value(min(2147483647, position_micros))
|
||||
except Exception as e:
|
||||
print(f"[_on_track_position] Error: {e}")
|
||||
logger.error(f"[_on_track_position] Error: {e}")
|
||||
|
||||
def _on_seek_start(self, widget, event):
|
||||
self._user_seeking = True
|
||||
@@ -651,8 +649,8 @@ class PlayerBox(Box):
|
||||
self.seek_bar.set_range(
|
||||
0, min(2147483647, duration) if duration > 0 else 100
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
def _on_scale_value_changed(self, scale: Scale):
|
||||
if self.player and not self.exit and self._user_seeking:
|
||||
@@ -660,8 +658,8 @@ class PlayerBox(Box):
|
||||
new_position = max(-2147483648, min(2147483647, int(scale.get_value())))
|
||||
self.player.position = new_position
|
||||
self.position_label.set_label(self.length_str(new_position))
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
|
||||
class ExpandedPlayer(Window):
|
||||
|
||||
@@ -599,14 +599,14 @@ class ModusControlCenter(AppletWindow):
|
||||
try:
|
||||
self.volume_scale.disconnect_by_func(self.set_volume)
|
||||
self.volume_scale.disconnect_by_func(self.on_volume_scroll)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
if hasattr(self, "brightness_scale"):
|
||||
try:
|
||||
self.brightness_scale.disconnect_by_func(self.set_brightness)
|
||||
self.brightness_scale.disconnect_by_func(self.on_brightness_scroll)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
self._signals_connected = False
|
||||
self._resources_initialized = False
|
||||
@@ -765,8 +765,8 @@ class ModusControlCenter(AppletWindow):
|
||||
if self._caffeine_process:
|
||||
try:
|
||||
self._caffeine_process.terminate()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
self._caffeine_process = None
|
||||
else:
|
||||
inhibit_script = get_relative_path("../../utils/inhibit.py")
|
||||
@@ -904,8 +904,8 @@ class ModusControlCenter(AppletWindow):
|
||||
def close_bluetooth(self, *_):
|
||||
try:
|
||||
self.bluetooth_man.close_bluetooth()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
if self.current_view == "expanded_player":
|
||||
self._crossfade_to_view("main")
|
||||
else:
|
||||
@@ -915,8 +915,8 @@ class ModusControlCenter(AppletWindow):
|
||||
def close_wifi(self, *_):
|
||||
try:
|
||||
self.wifi_man.close_wifi()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
if self.current_view == "expanded_player":
|
||||
self._crossfade_to_view("main")
|
||||
else:
|
||||
@@ -1072,28 +1072,28 @@ class ModusControlCenter(AppletWindow):
|
||||
if hasattr(self, "volume_scale") and self.volume_scale:
|
||||
try:
|
||||
self.volume_scale.disconnect_by_func(self.set_volume)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
try:
|
||||
self.volume_scale.disconnect_by_func(self.on_volume_scroll)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
if hasattr(self, "brightness_scale") and self.brightness_scale:
|
||||
try:
|
||||
self.brightness_scale.disconnect_by_func(self.set_brightness)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
try:
|
||||
self.brightness_scale.disconnect_by_func(self.on_brightness_scroll)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
# Disconnect the visibility change signal on self
|
||||
try:
|
||||
self.disconnect_by_func(self._on_visibility_changed)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
self._signals_connected = False
|
||||
logger.debug("All signals disconnected successfully")
|
||||
@@ -1254,5 +1254,5 @@ class ModusControlCenter(AppletWindow):
|
||||
logger.error(f"Failed to destroy control center: {e}")
|
||||
try:
|
||||
super().destroy()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
@@ -1,4 +1,4 @@
|
||||
from fabric.utils import GLib
|
||||
from fabric.utils import GLib, logger
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.button import Button
|
||||
from fabric.widgets.image import Image
|
||||
@@ -60,8 +60,8 @@ class PerAppVolumeControl(Box):
|
||||
try:
|
||||
if hasattr(self.control_center, "add_keybinding"):
|
||||
self.control_center.add_keybinding("Escape", self._go_back)
|
||||
except Exception:
|
||||
pass # Ignore if keybinding fails
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}") # Ignore if keybinding fails
|
||||
|
||||
self.children = [self.header, self.scrolled_window]
|
||||
|
||||
@@ -174,8 +174,8 @@ class PerAppVolumeControl(Box):
|
||||
for child in list(self.apps_container.get_children()):
|
||||
try:
|
||||
child.destroy()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
self.apps_container.children = []
|
||||
self._app_widgets.clear()
|
||||
|
||||
@@ -310,7 +310,7 @@ class PerAppVolumeControl(Box):
|
||||
app.volume = volume_value
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error setting volume for {app.name}: {e}")
|
||||
logger.error(f"Error setting volume for {app.name}: {e}")
|
||||
finally:
|
||||
GLib.timeout_add(100, lambda: self._updating_volumes.discard(app.name))
|
||||
|
||||
@@ -331,8 +331,8 @@ class PerAppVolumeControl(Box):
|
||||
if self._refresh_timer is not None:
|
||||
try:
|
||||
GLib.source_remove(self._refresh_timer)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
self._refresh_timer = None
|
||||
|
||||
# Disconnect audio service signals
|
||||
@@ -340,8 +340,8 @@ class PerAppVolumeControl(Box):
|
||||
for connection in self._signal_connections:
|
||||
try:
|
||||
audio_service.disconnect(connection)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
self._signal_connections.clear()
|
||||
self._app_widgets.clear()
|
||||
|
||||
@@ -101,8 +101,8 @@ class PlayerBoxStack(Box):
|
||||
for obj, handler_id in self._signal_connections:
|
||||
try:
|
||||
obj.disconnect(handler_id)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
self._signal_connections.clear()
|
||||
super().destroy()
|
||||
|
||||
@@ -451,8 +451,8 @@ class PlayerBox(Box):
|
||||
self.play_pause_icon.dynamic_file(
|
||||
"player/play.svg" if status == "paused" else "player/Pause.svg"
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
def _on_playback_change(self, *_):
|
||||
if self.exit or self.player is None:
|
||||
@@ -482,6 +482,6 @@ class PlayerBox(Box):
|
||||
for obj, handler_id in self._signal_connections:
|
||||
try:
|
||||
obj.disconnect(handler_id)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
super().destroy()
|
||||
@@ -1,6 +1,6 @@
|
||||
import subprocess
|
||||
|
||||
from fabric.utils import Gdk, GLib
|
||||
from fabric.utils import Gdk, GLib, logger
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.button import Button
|
||||
from fabric.widgets.centerbox import CenterBox
|
||||
@@ -151,7 +151,10 @@ class WifiNetworkSlot(Box):
|
||||
self.network_service.connect_wifi_bssid(
|
||||
self.access_point.bssid, callback=on_open_connection_result
|
||||
)
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
logger.error(
|
||||
f"[WiFi] Failed to connect to {self.access_point.ssid}: {e}"
|
||||
)
|
||||
self._reset_connect_state()
|
||||
self.on_changed()
|
||||
|
||||
@@ -234,7 +237,10 @@ class WifiNetworkSlot(Box):
|
||||
self.network_service.connect_wifi_with_password(
|
||||
self.access_point.bssid, password, callback=on_connection_result
|
||||
)
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
logger.error(
|
||||
f"[WiFi] Failed to initiate connection to {self.access_point.ssid}: {e}"
|
||||
)
|
||||
self._reset_connect_state()
|
||||
if self.password_dialog:
|
||||
self._show_connection_error("Connection failed. Please try again.")
|
||||
@@ -447,8 +453,8 @@ class WifiConnections(Box):
|
||||
self.parent.hide_controlcenter()
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"[WiFi] Failed to open network settings: {e}")
|
||||
|
||||
def update_networks(self, *_):
|
||||
"""Update the list of available networks"""
|
||||
@@ -487,7 +493,10 @@ class WifiConnections(Box):
|
||||
else:
|
||||
other_networks.append(access_point)
|
||||
new_other_ssids.add(access_point.ssid)
|
||||
except Exception:
|
||||
except Exception as e:
|
||||
logger.warning(
|
||||
f"[WiFi] Failed to process access point {access_point}: {e}"
|
||||
)
|
||||
continue
|
||||
|
||||
known_changed = current_known_ssids != new_known_ssids
|
||||
@@ -570,8 +579,8 @@ class WifiConnections(Box):
|
||||
self.other_networks_button.set_visible(True) # Always visible
|
||||
self.refresh_network_states()
|
||||
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"[WiFi] Error during update_networks: {e}")
|
||||
finally:
|
||||
self._update_in_progress = False
|
||||
|
||||
@@ -619,8 +628,8 @@ class WifiConnections(Box):
|
||||
|
||||
try:
|
||||
self.update_networks()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"[WiFi] Error during periodic network refresh: {e}")
|
||||
|
||||
return True # Continue monitoring
|
||||
|
||||
@@ -631,8 +640,8 @@ class WifiConnections(Box):
|
||||
|
||||
try:
|
||||
self.update_networks()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"[WiFi] Error during forced network refresh: {e}")
|
||||
|
||||
def setup_pull_to_refresh(self):
|
||||
"""Setup pull-to-refresh gesture for the scrolled window"""
|
||||
@@ -714,15 +723,15 @@ class WifiConnections(Box):
|
||||
for obj, sig_id in self._signal_ids:
|
||||
try:
|
||||
obj.disconnect(sig_id)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"[WiFi] Failed to disconnect signal {sig_id}: {e}")
|
||||
self._signal_ids.clear()
|
||||
self.wifi_service = None
|
||||
self.network_service = None
|
||||
try:
|
||||
self.other_networks_revealer.child_revealed = False
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"[WiFi] Failed to hide other networks revealer: {e}")
|
||||
|
||||
def close_wifi(self):
|
||||
"""Called when WiFi panel is being closed"""
|
||||
|
||||
@@ -6,7 +6,7 @@ from concurrent.futures import ThreadPoolExecutor
|
||||
from typing import Any, Dict, List, Optional, Tuple
|
||||
|
||||
import psutil
|
||||
from fabric.utils import GLib, invoke_repeater, time
|
||||
from fabric.utils import GLib, invoke_repeater, time, logger
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.circularprogressbar import CircularProgressBar
|
||||
from fabric.widgets.datetime import DateTime
|
||||
@@ -52,7 +52,7 @@ def http_get_json(
|
||||
if response.status_code == 200:
|
||||
return response.json()
|
||||
except Exception as e:
|
||||
print(f"HTTP Request to {url} failed: {e}")
|
||||
logger.error(f"HTTP Request to {url} failed: {e}")
|
||||
return None
|
||||
|
||||
|
||||
@@ -64,8 +64,8 @@ def get_location() -> str:
|
||||
manual_location = config.get("weather_location")
|
||||
if manual_location:
|
||||
return manual_location
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
# Fallback to IP geolocation APIs
|
||||
for api_url in LOCATION_APIS:
|
||||
@@ -160,7 +160,7 @@ def format_weather_data(weather_data: Dict[str, Any], city: str) -> List[str]:
|
||||
|
||||
return [icon_name, temp, condition, city, max_temp, min_temp, gradient_class]
|
||||
except (KeyError, IndexError, TypeError) as e:
|
||||
print(f"Error formatting weather data: {e}")
|
||||
logger.error(f"Error formatting weather data: {e}")
|
||||
return None
|
||||
|
||||
|
||||
@@ -605,7 +605,7 @@ class RamInfo(SystemInfoBase):
|
||||
)
|
||||
GLib.idle_add(self.progress.set_value, mem.percent)
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
logger.error(f"Error: {e}")
|
||||
return True
|
||||
|
||||
|
||||
@@ -634,8 +634,8 @@ class CpuInfo(SystemInfoBase):
|
||||
for p in ["package id 0", "core 0", ""]
|
||||
):
|
||||
return round(entry.current, 1)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
return None
|
||||
|
||||
def update(self) -> bool:
|
||||
@@ -646,7 +646,7 @@ class CpuInfo(SystemInfoBase):
|
||||
self.temp_value.set_label(f"{temp}°C" if temp else "N/A")
|
||||
GLib.idle_add(self.progress.set_value, cpu)
|
||||
except Exception as e:
|
||||
print(f"Error: {e}")
|
||||
logger.error(f"Error: {e}")
|
||||
return True
|
||||
|
||||
|
||||
|
||||
+18
-14
@@ -1,7 +1,7 @@
|
||||
from typing import List, Optional, Tuple
|
||||
|
||||
from fabric.core.service import Property
|
||||
from fabric.utils import Gdk, GLib
|
||||
from fabric.utils import Gdk, GLib, logger
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.entry import Entry
|
||||
from fabric.widgets.scrolledwindow import ScrolledWindow
|
||||
@@ -193,7 +193,7 @@ class Launcher(Window):
|
||||
self.selected_index = 0
|
||||
self._update_results_display()
|
||||
except Exception as e:
|
||||
print(
|
||||
logger.error(
|
||||
f"Error querying triggered plugin {triggered_plugin.name}: {e}"
|
||||
)
|
||||
self._clear_results()
|
||||
@@ -353,7 +353,7 @@ class Launcher(Window):
|
||||
self.selected_index = 0
|
||||
self._update_results_display()
|
||||
except Exception as e:
|
||||
print(f"Error getting applications: {e}")
|
||||
logger.error(f"Error getting applications: {e}")
|
||||
self._clear_results()
|
||||
else:
|
||||
self._clear_results()
|
||||
@@ -369,7 +369,9 @@ class Launcher(Window):
|
||||
)
|
||||
all_results = self.triggered_plugin.query(remaining_query)
|
||||
except Exception as e:
|
||||
print(f"Error in triggered plugin {self.triggered_plugin.name}: {e}")
|
||||
logger.error(
|
||||
f"Error in triggered plugin {self.triggered_plugin.name}: {e}"
|
||||
)
|
||||
all_results = []
|
||||
else:
|
||||
# Check for trigger activation
|
||||
@@ -400,7 +402,9 @@ class Launcher(Window):
|
||||
try:
|
||||
all_results = triggered_plugin.query(remaining_query)
|
||||
except Exception as e:
|
||||
print(f"Error in triggered plugin {triggered_plugin.name}: {e}")
|
||||
logger.error(
|
||||
f"Error in triggered plugin {triggered_plugin.name}: {e}"
|
||||
)
|
||||
all_results = []
|
||||
else:
|
||||
# No trigger detected - search applications and show trigger suggestions
|
||||
@@ -416,7 +420,7 @@ class Launcher(Window):
|
||||
app_results = applications_plugin.query(query)
|
||||
all_results.extend(app_results)
|
||||
except Exception as e:
|
||||
print(f"Error searching applications: {e}")
|
||||
logger.error(f"Error searching applications: {e}")
|
||||
|
||||
# Also show trigger suggestions if query matches trigger prefixes
|
||||
trigger_suggestions = self._get_trigger_suggestions(query)
|
||||
@@ -695,18 +699,18 @@ class Launcher(Window):
|
||||
print(f"External command executed: {command_string}")
|
||||
return result_value
|
||||
except Exception as e:
|
||||
print(f"Error executing result action: {e}")
|
||||
logger.error(f"Error executing result action: {e}")
|
||||
return None
|
||||
else:
|
||||
print(f"No suitable result found for: {command_string}")
|
||||
return None
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error querying plugin {triggered_plugin.name}: {e}")
|
||||
logger.error(f"Error querying plugin {triggered_plugin.name}: {e}")
|
||||
return None
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error executing external command '{command_string}': {e}")
|
||||
logger.error(f"Error executing external command '{command_string}': {e}")
|
||||
return None
|
||||
|
||||
def _update_results_display(self):
|
||||
@@ -1274,7 +1278,7 @@ class Launcher(Window):
|
||||
)
|
||||
vadjustment.set_value(target_pos)
|
||||
except Exception as e:
|
||||
print(f"Error in _ensure_selected_visible: {e}")
|
||||
logger.error(f"Error in _ensure_selected_visible: {e}")
|
||||
|
||||
return False # Don't repeat the idle callback
|
||||
|
||||
@@ -1325,11 +1329,11 @@ class Launcher(Window):
|
||||
if hasattr(gtk_entry, "select_region"):
|
||||
gtk_entry.select_region(text_length, text_length)
|
||||
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Could not clear selection: {e}")
|
||||
logger.error(f"Could not clear selection: {e}")
|
||||
return False
|
||||
|
||||
# Schedule clearing selection after focus is established
|
||||
@@ -1386,4 +1390,4 @@ class Launcher(Window):
|
||||
self.close_launcher()
|
||||
# For trigger suggestions and keep_launcher_open actions, the launcher stays open
|
||||
except Exception as e:
|
||||
print(f"Error activating result: {e}")
|
||||
logger.error(f"Error activating result: {e}")
|
||||
@@ -1,3 +1,4 @@
|
||||
from fabric.utils import logger
|
||||
import importlib
|
||||
import importlib.util
|
||||
import os
|
||||
@@ -72,7 +73,7 @@ class PluginManager:
|
||||
break
|
||||
|
||||
except Exception as e:
|
||||
print(f"Failed to load plugin {plugin_name}: {e}")
|
||||
logger.error(f"Failed to load plugin {plugin_name}: {e}")
|
||||
|
||||
def _activate_default_plugins(self):
|
||||
"""Activate default plugins."""
|
||||
@@ -115,7 +116,7 @@ class PluginManager:
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"Failed to activate plugin {plugin_name}: {e}")
|
||||
logger.error(f"Failed to activate plugin {plugin_name}: {e}")
|
||||
return False
|
||||
|
||||
def deactivate_plugin(self, plugin_name: str) -> bool:
|
||||
@@ -136,7 +137,7 @@ class PluginManager:
|
||||
return True
|
||||
|
||||
except Exception as e:
|
||||
print(f"Failed to deactivate plugin {plugin_name}: {e}")
|
||||
logger.error(f"Failed to deactivate plugin {plugin_name}: {e}")
|
||||
return False
|
||||
|
||||
def get_active_plugins(self) -> List[PluginBase]:
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from fabric.utils import logger
|
||||
import json
|
||||
from typing import List
|
||||
|
||||
@@ -54,7 +55,7 @@ class ApplicationsPlugin(PluginBase):
|
||||
dock_apps_json = json.dumps(pinned_apps)
|
||||
modus_service.dock_apps = dock_apps_json
|
||||
except Exception as e:
|
||||
print(f"Failed to notify dock about pinned app change: {e}")
|
||||
logger.error(f"Failed to notify dock about pinned app change: {e}")
|
||||
|
||||
def query(self, query_string: str) -> List[Result]:
|
||||
"""Search applications based on query."""
|
||||
@@ -64,7 +65,7 @@ class ApplicationsPlugin(PluginBase):
|
||||
try:
|
||||
applications = get_desktop_applications(include_hidden=False)
|
||||
except Exception as e:
|
||||
print(f"Failed to load applications: {e}")
|
||||
logger.error(f"Failed to load applications: {e}")
|
||||
applications = []
|
||||
|
||||
query = query_string.lower().strip()
|
||||
@@ -163,7 +164,7 @@ class ApplicationsPlugin(PluginBase):
|
||||
try:
|
||||
applications = get_desktop_applications(include_hidden=False)
|
||||
except Exception as e:
|
||||
print(f"Failed to load applications: {e}")
|
||||
logger.error(f"Failed to load applications: {e}")
|
||||
return []
|
||||
|
||||
results = []
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from fabric.utils import logger
|
||||
import subprocess
|
||||
from threading import Timer
|
||||
from typing import List
|
||||
@@ -74,7 +75,7 @@ class CaffeinePlugin(PluginBase):
|
||||
self._schedule_expiration_notification(duration, duration_text)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error starting inhibit script: {e}")
|
||||
logger.error(f"Error starting inhibit script: {e}")
|
||||
|
||||
return action
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from fabric.utils import logger
|
||||
import math
|
||||
import re
|
||||
import subprocess
|
||||
@@ -136,8 +137,8 @@ class CalculatorPlugin(PluginBase):
|
||||
plugin_name=self.display_name,
|
||||
)
|
||||
]
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
return []
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from fabric.utils import logger
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import threading
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
@@ -71,7 +71,7 @@ class ClipboardPlugin(PluginBase):
|
||||
self.image_cache.clear()
|
||||
self.clipboard_items_cache.clear()
|
||||
except Exception as e:
|
||||
print(f"Error cleaning up temporary files: {e}", file=sys.stderr)
|
||||
logger.error(f"Error cleaning up temporary files: {e}")
|
||||
|
||||
def invalidate_cache(self):
|
||||
"""Force invalidation of the clipboard cache."""
|
||||
@@ -120,7 +120,7 @@ class ClipboardPlugin(PluginBase):
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error forcing launcher refresh: {e}")
|
||||
logger.error(f"Error forcing launcher refresh: {e}")
|
||||
|
||||
return False # Don't repeat
|
||||
|
||||
@@ -128,7 +128,7 @@ class ClipboardPlugin(PluginBase):
|
||||
GLib.timeout_add(10, trigger_refresh)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Could not trigger refresh: {e}")
|
||||
logger.error(f"Could not trigger refresh: {e}")
|
||||
|
||||
def _load_clipboard_items_cached(self) -> List[str]:
|
||||
"""Load clipboard items from cliphist with caching and change detection."""
|
||||
@@ -172,10 +172,10 @@ class ClipboardPlugin(PluginBase):
|
||||
|
||||
return items
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"Error loading clipboard history: {e}", file=sys.stderr)
|
||||
logger.error(f"Error loading clipboard history: {e}")
|
||||
return []
|
||||
except Exception as e:
|
||||
print(f"Unexpected error: {e}", file=sys.stderr)
|
||||
logger.error(f"Unexpected error: {e}")
|
||||
return []
|
||||
|
||||
def _load_clipboard_items(self) -> List[str]:
|
||||
@@ -247,7 +247,7 @@ class ClipboardPlugin(PluginBase):
|
||||
|
||||
return pixbuf
|
||||
except Exception as e:
|
||||
print(f"Error loading image preview: {e}", file=sys.stderr)
|
||||
logger.error(f"Error loading image preview: {e}")
|
||||
return None
|
||||
|
||||
def _load_image_preview_async(self, item_id: str) -> Optional[GdkPixbuf.Pixbuf]:
|
||||
@@ -430,6 +430,6 @@ class ClipboardPlugin(PluginBase):
|
||||
self.cache_timestamp = 0
|
||||
|
||||
except subprocess.SubprocessError as e:
|
||||
print(f"Error copying to clipboard: {e}", file=sys.stderr)
|
||||
logger.error(f"Error copying to clipboard: {e}")
|
||||
except subprocess.TimeoutExpired as e:
|
||||
print(f"Timeout copying to clipboard: {e}", file=sys.stderr)
|
||||
logger.error(f"Timeout copying to clipboard: {e}")
|
||||
@@ -137,7 +137,7 @@ class EmojiPlugin(PluginBase):
|
||||
self.recent_emojis = OrderedDict()
|
||||
self._save_recent_emojis()
|
||||
except Exception as e:
|
||||
print(f"Error loading recent emoji data: {e}")
|
||||
logger.error(f"Error loading recent emoji data: {e}")
|
||||
self.recent_emojis = OrderedDict()
|
||||
|
||||
def _save_recent_emojis(self):
|
||||
@@ -149,7 +149,7 @@ class EmojiPlugin(PluginBase):
|
||||
with open(self.recent_emoji_path, "w", encoding="utf-8") as f:
|
||||
json.dump(dict(self.recent_emojis), f, ensure_ascii=False, indent=2)
|
||||
except Exception as e:
|
||||
print(f"Error saving recent emoji data: {e}")
|
||||
logger.error(f"Error saving recent emoji data: {e}")
|
||||
|
||||
def _add_to_recent(self, emoji: str):
|
||||
"""Add an emoji to the recent list."""
|
||||
@@ -186,7 +186,7 @@ class EmojiPlugin(PluginBase):
|
||||
self._add_to_recent(emoji)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Failed to copy to clipboard: {e}")
|
||||
logger.error(f"Failed to copy to clipboard: {e}")
|
||||
|
||||
def query(self, query_string: str) -> List[Result]:
|
||||
"""Search emojis based on query."""
|
||||
|
||||
@@ -260,12 +260,12 @@ class WallpaperPlugin(PluginBase):
|
||||
)
|
||||
self.thumbnail_cache[filename] = pixbuf
|
||||
except Exception as e:
|
||||
print(f"Error loading thumbnail for {filename}: {e}")
|
||||
logger.error(f"Error loading thumbnail for {filename}: {e}")
|
||||
self.thumbnail_cache[filename] = None
|
||||
else:
|
||||
self.thumbnail_cache[filename] = None
|
||||
except Exception as e:
|
||||
print(f"Error creating thumbnail for {filename}: {e}")
|
||||
logger.error(f"Error creating thumbnail for {filename}: {e}")
|
||||
self.thumbnail_cache[filename] = None
|
||||
finally:
|
||||
self.thumbnail_loading.discard(filename)
|
||||
@@ -341,7 +341,7 @@ class WallpaperPlugin(PluginBase):
|
||||
# File doesn't exist, return default
|
||||
return "scheme-tonal-spot"
|
||||
except Exception as e:
|
||||
print(f"Error reading current scheme from config: {e}")
|
||||
logger.error(f"Error reading current scheme from config: {e}")
|
||||
return "scheme-tonal-spot"
|
||||
|
||||
def _set_current_scheme(self, scheme: str):
|
||||
@@ -365,7 +365,7 @@ class WallpaperPlugin(PluginBase):
|
||||
json.dump(config, f, indent=4)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error saving current scheme to config: {e}")
|
||||
logger.error(f"Error saving current scheme to config: {e}")
|
||||
return
|
||||
|
||||
# Apply the scheme to current wallpaper if matugen is enabled
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from fabric.utils import logger
|
||||
import subprocess
|
||||
import urllib.parse
|
||||
from typing import List
|
||||
@@ -179,7 +180,7 @@ class WebSearchPlugin(PluginBase):
|
||||
["xdg-open", url], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"Failed to open URL: {e}")
|
||||
logger.error(f"Failed to open URL: {e}")
|
||||
|
||||
def _get_search_engine_list(self) -> List[Result]:
|
||||
"""Get list of available search engines."""
|
||||
@@ -248,7 +249,7 @@ class WebSearchPlugin(PluginBase):
|
||||
stderr=subprocess.DEVNULL,
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"Failed to open search URL: {e}")
|
||||
logger.error(f"Failed to open search URL: {e}")
|
||||
|
||||
def _show_engine_help(self, engine_id: str):
|
||||
"""Show help for a specific search engine."""
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from fabric.utils import logger
|
||||
import json
|
||||
import os
|
||||
from typing import Any, Dict, List
|
||||
@@ -19,7 +20,7 @@ class TriggerConfig:
|
||||
with open(config_path, "r", encoding="utf-8") as f:
|
||||
config = json.load(f)
|
||||
except Exception as e:
|
||||
print(f"Error loading trigger config: {e}")
|
||||
logger.error(f"Error loading trigger config: {e}")
|
||||
|
||||
self.config = config
|
||||
self.launcher_config = self.config.get("launcher_config", {})
|
||||
|
||||
@@ -186,8 +186,8 @@ def get_notification_image_cache_key(notification_id, image_pixbuf):
|
||||
f"{width}x{height}".encode()
|
||||
).hexdigest()[:8]
|
||||
return dimension_hash
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
# Fallback to timestamp for invalid pixbufs
|
||||
return str(int(time.time()))[:8]
|
||||
@@ -863,8 +863,8 @@ class NotificationRevealer(SlideRevealer):
|
||||
self.notif_box._should_cleanup_cache = True
|
||||
try:
|
||||
self.notification.close("dismissed-by-user")
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
return False
|
||||
|
||||
return True
|
||||
@@ -942,8 +942,8 @@ class NotificationRevealer(SlideRevealer):
|
||||
if hasattr(self, "_closed_handler_id") and self._closed_handler_id:
|
||||
try:
|
||||
self.notification.disconnect(self._closed_handler_id)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
self._closed_handler_id = 0
|
||||
|
||||
# Clean up CSS provider from style context
|
||||
@@ -952,8 +952,8 @@ class NotificationRevealer(SlideRevealer):
|
||||
style_context = self.notif_box.get_style_context()
|
||||
if style_context:
|
||||
style_context.remove_provider(self._css_provider)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
self._css_provider = None
|
||||
|
||||
super().destroy()
|
||||
@@ -1042,8 +1042,8 @@ class ModusNoti(Window):
|
||||
oldest = self.notification_queue.pop(0)
|
||||
try:
|
||||
oldest.close("dismissed-by-user")
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
# Add new notification to queue
|
||||
self.notification_queue.append(notification)
|
||||
@@ -1093,8 +1093,8 @@ class ModusNoti(Window):
|
||||
# Force close current notification with smooth animation
|
||||
try:
|
||||
self.current_notification.notification.close("expired")
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
def _show_next_notification(self):
|
||||
if (
|
||||
@@ -1126,8 +1126,8 @@ class ModusNoti(Window):
|
||||
for child in list(self.notifications.children):
|
||||
try:
|
||||
self.notifications.remove(child)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
self.notifications.children = [new_box]
|
||||
|
||||
@@ -1158,8 +1158,8 @@ class ModusNoti(Window):
|
||||
try:
|
||||
if notification_box in self.notifications.children:
|
||||
self.notifications.remove(notification_box)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
# Reset state
|
||||
self.current_notification = None
|
||||
@@ -1191,8 +1191,8 @@ class ModusNoti(Window):
|
||||
for notification in list(self.notification_queue):
|
||||
try:
|
||||
notification.close("dismissed-by-user")
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
self.notification_queue.clear()
|
||||
|
||||
# Also clean current notification if showing
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from fabric.hyprland.widgets import HyprlandActiveWindow as ActiveWindow
|
||||
from fabric.utils import FormattedString, exec_shell_command_async
|
||||
from fabric.utils import FormattedString, exec_shell_command_async, logger
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.button import Button
|
||||
from fabric.widgets.centerbox import CenterBox
|
||||
@@ -312,8 +312,8 @@ class GlobalMenuDropdowns:
|
||||
modus_service.disconnect_by_func(self._on_active_app_changed)
|
||||
modus_service.disconnect_by_func(self.changed_dropdown)
|
||||
modus_service.disconnect_by_func(self.hide_dropdowns)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
# Destroy all dropdown captures
|
||||
dropdown_captures = [
|
||||
@@ -327,8 +327,8 @@ class GlobalMenuDropdowns:
|
||||
try:
|
||||
if capture and hasattr(capture, "destroy"):
|
||||
capture.destroy()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
super().destroy()
|
||||
|
||||
@@ -364,6 +364,6 @@ class GlobalMenu(Box):
|
||||
if hasattr(self, "dropdown_system") and self.dropdown_system:
|
||||
try:
|
||||
self.dropdown_system.destroy()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
super().destroy()
|
||||
@@ -1,3 +1,4 @@
|
||||
from fabric.utils import logger
|
||||
from fabric.bluetooth import BluetoothClient
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.button import Button
|
||||
@@ -465,7 +466,7 @@ class BatteryIndicator(Box):
|
||||
if hasattr(self, "battery_service") and self.battery_service:
|
||||
self.battery_service.disconnect_by_func(self.on_battery_direct_changed)
|
||||
except Exception as e:
|
||||
print(f"Error disconnecting battery indicator signals: {e}")
|
||||
logger.error(f"Error disconnecting battery indicator signals: {e}")
|
||||
|
||||
# Destroy window and widget
|
||||
try:
|
||||
@@ -473,8 +474,8 @@ class BatteryIndicator(Box):
|
||||
self.battery_widget.destroy()
|
||||
if hasattr(self, "battery_window") and self.battery_window:
|
||||
self.battery_window.destroy()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
super().destroy()
|
||||
|
||||
@@ -491,14 +492,14 @@ def add_destroy_to_indicators():
|
||||
self.bluetooth.disconnect_by_func(self.on_device_added)
|
||||
self.bluetooth.disconnect_by_func(self.on_device_removed)
|
||||
except Exception as e:
|
||||
print(f"Error disconnecting bluetooth indicator signals: {e}")
|
||||
logger.error(f"Error disconnecting bluetooth indicator signals: {e}")
|
||||
try:
|
||||
if hasattr(self, "bluetooth_widget") and self.bluetooth_widget:
|
||||
self.bluetooth_widget.destroy()
|
||||
if hasattr(self, "bluetooth_window") and self.bluetooth_window:
|
||||
self.bluetooth_window.destroy()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
Box.destroy(self)
|
||||
|
||||
BluetoothIndicator.destroy = bt_destroy
|
||||
@@ -521,8 +522,8 @@ def add_destroy_to_indicators():
|
||||
self.network_service.wifi_device.disconnect_by_func(
|
||||
self.on_network_direct_changed
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
if (
|
||||
hasattr(self.network_service, "ethernet_device")
|
||||
and self.network_service.ethernet_device
|
||||
@@ -531,17 +532,17 @@ def add_destroy_to_indicators():
|
||||
self.network_service.ethernet_device.disconnect_by_func(
|
||||
self.on_network_direct_changed
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
except Exception as e:
|
||||
print(f"Error disconnecting network indicator signals: {e}")
|
||||
logger.error(f"Error disconnecting network indicator signals: {e}")
|
||||
try:
|
||||
if hasattr(self, "wifi_widget") and self.wifi_widget:
|
||||
self.wifi_widget.destroy()
|
||||
if hasattr(self, "wifi_window") and self.wifi_window:
|
||||
self.wifi_window.destroy()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
Box.destroy(self)
|
||||
|
||||
NetworkIndicator.destroy = net_destroy
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from fabric.utils import GLib, os, time
|
||||
from fabric.utils import GLib, os, time, logger
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.button import Button
|
||||
from fabric.widgets.label import Label
|
||||
@@ -41,14 +41,14 @@ class RecordingIndicator(Button):
|
||||
# Prevent container.show_all() from forcing this visible when no recording
|
||||
try:
|
||||
self.set_no_show_all(True)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
self.connect("clicked", self.on_stop_recording)
|
||||
try:
|
||||
setup_cursor_hover(self, "pointer")
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
self.connect("button-press-event", self.on_button_press)
|
||||
self.set_visible(False)
|
||||
|
||||
@@ -86,7 +86,7 @@ class RecordingIndicator(Button):
|
||||
self.cleanup_recording_state()
|
||||
|
||||
except Exception as e:
|
||||
print(f"[DEBUG] Error checking recording status: {e}")
|
||||
logger.error(f"[DEBUG] Error checking recording status: {e}")
|
||||
if self.get_visible():
|
||||
self.set_visible(False)
|
||||
self.cleanup_recording_state()
|
||||
@@ -110,7 +110,7 @@ class RecordingIndicator(Button):
|
||||
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"[DEBUG] Error updating timer display: {e}")
|
||||
logger.error(f"[DEBUG] Error updating timer display: {e}")
|
||||
return False
|
||||
|
||||
def cleanup_recording_state(self):
|
||||
@@ -197,7 +197,7 @@ class RecordingIndicator(Button):
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
print(f"[DEBUG] Error in delayed recording indicator init: {e}")
|
||||
logger.error(f"[DEBUG] Error in delayed recording indicator init: {e}")
|
||||
return False
|
||||
|
||||
def destroy(self):
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from fabric.utils import logger
|
||||
from fabric.hyprland.widgets import HyprlandWorkspaces, WorkspaceButton
|
||||
from fabric.widgets.box import Box
|
||||
|
||||
@@ -105,8 +106,8 @@ class WorkspaceIndicator(Box):
|
||||
|
||||
if self._on_config_changed in _config_handlers:
|
||||
_config_handlers.remove(self._on_config_changed)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
if hasattr(self, "workspaces") and self.workspaces:
|
||||
self.workspaces.destroy()
|
||||
Box.destroy(self)
|
||||
@@ -1,3 +1,4 @@
|
||||
from fabric.utils import logger
|
||||
from fabric.system_tray.widgets import SystemTray
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.button import Button
|
||||
@@ -312,8 +313,8 @@ class Panel(Window):
|
||||
|
||||
if self._on_config_changed in _config_handlers:
|
||||
_config_handlers.remove(self._on_config_changed)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
# Destroy components
|
||||
for component in [
|
||||
@@ -324,14 +325,14 @@ class Panel(Window):
|
||||
]:
|
||||
try:
|
||||
component.destroy()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
# Destroy MouseCapture windows
|
||||
for mc in [self.control_center, self.notification_center]:
|
||||
try:
|
||||
mc.destroy()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
super().destroy()
|
||||
@@ -5,7 +5,7 @@ from fabric.widgets.entry import Entry
|
||||
from fabric.widgets.label import Label
|
||||
from fabric.widgets.scrolledwindow import ScrolledWindow
|
||||
from fabric.widgets.stack import Stack
|
||||
from fabric.utils import Gtk, GLib, Gdk
|
||||
from fabric.utils import Gtk, GLib, Gdk, logger
|
||||
|
||||
from services.config import config, on_config_change
|
||||
from utils.utils import setup_cursor_hover, svg_file
|
||||
@@ -98,8 +98,8 @@ class SettingsEntry(Entry):
|
||||
try:
|
||||
if value.isdigit():
|
||||
value = int(value)
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
|
||||
config().set(self.config_key, value)
|
||||
config().save()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from fabric.utils import logger
|
||||
import json
|
||||
|
||||
from fabric.hyprland.widgets import get_hyprland_connection
|
||||
@@ -208,7 +209,7 @@ class ApplicationSwitcher(Window):
|
||||
self.view.show_all()
|
||||
self.update_selection()
|
||||
except Exception as e:
|
||||
print(f"Failed to update windows: {e}")
|
||||
logger.error(f"Failed to update windows: {e}")
|
||||
|
||||
def on_key_press(self, _, event):
|
||||
keyval = event.keyval
|
||||
@@ -319,7 +320,7 @@ class ApplicationSwitcher(Window):
|
||||
f"hyprctl dispatch 'hl.dsp.focus({{ window = \"address:{address}\" }})'"
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"Failed to focus window: {e}")
|
||||
logger.error(f"Failed to focus window: {e}")
|
||||
|
||||
def _on_item_clicked(self, index):
|
||||
self.current_index = index
|
||||
@@ -334,7 +335,7 @@ class ApplicationSwitcher(Window):
|
||||
window = self.get_window()
|
||||
seat.grab(window, Gdk.SeatCapabilities.KEYBOARD, False, None, None, None)
|
||||
except Exception as e:
|
||||
print(f"Failed to grab keyboard: {e}")
|
||||
logger.error(f"Failed to grab keyboard: {e}")
|
||||
|
||||
def ungrab_keyboard(self):
|
||||
try:
|
||||
@@ -342,4 +343,4 @@ class ApplicationSwitcher(Window):
|
||||
seat = display.get_default_seat()
|
||||
seat.ungrab()
|
||||
except Exception as e:
|
||||
print(f"Failed to ungrab keyboard: {e}")
|
||||
logger.error(f"Failed to ungrab keyboard: {e}")
|
||||
Reference in new issue
Block a user