def getNetworkList(self): if self.oldInterfaceState is None: self.oldInterfaceState = iNetwork.getAdapterAttribute( self.iface, "up") if self.oldInterfaceState is False: if iNetwork.getAdapterAttribute(self.iface, "up") is False: iNetwork.setAdapterAttribute(self.iface, "up", True) Console().ePopen( ["/sbin/ifconfig", "/sbin/ifconfig", self.iface, "up"]) driver = iNetwork.detectWlanModule(self.iface) if driver == "brcm-wl": Console().ePopen(["/usr/bin/wl", "/usr/bin/wl", "up"]) try: scanResults = list(Cell.all(self.iface, 5)) print("[Wlan] Scan results = '%s'." % scanResults) except Exception: scanResults = None print("[Wlan] No wireless networks could be found.") aps = {} if scanResults: for i in range(len(scanResults)): bssid = scanResults[i].ssid aps[bssid] = { "active": True, "bssid": scanResults[i].ssid, "essid": scanResults[i].ssid, "channel": scanResults[i].channel, "encrypted": scanResults[i].encrypted, "encryption_type": scanResults[i].encryption_type if scanResults[i].encrypted else "none", "iface": self.iface, "maxrate": scanResults[i].bitrates, "mode": scanResults[i].mode, "quality": scanResults[i].quality, "signal": scanResults[i].signal, "frequency": scanResults[i].frequency, "frequency_norm": scanResults[i].frequency_norm, "address": scanResults[i].address, "noise": scanResults[i].noise, "pairwise_ciphers": scanResults[i].pairwise_ciphers, "authentication_suites": scanResults[i].authentication_suites, } return aps
def stopGetNetworkList(self): if self.oldInterfaceState is not None: if self.oldInterfaceState is False: iNetwork.setAdapterAttribute(self.iface, "up", False) system("ifconfig "+self.iface+" down") self.oldInterfaceState = None self.iface = None
def stopGetNetworkList(self): if self.oldInterfaceState is not None: if self.oldInterfaceState is False: iNetwork.setAdapterAttribute(self.iface, "up", False) enigma.eConsoleAppContainer().execute("ifconfig %s down" % self.iface) self.oldInterfaceState = None self.iface = None
def stopGetNetworkList(self): if self.oldInterfaceState is not None: if self.oldInterfaceState is False: iNetwork.setAdapterAttribute(self.iface, "up", False) system("ifconfig " + self.iface + " down") self.oldInterfaceState = None self.iface = None
def getNetworkList(self): if self.oldInterfaceState is None: self.oldInterfaceState = iNetwork.getAdapterAttribute( self.iface, "up") if self.oldInterfaceState is False: if iNetwork.getAdapterAttribute(self.iface, "up") is False: iNetwork.setAdapterAttribute(self.iface, "up", True) system("ifconfig " + self.iface + " up") if existBcmWifi(self.iface): eConsoleAppContainer().execute("wl up") aps = {} try: scanresults = list(Cell.all(self.iface, 5)) print("[Wlan.py] scanresults1 = %s" % scanresults) except: scanresults = None print("[Wlan.py] No wireless networks could be found") if scanresults is not None: for i in range(len(scanresults)): bssid = scanresults[i].ssid aps[bssid] = { 'active': True, 'bssid': scanresults[i].ssid, 'essid': scanresults[i].ssid, 'channel': scanresults[i].channel, 'encrypted': scanresults[i].encrypted, 'encryption_type': scanresults[i].encryption_type if scanresults[i].encrypted else "n/a", 'iface': self.iface, 'maxrate': scanresults[i].bitrates, 'mode': scanresults[i].mode, 'quality': scanresults[i].quality, 'signal': scanresults[i].signal, 'frequency': scanresults[i].frequency, 'frequency_norm': scanresults[i].frequency_norm, 'address': scanresults[i].address, 'noise': scanresults[i].noise, 'pairwise_ciphers': scanresults[i].pairwise_ciphers, 'authentication_suites': scanresults[i].authentication_suites, } print("[Wlan.py] apsresults1 = %s" % aps) return aps
def getNetworkList(self): if self.oldInterfaceState is None: self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up") if self.oldInterfaceState is False: if iNetwork.getAdapterAttribute(self.iface, "up") is False: iNetwork.setAdapterAttribute(self.iface, "up", True) system("ifconfig "+self.iface+" up") ifobj = Wireless(self.iface) # a Wireless NIC Object try: scanresults = ifobj.scan() except: scanresults = None print "[Wlan.py] No wireless networks could be found" aps = {} if scanresults is not None: (num_channels, frequencies) = ifobj.getChannelInfo() index = 1 for result in scanresults: bssid = result.bssid if result.encode.flags & wififlags.IW_ENCODE_DISABLED > 0: encryption = False elif result.encode.flags & wififlags.IW_ENCODE_NOKEY > 0: encryption = True else: encryption = None signal = str(result.quality.siglevel-0x100) + " dBm" quality = "%s/%s" % (result.quality.quality,ifobj.getQualityMax().quality) extra = [] for element in result.custom: element = element.encode() extra.append( strip(self.asciify(element)) ) for element in extra: if 'SignalStrength' in element: signal = element[element.index('SignalStrength')+15:element.index(',L')] if 'LinkQuality' in element: quality = element[element.index('LinkQuality')+12:len(element)] # noinspection PyProtectedMember aps[bssid] = { 'active' : True, 'bssid': result.bssid, 'channel': frequencies.index(ifobj._formatFrequency(result.frequency.getFrequency())) + 1, 'encrypted': encryption, 'essid': strip(self.asciify(result.essid)), 'iface': self.iface, 'maxrate' : ifobj._formatBitrate(result.rate[-1][-1]), 'noise' : '',#result.quality.nlevel-0x100, 'quality' : str(quality), 'signal' : str(signal), 'custom' : extra, } index += 1 return aps
def getNetworkList(self): if self.oldInterfaceState is None: self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up") if self.oldInterfaceState is False: if iNetwork.getAdapterAttribute(self.iface, "up") is False: iNetwork.setAdapterAttribute(self.iface, "up", True) enigma.eConsoleAppContainer().execute("ifconfig %s up" % self.iface) ifobj = Wireless(self.iface) # a Wireless NIC Object try: scanresults = ifobj.scan() except: scanresults = None print "[Wlan.py] No wireless networks could be found" aps = {} if scanresults is not None: (num_channels, frequencies) = ifobj.getChannelInfo() index = 1 for result in scanresults: bssid = result.bssid if result.encode.flags & wififlags.IW_ENCODE_DISABLED > 0: encryption = False elif result.encode.flags & wififlags.IW_ENCODE_NOKEY > 0: encryption = True else: encryption = None signal = str(result.quality.siglevel-0x100) + " dBm" quality = "%s/%s" % (result.quality.quality,ifobj.getQualityMax().quality) extra = [] for element in result.custom: element = element.encode() extra.append( strip(self.asciify(element)) ) for element in extra: if 'SignalStrength' in element: signal = element[element.index('SignalStrength')+15:element.index(',L')] if 'LinkQuality' in element: quality = element[element.index('LinkQuality')+12:len(element)] # noinspection PyProtectedMember aps[bssid] = { 'active' : True, 'bssid': result.bssid, 'channel': frequencies.index(ifobj._formatFrequency(result.frequency.getFrequency())) + 1, 'encrypted': encryption, 'essid': strip(self.asciify(result.essid)), 'iface': self.iface, 'maxrate' : ifobj._formatBitrate(result.rate[-1][-1]), 'noise' : '',#result.quality.nlevel-0x100, 'quality' : str(quality), 'signal' : str(signal), 'custom' : extra, } index += 1 return aps
def getNetworkList(self): if self.oldInterfaceState is None: self.oldInterfaceState = iNetwork.getAdapterAttribute(self.iface, "up") if self.oldInterfaceState is False: if iNetwork.getAdapterAttribute(self.iface, "up") is False: iNetwork.setAdapterAttribute(self.iface, "up", True) system("ifconfig " + self.iface + " up") ifobj = Wireless(self.iface) # a Wireless NIC Object try: scanresults = ifobj.scan() except: scanresults = None print "[Wlan.py] No wireless networks could be found" aps = {} if scanresults is not None: (num_channels, frequencies) = ifobj.getChannelInfo() index = 1 for result in scanresults: bssid = result.bssid if result.encode.flags & wififlags.IW_ENCODE_DISABLED > 0: encryption = False elif result.encode.flags & wififlags.IW_ENCODE_NOKEY > 0: encryption = True else: encryption = None signal = str(result.quality.siglevel - 0x100) + " dBm" quality = "%s/%s" % (result.quality.quality, ifobj.getQualityMax().quality) extra = [] for element in result.custom: element = element.encode() extra.append(strip(self.asciify(element))) for element in extra: if "SignalStrength" in element: signal = element[element.index("SignalStrength") + 15 : element.index(",L")] if "LinkQuality" in element: quality = element[element.index("LinkQuality") + 12 : len(element)] # noinspection PyProtectedMember aps[bssid] = { "active": True, "bssid": result.bssid, "channel": frequencies.index(ifobj._formatFrequency(result.frequency.getFrequency())) + 1, "encrypted": encryption, "essid": strip(self.asciify(result.essid)), "iface": self.iface, "maxrate": ifobj._formatBitrate(result.rate[-1][-1]), "noise": "", # result.quality.nlevel-0x100, "quality": str(quality), "signal": str(signal), "custom": extra, } index += 1 return aps
def cancel(self): if self.oldInterfaceState is False: iNetwork.setAdapterAttribute(self.iface, "up", False) iNetwork.deactivateInterface(self.iface,self.deactivateInterfaceCB) else: self.rescanTimer.stop() del self.rescanTimer self.close(None)
def stopGetNetworkList(self): if self.oldInterfaceState is not None: if self.oldInterfaceState is False: iNetwork.setAdapterAttribute(self.iface, "up", False) system("ifconfig "+self.iface+" down") if existBcmWifi(self.iface): eConsoleAppContainer().execute("wl down") self.oldInterfaceState = None self.iface = None
def stopGetNetworkList(self): if self.oldInterfaceState is not None: if self.oldInterfaceState is False: iNetwork.setAdapterAttribute(self.iface, "up", False) system("ifconfig " + self.iface + " down") if iNetwork.detectWlanModule(self.iface) == 'wl': system("wl down") self.oldInterfaceState = None self.iface = None
def stopGetNetworkList(self): if self.oldInterfaceState is not None: if self.oldInterfaceState is False: iNetwork.setAdapterAttribute(self.iface, "up", False) system("ifconfig " + self.iface + " down") if existBcmWifi(self.iface): eConsoleAppContainer().execute("wl down") self.oldInterfaceState = None self.iface = None
def deActivateIface(self): if self.oldInterfaceState is not True: os.system("ifconfig " + self.iface + " down") iNetwork.setAdapterAttribute(self.iface, "up", False) if iNetwork.useWlCommand(self.iface): os.system("wl down") self.oldInterfaceState = None
def stopGetNetworkList(self): if self.oldInterfaceState is not None: if self.oldInterfaceState is False: iNetwork.setAdapterAttribute(self.iface, "up", False) enigma.eConsoleAppContainer().execute("ifconfig %s down" % self.iface) driver = iNetwork.detectWlanModule(self.iface) if driver in ('brcm-wl', ): system("wl down") self.oldInterfaceState = None self.iface = None
def secondIfaceFoundCB(self,data): if data is False: self.applyConfig(True) else: configuredInterfaces = iNetwork.getConfiguredAdapters() for interface in configuredInterfaces: if interface == self.iface: continue iNetwork.setAdapterAttribute(interface, "up", False) iNetwork.deactivateInterface(configuredInterfaces,self.deactivateSecondInterfaceCB)
def stopGetNetworkList(self): if self.oldInterfaceState is not None: if self.oldInterfaceState is False: iNetwork.setAdapterAttribute(self.iface, "up", False) system("ifconfig "+self.iface+" down") driver = iNetwork.detectWlanModule(self.iface) if driver in ('brcm-wl', ): system("wl down") self.oldInterfaceState = None self.iface = None
def getNetworkList(self): if self.oldInterfaceState is None: self.oldInterfaceState = iNetwork.getAdapterAttribute( self.iface, "up") if self.oldInterfaceState is False: if iNetwork.getAdapterAttribute(self.iface, "up") is False: iNetwork.setAdapterAttribute(self.iface, "up", True) system("ifconfig " + self.iface + " up") driver = iNetwork.detectWlanModule(self.iface) if driver in ('brcm-wl', ): system("wl up") scanresults = list(Cell.all(self.iface)) aps = {} if scanresults is not None: for i in range(len(scanresults)): bssid = scanresults[i].ssid aps[bssid] = { 'active': True, 'bssid': scanresults[i].ssid, 'essid': scanresults[i].ssid, 'channel': scanresults[i].channel, 'encrypted': scanresults[i].encrypted, 'encryption_type': scanresults[i].encryption_type if scanresults[i].encrypted else "none", 'iface': self.iface, 'maxrate': scanresults[i].bitrates, 'mode': scanresults[i].mode, 'quality': scanresults[i].quality, 'signal': scanresults[i].signal, 'frequency': scanresults[i].frequency, 'frequency_norm': scanresults[i].frequency_norm, 'address': scanresults[i].address, 'noise': scanresults[i].noise, 'pairwise_ciphers': scanresults[i].pairwise_ciphers, 'authentication_suites': scanresults[i].authentication_suites, } return aps
def stopGetNetworkList(self): if self.oldInterfaceState is not None: if self.oldInterfaceState is False: iNetwork.setAdapterAttribute(self.iface, "up", False) Console().ePopen( ["/sbin/ifconfig", "/sbin/ifconfig", self.iface, "down"]) driver = iNetwork.detectWlanModule(self.iface) if driver == "brcm-wl": Console().ePopen(["/usr/bin/wl", "/usr/bin/wl", "down"]) self.oldInterfaceState = None self.iface = None
def activateIface(self): if self.oldInterfaceState is None: self.oldInterfaceState = iNetwork.getAdapterAttribute( self.iface, "up") if self.oldInterfaceState is not True: os.system("ifconfig " + self.iface + " up") iNetwork.setAdapterAttribute(self.iface, "up", True) if iNetwork.useWlCommand(self.iface): os.system("wl up")
def cbConfirmDone(self, ret): if not ret: return if self["key_green"].getText() == 'Connect': networkAdapters = iNetwork.getConfiguredAdapters() for x in networkAdapters: if x[:3] == 'ppp': continue iNetwork.setAdapterAttribute(x, "up", False) iNetwork.deactivateInterface(x) x = {} try: x = self["menulist"].getCurrent()[1] except: printInfoModemMgr('no selected device..') return devFile = '/usr/share/usb_modeswitch/%s:%s' % (x.get("Vendor"), x.get("ProdID")) if not os.path.exists(devFile): message = "Can't found device file!! [%s]" % (devFile) printInfoModemMgr(message) self.session.open(MessageBox, _(message), MessageBox.TYPE_INFO) return if self["key_green"].getText() == 'Disconnect': cmd = "%s -s 0" % (self.commandBin) self.taskManager.append(cmd, self.cbPrintAvail, self.cbPrintClose) cmd = "%s -s 1" % (self.commandBin) self.taskManager.append(cmd, self.cbPrintAvail, self.cbUnloadClose) self.taskManager.setStatusCB(self.setDisconnectStatus) else: cmd = "%s -s 2 -e vendor=0x%s -e product=0x%s" % ( self.commandBin, x.get("Vendor"), x.get("ProdID")) self.taskManager.append(cmd, self.cbStep1PrintAvail, self.cbPrintClose) cmd = "%s -s 3 -e %s:%s" % (self.commandBin, x.get("Vendor"), x.get("ProdID")) self.taskManager.append(cmd, self.cbPrintAvail, self.cbPrintClose) cmd = "%s -s 4" % (self.commandBin) self.taskManager.append(cmd, self.cbStep3PrintAvail, self.cbMakeWvDialClose) cmd = "%s -s 5" % (self.commandBin) self.taskManager.append(cmd, self.cbRunWvDialAvail, self.cbPrintClose) self.taskManager.setStatusCB(self.setConnectStatus) self.taskManager.next()
def msgClosed(ret): if ret: from os import system, _exit system("rm -rf /etc/enigma2") system("rm -rf /etc/network/interfaces") system("rm -rf /etc/wpa_supplicant.ath0.conf") system("rm -rf /etc/wpa_supplicant.wlan0.conf") system("rm -rf /etc/wpa_supplicant.conf") system("cp -a /usr/share/enigma2/defaults /etc/enigma2") system("/usr/bin/showiframe /usr/share/backdrop.mvi") iNetwork.setAdapterAttribute("eth0", "up", True) iNetwork.setAdapterAttribute("eth0", "dhcp", True) iNetwork.activateInterface("eth0", deactivateInterfaceCB) iNetwork.writeNetworkConfig() _exit(2) # We want a full reboot to ensure new hostname is picked up
def msgClosed(ret): if ret: from os import system, _exit system("rm -rf /etc/enigma2") system("rm -rf /etc/network/interfaces") system("rm -rf /etc/wpa_supplicant.ath0.conf") system("rm -rf /etc/wpa_supplicant.wlan0.conf") system("rm -rf /etc/wpa_supplicant.conf") system("cp -a /usr/share/enigma2/defaults /etc/enigma2") system("/usr/bin/showiframe /usr/share/backdrop.mvi") iNetwork.setAdapterAttribute("eth0", "up", True) iNetwork.setAdapterAttribute("eth0", "dhcp", True) iNetwork.activateInterface("eth0", deactivateInterfaceCB) iNetwork.writeNetworkConfig() _exit( 2 ) # We want a full reboot to ensure new hostname is picked up
def cbConfirmDone(self, ret): if not ret: return if self["key_green"].getText() == 'Connect': networkAdapters = iNetwork.getConfiguredAdapters() for x in networkAdapters: if x[:3] == 'ppp': continue iNetwork.setAdapterAttribute(x, "up", False) iNetwork.deactivateInterface(x) x = {} try: x = self["menulist"].getCurrent()[1] except: printInfoModemMgr('no selected device..') return devFile = '/usr/share/usb_modeswitch/%s:%s' % (x.get("Vendor"), x.get("ProdID")) if not os.path.exists(devFile) : message = "Can't found device file!! [%s]" % (devFile) printInfoModemMgr(message) self.session.open(MessageBox, _(message), MessageBox.TYPE_INFO) return if self["key_green"].getText() == 'Disconnect': cmd = "%s -s 0" % (self.commandBin) self.taskManager.append(cmd, self.cbPrintAvail, self.cbPrintClose) cmd = "%s -s 1" % (self.commandBin) self.taskManager.append(cmd, self.cbPrintAvail, self.cbUnloadClose) self.taskManager.setStatusCB(self.setDisconnectStatus) else: cmd = "%s -s 2 -e vendor=0x%s -e product=0x%s" % (self.commandBin, x.get("Vendor"), x.get("ProdID")) self.taskManager.append(cmd, self.cbStep1PrintAvail, self.cbPrintClose) cmd = "%s -s 3 -e %s:%s" % (self.commandBin, x.get("Vendor"), x.get("ProdID")) self.taskManager.append(cmd, self.cbPrintAvail, self.cbPrintClose) cmd = "%s -s 4" % (self.commandBin) self.taskManager.append(cmd, self.cbStep3PrintAvail, self.cbMakeWvDialClose) cmd = "%s -s 5" % (self.commandBin) self.taskManager.append(cmd, self.cbRunWvDialAvail, self.cbPrintClose) self.taskManager.setStatusCB(self.setConnectStatus) self.taskManager.next()
def cancel(self): if self.oldInterfaceState is False: iNetwork.setAdapterAttribute(self.iface, "up", self.oldInterfaceState) iNetwork.deactivateInterface(self.iface) self.close()
def setValue(self, oid, value): #the first time we are called, we have to fill the bisect oid store, values are just values, no objects (we cannot call value.get) try: value.get() except: return bisectoidstore.BisectOIDStore.setValue(self, oid, value) oidstring = bisectoidstore.sortableToOID(oid) if oidstring == self.MANAGERIP_OID: if config.plugins.SnmpAgent.managerip.value <> value.get(): config.plugins.SnmpAgent.managerip.value = value.get() config.plugins.SnmpAgent.managerip.save() elif oidstring == self.ENABLE_BITRATE_OID: if config.plugins.SnmpAgent.measurebitrate.value and not value.get(): config.plugins.SnmpAgent.measurebitrate.value = False config.plugins.SnmpAgent.measurebitrate.save() if self.bitrate: self.bitrate.stop() self.bitrate = None elif not config.plugins.SnmpAgent.measurebitrate.value and value.get(): config.plugins.SnmpAgent.measurebitrate.value = True config.plugins.SnmpAgent.measurebitrate.save() self.bitrate = Bitrate(self.session) self.bitrate.start() elif oidstring == self.SYSTEMNAME_OID: if config.plugins.SnmpAgent.systemname.value <> value.get(): config.plugins.SnmpAgent.systemname.value = value.get() config.plugins.SnmpAgent.systemname.save() elif oidstring == self.SUPPORTADDRESS_OID: if config.plugins.SnmpAgent.supportaddress.value <> value.get(): config.plugins.SnmpAgent.supportaddress.value = value.get() config.plugins.SnmpAgent.supportaddress.save() elif oidstring == self.SYSTEMDESCRIPTION_OID: if config.plugins.SnmpAgent.systemdescription.value <> value.get(): config.plugins.SnmpAgent.systemdescription.value = value.get() config.plugins.SnmpAgent.systemdescription.save() elif oidstring == self.LOCATION_OID: if config.plugins.SnmpAgent.location.value <> value.get(): config.plugins.SnmpAgent.location.value = value.get() config.plugins.SnmpAgent.location.save() elif oidstring == self.CHANNELNAME_OID: if self.getChannelName() <> value.get(): root = config.tv.lastroot.value.split(';') fav = eServiceReference(root[-2]) services = ServiceList(fav, command_func=self.zapTo, validate_commands=False) sub = services.getServicesAsList() if len(sub) > 0: for (ref, name) in sub: if name == value.get(): self.zapTo(eServiceReference(ref)) break elif oidstring == self.SERVICESTRING_OID: if self.getServiceString() <> value.get(): self.zapTo(eServiceReference(value.get())) elif oidstring == self.FASTSCANSTRING_OID: refstring = '' fields = value.get().split(',') if len(fields) >= 15: onid, tsid, freq, id1, id2, sid, orbital_pos, f1, f2, f3, symbolrate, f4, name, provider, servicetype = fields[0:15] refstring = '%d:%d:%d:%x:%x:%x:%x:%x:%x:%x:' % (1, 0, int(servicetype), int(sid), int(tsid), int(onid), int(orbital_pos) * 65536, 0, 0, 0) if refstring is not '': self.zapTo(eServiceReference(refstring)) elif oidstring == self.SERVICEPARAMS_OID: refstring = '' fields = value.get().split(',') if len(fields) >= 5: orbital_pos, tsid, onid, sid, servicetype = fields[0:5] refstring = '%d:%d:%d:%x:%x:%x:%x:%x:%x:%x:' % (1, 0, int(servicetype), int(sid), int(tsid), int(onid), int(orbital_pos) * 65536, 0, 0, 0) if refstring is not '': self.zapTo(eServiceReference(refstring)) elif oidstring == self.IP_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "ip") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "ip", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.IP_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "netmask") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "netmask", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.GATEWAY_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "gateway") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "gateway", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.ENABLE_EMM_OID: if config.plugins.SnmpAgent.checkemm.value and not value.get(): config.plugins.SnmpAgent.checkemm.value = False config.plugins.SnmpAgent.checkemm.save() if self.emm: self.emm.stop() self.emm = None elif not config.plugins.SnmpAgent.checkemm.value and value.get(): config.plugins.SnmpAgent.checkemm.value = True config.plugins.SnmpAgent.checkemm.save() self.emm = Emm(self.session) self.emm.start() else: print "oid not found!?" return None
def setValue(self, oid, value): #the first time we are called, we have to fill the bisect oid store, values are just values, no objects (we cannot call value.get) try: value.get() except: return bisectoidstore.BisectOIDStore.setValue(self, oid, value) oidstring = bisectoidstore.sortableToOID(oid) if oidstring == self.MANAGERIP_OID: if config.plugins.SnmpAgent.managerip.value <> value.get(): config.plugins.SnmpAgent.managerip.value = value.get() config.plugins.SnmpAgent.managerip.save() elif oidstring == self.ENABLE_BITRATE_OID: if config.plugins.SnmpAgent.measurebitrate.value and not value.get( ): config.plugins.SnmpAgent.measurebitrate.value = False config.plugins.SnmpAgent.measurebitrate.save() if self.bitrate: self.bitrate.stop() self.bitrate = None elif not config.plugins.SnmpAgent.measurebitrate.value and value.get( ): config.plugins.SnmpAgent.measurebitrate.value = True config.plugins.SnmpAgent.measurebitrate.save() self.bitrate = Bitrate(self.session) self.bitrate.start() elif oidstring == self.SYSTEMNAME_OID: if config.plugins.SnmpAgent.systemname.value <> value.get(): config.plugins.SnmpAgent.systemname.value = value.get() config.plugins.SnmpAgent.systemname.save() elif oidstring == self.SUPPORTADDRESS_OID: if config.plugins.SnmpAgent.supportaddress.value <> value.get(): config.plugins.SnmpAgent.supportaddress.value = value.get() config.plugins.SnmpAgent.supportaddress.save() elif oidstring == self.SYSTEMDESCRIPTION_OID: if config.plugins.SnmpAgent.systemdescription.value <> value.get(): config.plugins.SnmpAgent.systemdescription.value = value.get() config.plugins.SnmpAgent.systemdescription.save() elif oidstring == self.LOCATION_OID: if config.plugins.SnmpAgent.location.value <> value.get(): config.plugins.SnmpAgent.location.value = value.get() config.plugins.SnmpAgent.location.save() elif oidstring == self.CHANNELNAME_OID: if self.getChannelName() <> value.get(): root = config.tv.lastroot.value.split(';') fav = eServiceReference(root[-2]) services = ServiceList(fav, command_func=self.zapTo, validate_commands=False) sub = services.getServicesAsList() if len(sub) > 0: for (ref, name) in sub: if name == value.get(): self.zapTo(eServiceReference(ref)) break elif oidstring == self.SERVICESTRING_OID: if self.getServiceString() <> value.get(): self.zapTo(eServiceReference(value.get())) elif oidstring == self.FASTSCANSTRING_OID: refstring = '' fields = value.get().split(',') if len(fields) >= 15: onid, tsid, freq, id1, id2, sid, orbital_pos, f1, f2, f3, symbolrate, f4, name, provider, servicetype = fields[ 0:15] refstring = '%d:%d:%d:%x:%x:%x:%x:%x:%x:%x:' % ( 1, 0, int(servicetype), int(sid), int(tsid), int(onid), int(orbital_pos) * 65536, 0, 0, 0) if refstring is not '': self.zapTo(eServiceReference(refstring)) elif oidstring == self.SERVICEPARAMS_OID: refstring = '' fields = value.get().split(',') if len(fields) >= 5: orbital_pos, tsid, onid, sid, servicetype = fields[0:5] refstring = '%d:%d:%d:%x:%x:%x:%x:%x:%x:%x:' % ( 1, 0, int(servicetype), int(sid), int(tsid), int(onid), int(orbital_pos) * 65536, 0, 0, 0) if refstring is not '': self.zapTo(eServiceReference(refstring)) elif oidstring == self.IP_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "ip") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "ip", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.IP_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "netmask") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "netmask", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.GATEWAY_OID: ipstring = value.get().split('.') ipval = [] for x in ipstring: ipval.append(int(x)) if iNetwork.getAdapterAttribute(self.iface, "gateway") <> ipval: iNetwork.setAdapterAttribute(self.iface, "dhcp", 0) iNetwork.setAdapterAttribute(self.iface, "gateway", ipval) iNetwork.deactivateNetworkConfig() iNetwork.writeNetworkConfig() iNetwork.activateNetworkConfig() elif oidstring == self.ENABLE_EMM_OID: if config.plugins.SnmpAgent.checkemm.value and not value.get(): config.plugins.SnmpAgent.checkemm.value = False config.plugins.SnmpAgent.checkemm.save() if self.emm: self.emm.stop() self.emm = None elif not config.plugins.SnmpAgent.checkemm.value and value.get(): config.plugins.SnmpAgent.checkemm.value = True config.plugins.SnmpAgent.checkemm.save() self.emm = Emm(self.session) self.emm.start() else: print "oid not found!?" return None
def applyConfig(self, ret = False): if ret: self.applyConfigRef = None iNetwork.setAdapterAttribute(self.iface, "up", self.activateInterfaceEntry.value) iNetwork.setAdapterAttribute(self.iface, "dhcp", self.dhcpConfigEntry.value) iNetwork.setAdapterAttribute(self.iface, "ip", self.ipConfigEntry.value) iNetwork.setAdapterAttribute(self.iface, "netmask", self.netmaskConfigEntry.value) if self.hasGatewayConfigEntry.value: iNetwork.setAdapterAttribute(self.iface, "gateway", self.gatewayConfigEntry.value) else: iNetwork.removeAdapterAttribute(self.iface, "gateway") if self.extended is not None and self.configStrings is not None: iNetwork.setAdapterAttribute(self.iface, "configStrings", self.configStrings(self.iface)) self.ws.writeConfig(self.iface) if self.activateInterfaceEntry.value is False: iNetwork.deactivateInterface(self.iface,self.deactivateInterfaceCB) iNetwork.writeNetworkConfig() self.applyConfigRef = self.session.openWithCallback(self.applyConfigfinishedCB, MessageBox, _("Please wait for activation of your network configuration..."), type = MessageBox.TYPE_INFO, enable_input = False) else: if self.oldInterfaceState is False: iNetwork.activateInterface(self.iface,self.deactivateInterfaceCB) else: iNetwork.deactivateInterface(self.iface,self.activateInterfaceCB) iNetwork.writeNetworkConfig() 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.keyCancel()
def cbConfirmDone(self, ret): if not ret: return if self["key_green"].getText() == 'Connect': networkAdapters = iNetwork.getConfiguredAdapters() for x in networkAdapters: if x[:3] == 'ppp': continue iNetwork.setAdapterAttribute(x, "up", False) iNetwork.deactivateInterface(x) x = {} try: x = self["menulist"].getCurrent()[1] except: printInfoModemMgr('no selected device..') return devFile = '/usr/share/usb_modeswitch/%s:%s' % (x.get("Vendor"), x.get("ProdID")) if not os.path.exists(devFile) : message = "Can't found device file!! [%s]" % (devFile) printInfoModemMgr(message) #self.session.open(MessageBox, _(message), MessageBox.TYPE_INFO) return if self["key_green"].getText() == 'Disconnect': cmd = "%s 0" % (commandBin) self.taskManager.append(cmd, self.cbPrintAvail, self.cbPrintClose) cmd = "%s 1" % (commandBin) self.taskManager.append(cmd, self.cbPrintAvail, self.cbUnloadClose) self.taskManager.setStatusCB(self.setDisconnectStatus) self['myip'].setText(_('IP : 0.0.0.0')) # After Disconnect turn on all adapters and restart network networkAdapters = iNetwork.getConfiguredAdapters() for x in networkAdapters: iNetwork.setAdapterAttribute(x, "up", True) iNetwork.activateInterface(x) iNetwork.restartNetwork() else: cmd = "%s 2 vendor=0x%s product=0x%s" % (commandBin, x.get("Vendor"), x.get("ProdID")) self.taskManager.append(cmd, self.cbStep1PrintAvail, self.cbPrintClose) cmd = "%s 3 %s %s" % (commandBin, x.get("Vendor"), x.get("ProdID")) # do not save new vendor id and product id changed by usb-switchmode, use only 1st ones ( when no /dev/ttyUSB0 ) - it appears ONLY when it is switched to GSM MODE if not fileExists("/dev/ttyUSB0"): # SAVE Current Connection vendor and product ids for future Auto-Connect mode config.plugins.gmodemmanager.vendorid.setValue(x.get("Vendor")) config.plugins.gmodemmanager.productid.setValue(x.get("ProdID")) config.plugins.gmodemmanager.vendorid.save() config.plugins.gmodemmanager.productid.save() self.taskManager.append(cmd, self.cbPrintAvail, self.cbPrintClose) cmd = "%s 4" % (commandBin) self.taskManager.append(cmd, self.cbStep3PrintAvail, self.cbMakeWvDialClose) cmd = "%s 5" % (commandBin) self.taskManager.append(cmd, self.cbRunWvDialAvail, self.cbPrintClose) self.taskManager.setStatusCB(self.setConnectStatus) self.taskManager.next()
def getNetworkList(self): if self.oldInterfaceState is None: self.oldInterfaceState = iNetwork.getAdapterAttribute( self.iface, "up") if self.oldInterfaceState is False: if iNetwork.getAdapterAttribute(self.iface, "up") is False: iNetwork.setAdapterAttribute(self.iface, "up", True) enigma.eConsoleAppContainer().execute("ifconfig %s up" % self.iface) if existBcmWifi(self.iface): enigma.eConsoleAppContainer().execute("wl up") ifobj = Wireless(self.iface) # a Wireless NIC Object try: scanresults = ifobj.scan() except: scanresults = None print("[WirelessLan] No wireless networks could be found") aps = {} if scanresults is not None: (num_channels, frequencies) = ifobj.getChannelInfo() index = 1 for result in scanresults: bssid = result.bssid # skip hidden networks if not result.essid: continue if result.encode.flags & wififlags.IW_ENCODE_DISABLED > 0: encryption = False elif result.encode.flags & wififlags.IW_ENCODE_NOKEY > 0: encryption = True else: encryption = None signal = str(result.quality.siglevel - 0x100) + " dBm" quality = "%s/%s" % (result.quality.quality, ifobj.getQualityMax().quality) extra = [] for element in result.custom: element = element.encode() extra.append(strip(self.asciify(element))) for element in extra: if 'SignalStrength' in element: signal = element[element.index('SignalStrength') + 15:element.index(',L')] if 'LinkQuality' in element: quality = element[element.index('LinkQuality') + 12:len(element)] channel = "Unknown" try: channel = frequencies.index( ifobj._formatFrequency( result.frequency.getFrequency())) + 1 except: channel = "Unknown" aps[bssid] = { 'active': True, 'bssid': result.bssid, 'channel': channel, 'encrypted': encryption, 'essid': strip(self.asciify(result.essid)), 'iface': self.iface, 'maxrate': ifobj._formatBitrate(result.rate[-1][-1]), 'noise': '', #result.quality.nlevel-0x100, 'quality': str(quality), 'signal': str(signal), 'custom': extra, } index = index + 1 return aps