def dhcp_acquire(self, device): if device not in self.quering: self.quering.append(device) else: return if device != "": def reply(_obj, result, _user_data): logging.info(result) Notification(_("Bluetooth Network"), _("Interface %(0)s bound to IP address %(1)s") % {"0": device, "1": result}, icon_name="network-workgroup", pos_hint=self.Applet.Plugins.StatusIcon.geometry).show() self.quering.remove(device) def err(_obj, result, _user_data): logging.warning(result) Notification(_("Bluetooth Network"), _("Failed to obtain an IP address on %s") % (device), icon_name="network-workgroup", pos_hint=self.Applet.Plugins.StatusIcon.geometry).show() self.quering.remove(device) Notification(_("Bluetooth Network"), _("Trying to obtain an IP address on %s\nPlease wait..." % device), icon_name="network-workgroup", pos_hint=self.Applet.Plugins.StatusIcon.geometry).show() m = Mechanism() m.DhcpClient(str('(s)'), device, result_handler=reply, error_handler=err, timeout=120)
def dhcp_acquire(self, device): if device not in self.quering: self.quering.append(device) else: return if device != "": def reply(ip_address): Notification(_("Bluetooth Network"), _("Interface %(0)s bound to IP address %(1)s") % { "0": device, "1": ip_address }, pixbuf=get_icon("gtk-network", 48), status_icon=self.Applet.Plugins.StatusIcon) self.quering.remove(device) def err(msg): dprint(msg) Notification(_("Bluetooth Network"), _("Failed to obtain an IP address on %s") % (device), pixbuf=get_icon("gtk-network", 48), status_icon=self.Applet.Plugins.StatusIcon) self.quering.remove(device) Notification( _("Bluetooth Network"), _("Trying to obtain an IP address on %s\nPlease wait..." % device), pixbuf=get_icon("gtk-network", 48), status_icon=self.Applet.Plugins.StatusIcon) m = Mechanism() m.DhcpClient(device, reply_handler=reply, error_handler=err, timeout=120)