mirror of
https://github.com/gryf/wicd.git
synced 2025-12-23 22:52:33 +01:00
If the monitor loses contact with the daemon for an extended period, die instead of ignoring the errors.
This commit is contained in:
@@ -26,6 +26,7 @@ when appropriate.
|
|||||||
|
|
||||||
import gobject
|
import gobject
|
||||||
import time
|
import time
|
||||||
|
import sys
|
||||||
|
|
||||||
from dbus import DBusException
|
from dbus import DBusException
|
||||||
|
|
||||||
@@ -46,6 +47,23 @@ wireless = dbus_dict["wireless"]
|
|||||||
|
|
||||||
monitor = to_time = update_callback = None
|
monitor = to_time = update_callback = None
|
||||||
|
|
||||||
|
def diewithdbus(func):
|
||||||
|
def wrapper(self, *__args, **__kargs):
|
||||||
|
try:
|
||||||
|
ret = func(self, *__args, **__kargs)
|
||||||
|
self.__lost_dbus_count = 0
|
||||||
|
return ret
|
||||||
|
except dbusmanager.DBusException:
|
||||||
|
if self.__lost_dbus_count > 3:
|
||||||
|
sys.exit(1)
|
||||||
|
self.__lost_dbus_count += 1
|
||||||
|
return True
|
||||||
|
|
||||||
|
wrapper.__name__ = func.__name__
|
||||||
|
wrapper.__dict__ = func.__dict__
|
||||||
|
wrapper.__doc__ = func.__doc__
|
||||||
|
return wrapper
|
||||||
|
|
||||||
class ConnectionStatus(object):
|
class ConnectionStatus(object):
|
||||||
""" Class for monitoring the computer's connection status. """
|
""" Class for monitoring the computer's connection status. """
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -63,6 +81,7 @@ class ConnectionStatus(object):
|
|||||||
self.signal_changed = False
|
self.signal_changed = False
|
||||||
self.iwconfig = ""
|
self.iwconfig = ""
|
||||||
self.trigger_reconnect = False
|
self.trigger_reconnect = False
|
||||||
|
self.__lost_dbus_count = 0
|
||||||
|
|
||||||
bus = dbusmanager.get_bus()
|
bus = dbusmanager.get_bus()
|
||||||
bus.add_signal_receiver(self._force_update_connection_status,
|
bus.add_signal_receiver(self._force_update_connection_status,
|
||||||
@@ -143,6 +162,7 @@ class ConnectionStatus(object):
|
|||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@diewithdbus
|
||||||
def update_connection_status(self):
|
def update_connection_status(self):
|
||||||
""" Updates the tray icon and current connection status.
|
""" Updates the tray icon and current connection status.
|
||||||
|
|
||||||
@@ -154,7 +174,6 @@ class ConnectionStatus(object):
|
|||||||
wired_ip = None
|
wired_ip = None
|
||||||
wifi_ip = None
|
wifi_ip = None
|
||||||
|
|
||||||
try:
|
|
||||||
if daemon.GetSuspend():
|
if daemon.GetSuspend():
|
||||||
print "Suspended."
|
print "Suspended."
|
||||||
state = misc.SUSPENDED
|
state = misc.SUSPENDED
|
||||||
@@ -201,8 +220,6 @@ class ConnectionStatus(object):
|
|||||||
from_wireless = False
|
from_wireless = False
|
||||||
self.auto_reconnect(from_wireless)
|
self.auto_reconnect(from_wireless)
|
||||||
self.update_state(state)
|
self.update_state(state)
|
||||||
except DBusException, e:
|
|
||||||
print 'Ignoring DBus Error: ' + str(e)
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _force_update_connection_status(self):
|
def _force_update_connection_status(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user