def on_apply(self): if self.on_query_apply_state() == True: dprint("network apply") m = Mechanism() nap_enable = self.Builder.get_object("nap-enable") if nap_enable.props.active: r_dnsmasq = self.Builder.get_object("r_dnsmasq") if r_dnsmasq.props.active: stype = "DnsMasqHandler" else: stype = "DhcpdHandler" net_ip = self.Builder.get_object("net_ip") net_nat = self.Builder.get_object("net_nat") try: m.EnableNetwork(inet_aton(net_ip.props.text), inet_aton("255.255.255.0"), stype) except Exception as e: d = NetworkErrorDialog(e) d.run() d.destroy() return else: m.DisableNetwork() self.clear_options()
def on_apply(self): if self.on_query_apply_state() == True: dprint("network apply") m = Mechanism() nap_enable = self.Builder.get_object("nap_enable") if nap_enable.props.active: r_dnsmasq = self.Builder.get_object("r_dnsmasq") if r_dnsmasq.props.active: stype = "DnsMasqHandler" else: stype = "DhcpdHandler" net_ip = self.Builder.get_object("net_ip") net_nat = self.Builder.get_object("net_nat") try: m.EnableNetwork(inet_aton(net_ip.props.text), inet_aton("255.255.255.0"), stype) if not self.NetConf.props.nap_enable: # race condition workaround self.ignored_keys.append("nap_enable") self.NetConf.props.nap_enable = True except Exception as e: lines = str(e).splitlines() d = Gtk.MessageDialog(None, buttons=Gtk.ButtonsType.OK, type=Gtk.MessageType.ERROR) d.props.icon_name = "dialog-error" d.props.text = _("Failed to apply network settings") d.props.secondary_text = lines[-1] d.run() d.destroy() return else: if self.NetConf.props.nap_enable: # race condition workaround self.ignored_keys.append("nap_enable") self.NetConf.props.nap_enable = False m.DisableNetwork() self.clear_options()
def on_apply(self): if self.on_query_apply_state(): logging.info("network apply") m = Mechanism() nap_enable = self.Builder.get_object("nap-enable") if nap_enable.props.active: if self.Builder.get_object("r_dhcpd").props.active: stype = "DhcpdHandler" elif self.Builder.get_object("r_dnsmasq").props.active: stype = "DnsMasqHandler" elif self.Builder.get_object("r_udhcpd").props.active: stype = "UdhcpdHandler" net_ip = self.Builder.get_object("net_ip") try: m.EnableNetwork('(ayays)', inet_aton(net_ip.props.text), inet_aton("255.255.255.0"), stype) if not self.Config["nap-enable"]: self.Config["nap-enable"] = True except Exception as e: d = ErrorDialog("<b>Failed to apply network settings</b>", excp=e, parent=self.widget.get_toplevel()) d.run() d.destroy() return else: self.Config["nap-enable"] = False m.DisableNetwork() self.clear_options()