X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/56253715ea1292610ad7fc802a533a99304af8cb..7cc28be2015e4ebb56d585c9cee2949138e4d67e:/lib/python/Screens/NetworkSetup.py diff --git a/lib/python/Screens/NetworkSetup.py b/lib/python/Screens/NetworkSetup.py index 887e1674..db6b5f9c 100755 --- a/lib/python/Screens/NetworkSetup.py +++ b/lib/python/Screens/NetworkSetup.py @@ -28,8 +28,10 @@ class InterfaceList(MenuList): self.l.setItemHeight(30) def InterfaceEntryComponent(index,name,default,active ): - res = [ (index) ] - res.append(MultiContentEntryText(pos=(80, 5), size=(430, 25), font=0, text=name)) + res = [ + (index), + MultiContentEntryText(pos=(80, 5), size=(430, 25), font=0, text=name) + ] num_configured_if = len(iNetwork.getConfiguredAdapters()) if num_configured_if >= 2: if default is True: @@ -50,8 +52,8 @@ class NetworkAdapterSelection(Screen,HelpableScreen): Screen.__init__(self, session) HelpableScreen.__init__(self) - self.wlan_errortext = _("No working wireless networkadapter found.\nPlease verify that you have attached a compatible WLAN USB Stick and your Network is configured correctly.") - self.lan_errortext = _("No working local networkadapter found.\nPlease verify that you have attached a network cable and your Network is configured correctly.") + self.wlan_errortext = _("No working wireless network adapter found.\nPlease verify that you have attached a compatible WLAN device and your network is configured correctly.") + self.lan_errortext = _("No working local network adapter found.\nPlease verify that you have attached a network cable and your network is configured correctly.") self.oktext = _("Press OK on your remote control to continue.") self.restartLanRef = None @@ -62,23 +64,23 @@ class NetworkAdapterSelection(Screen,HelpableScreen): self.adapters = [(iNetwork.getFriendlyAdapterName(x),x) for x in iNetwork.getAdapterList()] - if len(self.adapters) == 0: + if not self.adapters: self.onFirstExecBegin.append(self.NetworkFallback) self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions", { - "cancel": (self.close, _("exit networkinterface list")), + "cancel": (self.close, _("exit network interface list")), "ok": (self.okbuttonClick, _("select interface")), }) self["ColorActions"] = HelpableActionMap(self, "ColorActions", { - "red": (self.close, _("exit networkinterface list")), + "red": (self.close, _("exit network interface list")), }) self["DefaultInterfaceAction"] = HelpableActionMap(self, "ColorActions", { - "blue": (self.setDefaultInterface, [_("Set interface as default Interface"),_("* Only available if more then one interface is active.")] ), + "blue": (self.setDefaultInterface, [_("Set interface as default Interface"),_("* Only available if more than one interface is active.")] ), }) self.list = [] @@ -88,9 +90,9 @@ class NetworkAdapterSelection(Screen,HelpableScreen): if len(self.adapters) == 1: self.onFirstExecBegin.append(self.okbuttonClick) self.onClose.append(self.cleanup) - + + def updateList(self): - iNetwork.getInterfaces() self.list = [] default_gw = None num_configured_if = len(iNetwork.getConfiguredAdapters()) @@ -175,6 +177,7 @@ class NetworkAdapterSelection(Screen,HelpableScreen): def cleanup(self): iNetwork.stopLinkStateConsole() iNetwork.stopRestartConsole() + iNetwork.stopGetInterfacesConsole() def restartLan(self): iNetwork.restartNetwork(self.restartLanDataAvail) @@ -220,6 +223,10 @@ class NameserverSetup(Screen, ConfigListScreen, HelpableScreen): "yellow": (self.remove, _("remove a nameserver entry")), }) + self["actions"] = NumberActionMap(["SetupActions"], + { + "ok": self.ok, + }, -2) self.list = [] ConfigListScreen.__init__(self, self.list) @@ -227,17 +234,16 @@ class NameserverSetup(Screen, ConfigListScreen, HelpableScreen): def createConfig(self): self.nameservers = iNetwork.getNameserverList() - self.nameserverEntries = [] - - for nameserver in self.nameservers: - self.nameserverEntries.append(NoSave(ConfigIP(default=nameserver))) + self.nameserverEntries = [ NoSave(ConfigIP(default=nameserver)) for nameserver in self.nameservers] def createSetup(self): self.list = [] - - for i in range(len(self.nameserverEntries)): - self.list.append(getConfigListEntry(_("Nameserver %d") % (i + 1), self.nameserverEntries[i])) - + + i = 1 + for x in self.nameserverEntries: + self.list.append(getConfigListEntry(_("Nameserver %d") % (i), x)) + i += 1 + self["config"].list = self.list self["config"].l.setList(self.list) @@ -273,36 +279,41 @@ class NameserverSetup(Screen, ConfigListScreen, HelpableScreen): self.createSetup() class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): - def __init__(self, session, iface,essid=None, aplist=None): + def __init__(self, session, networkinfo, essid=None, aplist=None): Screen.__init__(self, session) HelpableScreen.__init__(self) self.session = session - self.iface = iface - self.essid = essid - self.aplist = aplist + if isinstance(networkinfo, (list, tuple)): + self.iface = networkinfo[0] + self.essid = networkinfo[1] + self.aplist = networkinfo[2] + else: + self.iface = networkinfo + self.essid = essid + self.aplist = aplist self.extended = None self.applyConfigRef = None self.finished_cb = None self.oktext = _("Press OK on your remote control to continue.") self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up") - + self.createConfig() self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions", { - "cancel": (self.cancel, _("exit networkadapter setup menu")), + "cancel": (self.cancel, _("exit network adapter setup menu")), "ok": (self.ok, _("select menu entry")), }) self["ColorActions"] = HelpableActionMap(self, "ColorActions", { - "red": (self.cancel, _("exit networkadapter configuration")), + "red": (self.cancel, _("exit network adapter configuration")), "blue": (self.KeyBlue, _("open nameserver configuration")), }) self["VirtualKB"] = HelpableActionMap(self, "ColorActions", { - "green": (self.KeyGreen, [_("open virtual keyboard input help"),_("* Only available when entering hidden ssid or network key")] ), + "green": (self.KeyGreen, [_("open virtual keyboard input help"),_("* Only available when entering hidden SSID or network key")] ), }) self["actions"] = NumberActionMap(["SetupActions"], @@ -417,10 +428,10 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): if a['active']: if a['essid'] == "": a['essid'] = a['bssid'] - self.nwlist.append( a['essid']) + self.nwlist.append((a['essid'],a['essid'])) self.nwlist.sort(key = lambda x: x[0]) except: - self.nwlist.append("No Networks found") + self.nwlist.append(("No Networks found",_("No Networks found"))) self.wsconfig = self.ws.loadConfig() if self.essid is not None: # ssid from wlan scan @@ -429,10 +440,9 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): self.default = self.wsconfig['ssid'] if "hidden..." not in self.nwlist: - self.nwlist.append("hidden...") + self.nwlist.append(("hidden...",_("hidden network"))) if self.default not in self.nwlist: - self.nwlist.append(self.default) - + self.nwlist.append((self.default,self.default)) config.plugins.wlan.essid = NoSave(ConfigSelection(self.nwlist, default = self.default )) config.plugins.wlan.hiddenessid = NoSave(ConfigText(default = self.wsconfig['hiddenessid'], visible_width = 50, fixed_size = False)) @@ -516,7 +526,7 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): if self.iface == "wlan0" or self.iface == "ath0" : if self["config"].getCurrent() == self.hiddenSSID: if config.plugins.wlan.essid.value == 'hidden...': - self.session.openWithCallback(self.VirtualKeyBoardSSIDCallback, VirtualKeyBoard, title = (_("Enter WLAN networkname/SSID:")), text = config.plugins.wlan.essid.value) + self.session.openWithCallback(self.VirtualKeyBoardSSIDCallback, VirtualKeyBoard, title = (_("Enter WLAN network name/SSID:")), text = config.plugins.wlan.essid.value) if self["config"].getCurrent() == self.encryptionKey: self.session.openWithCallback(self.VirtualKeyBoardKeyCallback, VirtualKeyBoard, title = (_("Enter WLAN passphrase/key:")), text = config.plugins.wlan.encryption.psk.value) @@ -600,7 +610,7 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): iNetwork.deactivateInterface(self.iface) iNetwork.writeNetworkConfig() iNetwork.restartNetwork(self.applyConfigDataAvail) - self.applyConfigRef = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _("Please wait while activating your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False) + self.applyConfigRef = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _("Please wait for activation of your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False) else: self.cancel() @@ -616,10 +626,10 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): if data is True: num_configured_if = len(iNetwork.getConfiguredAdapters()) if num_configured_if >= 2: - self.session.openWithCallback(self.secondIfaceFoundCB, MessageBox, _("Your network configuration has been activated.\nA second configured interface has been found.\n\nDo you want to disable the second networkinterface?"), default = True) + self.session.openWithCallback(self.secondIfaceFoundCB, MessageBox, _("Your network configuration has been activated.\nA second configured interface has been found.\n\nDo you want to disable the second network interface?"), default = True) else: if self.finished_cb: - self.session.openWithCallback(self.finished_cb, MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10) + self.session.openWithCallback(lambda x : self.finished_cb(), MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10) else: self.session.openWithCallback(self.ConfigfinishedCB, MessageBox, _("Your network configuration has been activated."), type = MessageBox.TYPE_INFO, timeout = 10) @@ -642,15 +652,10 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): def cancel(self): if self.oldInterfaceState is False: - iNetwork.deactivateInterface(self.iface,self.deactivateInterfaceCB) + iNetwork.deactivateInterface(self.iface,self.cancelCB) else: self.close('cancel') - def deactivateInterfaceCB(self,data): - if data is not None: - if data is True: - iNetwork.getInterfaces(self.cancelCB) - def cancelCB(self,data): if data is not None: if data is True: @@ -670,8 +675,7 @@ class AdapterSetup(Screen, ConfigListScreen, HelpableScreen): def cleanup(self): iNetwork.stopLinkStateConsole() - iNetwork.stopDeactivateInterfaceConsole() - + class AdapterSetupConfiguration(Screen, HelpableScreen): def __init__(self, session,iface): @@ -695,7 +699,7 @@ class AdapterSetupConfiguration(Screen, HelpableScreen): self.oktext = _("Press OK on your remote control to continue.") self.reboottext = _("Your Dreambox will restart after pressing OK on your remote control.") - self.errortext = _("No working wireless interface found.\n Please verify that you have attached a compatible WLAN device or enable you local network interface.") + self.errortext = _("No working wireless network interface found.\n Please verify that you have attached a compatible WLAN device or enable your local network interface.") self["WizardActions"] = HelpableActionMap(self, "WizardActions", { @@ -727,7 +731,7 @@ class AdapterSetupConfiguration(Screen, HelpableScreen): "right": self.right, }, -2) - iNetwork.getInterfaces(self.updateStatusbar) + self.updateStatusbar() self.onLayoutFinish.append(self.layoutFinished) self.onClose.append(self.cleanup) @@ -903,11 +907,11 @@ class AdapterSetupConfiguration(Screen, HelpableScreen): else: self.mainmenu = self.genMainMenu() self["menulist"].l.setList(self.mainmenu) - iNetwork.getInterfaces(self.updateStatusbar) + self.updateStatusbar() else: self.mainmenu = self.genMainMenu() self["menulist"].l.setList(self.mainmenu) - iNetwork.getInterfaces(self.updateStatusbar) + self.updateStatusbar() def WlanStatusClosed(self, *ret): if ret is not None and len(ret): @@ -915,7 +919,7 @@ class AdapterSetupConfiguration(Screen, HelpableScreen): iStatus.stopWlanConsole() self.mainmenu = self.genMainMenu() self["menulist"].l.setList(self.mainmenu) - iNetwork.getInterfaces(self.updateStatusbar) + self.updateStatusbar() def WlanScanClosed(self,*ret): if ret[0] is not None: @@ -925,7 +929,7 @@ class AdapterSetupConfiguration(Screen, HelpableScreen): iStatus.stopWlanConsole() self.mainmenu = self.genMainMenu() self["menulist"].l.setList(self.mainmenu) - iNetwork.getInterfaces(self.updateStatusbar) + self.updateStatusbar() def restartLan(self, ret = False): if (ret == True): @@ -942,6 +946,7 @@ class AdapterSetupConfiguration(Screen, HelpableScreen): def restartfinishedCB(self,data): if data is True: + self.updateStatusbar() self.session.open(MessageBox, _("Finished restarting your network"), type = MessageBox.TYPE_INFO, timeout = 10, default = False) def dataAvail(self,data): @@ -950,9 +955,9 @@ class AdapterSetupConfiguration(Screen, HelpableScreen): pattern = re_compile("Link detected: yes") for item in result: if re_search(pattern, item): - self["statuspic"].setPixmapNum(1) - else: self["statuspic"].setPixmapNum(0) + else: + self["statuspic"].setPixmapNum(1) self["statuspic"].show() def showErrorMessage(self): @@ -983,7 +988,6 @@ class NetworkAdapterTest(Screen): Screen.__init__(self, session) self.iface = iface self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up") - iNetwork.getInterfaces() self.setLabels() self.onClose.append(self.cleanup) self.onHide.append(self.cleanup) @@ -1404,4 +1408,5 @@ class NetworkAdapterTest(Screen): except ImportError: pass else: - iStatus.stopWlanConsole() \ No newline at end of file + iStatus.stopWlanConsole() +