def __init__(self, object_path, object_interface, service_name="org.freedesktop.NetworkManager", bus=nm_bus): gobject.GObject.__init__(self) self.bus = bus self.service_name = service_name if not is_dbus_name_exists(service_name, False): raise InvalidService(service_name) if valid_object_path(object_path): self.object_path = object_path else: raise InvalidObjectPath(object_path) if valid_object_interface(object_interface): self.object_interface = object_interface else: raise InvalidObjectInterface(object_interface) try: self.dbus_proxy = self.bus.get_object(service_name, object_path) self.dbus_interface = dbus.Interface(self.dbus_proxy, object_interface) except dbus.exceptions.DBusException: traceback.print_exc()
def new_object(self, path): if valid_object_path(path): key = path.split("/")[-2] else: raise NewObjectFailed(path) if path in self.cache_dict.iterkeys(): return self.cache_dict[path] elif key == "Settings": try: from nm_remote_connection import NMRemoteConnection remote_connection = NMRemoteConnection(path) if remote_connection: return remote_connection else: raise NewObjectFailed(path) except NewObjectFailed, e: print "create object:%s failed" % e.path except:
def __init__(self, object_path, object_interface, service_name = "org.freedesktop.NetworkManager", bus = nm_bus): gobject.GObject.__init__(self) self.bus = bus self.service_name = service_name if not is_dbus_name_exists(service_name, False): raise InvalidService(service_name) if valid_object_path(object_path): self.object_path = object_path else: raise InvalidObjectPath(object_path) if valid_object_interface(object_interface): self.object_interface = object_interface else: raise InvalidObjectInterface(object_interface) try: self.dbus_proxy = self.bus.get_object (service_name, object_path) self.dbus_interface = dbus.Interface (self.dbus_proxy, object_interface) except dbus.exceptions.DBusException: traceback.print_exc()