def wpa_status_changed(self, status):
     """
     Handles wpa status changes. Initializes backend server if a connection is made.
     :param status: status message
     :return: None
     """
     LoggerGui.debug("Wpa changed status to %s", status)
     self.label_wpa_status.config(text=status)
     if status == WpaSupplicant.CONNECTED:
         LoggerGui.debug("Routing")
         InterfaceUtil.dhclient(self.wii_u_interface)
         InterfaceUtil.set_metric(self.normal_interface, 0)
         InterfaceUtil.set_metric(self.wii_u_interface, 1)
         LoggerGui.debug("Starting backend")
         self.drc_sim_c = DrcSimC()
         self.drc_sim_c.add_status_change_listener(
             self.backend_status_changed)
         self.drc_sim_c.set_region(self.dropdown_region.get())
         self.drc_sim_c.start()
         self.label_interface_info.config(
             text="Server IP: " +
             InterfaceUtil.get_ip(self.normal_interface) + "\n" +
             os.uname()[1])
     elif status in (WpaSupplicant.DISCONNECTED, WpaSupplicant.TERMINATED):
         self.stop_server()
     elif status == WpaSupplicant.NOT_FOUND:
         self.stop_server()
         messagebox.showerror("Scan Error", "No Wii U found.")
     elif status == WpaSupplicant.FAILED_START:
         self.stop_server()
         messagebox.showerror(
             "Cannot Connect",
             "Failed to start wpa_supplicant_drc. This could mean there is a "
             "configuration error or wpa_supplicant_drc is not installed. "
             "Check %s for details." % constants.PATH_LOG_WPA)
Beispiel #2
0
 def run_server(self):
     LoggerCli.info("Starting server")
     normal_interface = Args.args.normal_interface
     wii_u_interface = Args.args.wii_u_interface
     self.check_interfaces(normal_interface, wii_u_interface)
     self.prompt_unmanaged(wii_u_interface)
     self.wpa_supplicant = WpaSupplicant()
     self.wpa_supplicant.connect(constants.PATH_CONF_CONNECT,
                                 wii_u_interface)
     self.wpa_supplicant.add_status_change_listener(self.status_changed)
     InterfaceUtil.dhclient(wii_u_interface)
     InterfaceUtil.set_metric(normal_interface, 0)
     InterfaceUtil.set_metric(wii_u_interface, 1)
     self.drc_sim_c = DrcSimC()
     self.drc_sim_c.set_region(Args.args.region)
     self.drc_sim_c.add_status_change_listener(
         self.drc_sim_c_status_changed)
     self.drc_sim_c.start()
     while self.drc_sim_c.running:
         time.sleep(1)