Beispiel #1
0
    def on_load(self, container):

        self.Builder = Gtk.Builder()
        self.Builder.set_translation_domain("blueman")
        bind_textdomain_codeset("blueman", "UTF-8")
        self.Builder.add_from_file(UI_PATH + "/services-network.ui")
        self.widget = self.Builder.get_object("network_frame")

        container.pack_start(self.widget, True, True, 0)

        self.interfaces: List[Tuple[str, ipaddress.IPv4Interface]] = []
        netifs = get_local_interfaces()
        for iface in netifs:
            if iface != "lo" and iface != "pan1":
                logging.info(iface)
                ipiface = ipaddress.ip_interface('/'.join(
                    cast(Tuple[str, str], netifs[iface])))
                self.interfaces.append((iface, ipiface))

        self.setup_network()
        try:
            self.ip_check()
        except (ValueError, ipaddress.AddressValueError) as e:
            logging.exception(e)
        return _("Network"), "network-workgroup"
Beispiel #2
0
    def _check_client(self):
        netifs = get_local_interfaces()
        status = self._client.poll()
        if status == 0:

            def complete():
                ip = netifs[self._interface][0]
                logging.info(f"bound to {ip}")
                self.emit("connected", ip)

            GLib.timeout_add(1000, complete)
            DhcpClient.quering.remove(self._interface)
            return False
        elif status:
            logging.error(f"dhcp client failed with status code {status}")
            self.emit("error-occurred", status)
            DhcpClient.quering.remove(self._interface)
            return False
        else:
            return True
Beispiel #3
0
    def on_load(self, container: Gtk.Box) -> None:

        self._builder = Builder("services-network.ui")
        self.widget = self._builder.get_widget("network_frame", Gtk.Widget)

        container.pack_start(self.widget, True, True, 0)

        self.interfaces: List[Tuple[str, ipaddress.IPv4Interface]] = []
        netifs = get_local_interfaces()
        for iface in netifs:
            if iface != "lo" and iface != "pan1":
                logging.info(iface)
                ipiface = ipaddress.ip_interface('/'.join(
                    cast(Tuple[str, str], netifs[iface])))
                self.interfaces.append((iface, ipiface))

        self.setup_network()
        try:
            self.ip_check()
        except (ValueError, ipaddress.AddressValueError) as e:
            logging.exception(e)