when appropriate. """ import dbus import gobject import time if getattr(dbus, 'version', (0, 0, 0)) < (0, 80, 0): import dbus.glib else: from dbus.mainloop.glib import DBusGMainLoop DBusGMainLoop(set_as_default=True) import wicd.wpath as wpath import wicd.misc as misc misc.RenameProcess("wicd-monitor") if __name__ == '__main__': wpath.chdir(__file__) bus = dbus.SystemBus() proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon') daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon') proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon/wired') wired = dbus.Interface(proxy_obj, 'org.wicd.daemon.wired') proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon/wireless') wireless = dbus.Interface(proxy_obj, 'org.wicd.daemon.wireless') class ConnectionStatus (object) : """ Class for monitoring the computer's connection status. """ def __init__(self): """ Initialize variables needed for the connection status methods. """ self.last_strength = -2 self.displayed_strength = -1 self.still_wired = False
ICON_AVAIL = True USE_EGG = False # Import egg.trayicon if we're using an older gtk version if not hasattr(gtk, "StatusIcon"): try: import egg.trayicon USE_EGG = True except ImportError: print(('Unable to load tray icon: Missing both egg.trayicon and ' + \ 'gtk.StatusIcon modules.')) ICON_AVAIL = False misc.RenameProcess("wicd-client") if __name__ == '__main__': wpath.chdir(__file__) daemon = wireless = wired = lost_dbus_id = None DBUS_AVAIL = False theme = gtk.icon_theme_get_default() theme.append_search_path(wpath.images) def catchdbus(func): """ Decorator to catch DBus exceptions. """ def wrapper(*args, **kwargs): try: return func(*args, **kwargs) except DBusException as e: if e.get_dbus_name() is not None and \