fix(network): add missing get_connectivity() call and widen NM import guard
- get_connectivity was compared as method object (always True), wired icon always showed no-route when activated - NM import now catches GLib.Error and ImportError, not just ValueError - Sets NM = None on failure instead of leaving undefined
This commit is contained in:
1 file changed
+5
-4
@@ -4,13 +4,14 @@ from typing import List, Literal
|
|||||||
|
|
||||||
import gi
|
import gi
|
||||||
from fabric.core.service import Property, Service, Signal
|
from fabric.core.service import Property, Service, Signal
|
||||||
from fabric.utils import Gio, bulk_connect, exec_shell_command_async, logger
|
from fabric.utils import Gio, GLib, bulk_connect, exec_shell_command_async, logger
|
||||||
|
|
||||||
try:
|
try:
|
||||||
gi.require_version("NM", "1.0")
|
gi.require_version("NM", "1.0")
|
||||||
from gi.repository import NM
|
from gi.repository import NM
|
||||||
except ValueError:
|
except (ValueError, GLib.Error, ImportError) as e:
|
||||||
logger.error("Failed to start network manager")
|
logger.error(f"Failed to start network manager: {e}")
|
||||||
|
NM = None
|
||||||
|
|
||||||
|
|
||||||
class Wifi(Service):
|
class Wifi(Service):
|
||||||
@@ -258,7 +259,7 @@ class Ethernet(Service):
|
|||||||
elif network == "activating":
|
elif network == "activating":
|
||||||
return "network-wired-acquiring-symbolic"
|
return "network-wired-acquiring-symbolic"
|
||||||
|
|
||||||
elif self._device.get_connectivity != NM.ConnectivityState.FULL:
|
elif self._device.get_connectivity() != NM.ConnectivityState.FULL:
|
||||||
return "network-wired-no-route-symbolic"
|
return "network-wired-no-route-symbolic"
|
||||||
|
|
||||||
return "network-wired-disconnected-symbolic"
|
return "network-wired-disconnected-symbolic"
|
||||||
|
|||||||
Reference in new issue
Block a user