X-Git-Url: http://code.vuplus.com/gitweb/?p=vuplus_dvbapp;a=blobdiff_plain;f=lib%2Fpython%2FComponents%2FNetwork.py;h=e8a3d459cb7638a8b9276569c40bbf1408f4d5e0;hp=f65d6090c3c8e699d901ab6778cd0ad97f2ee8a4;hb=fcb47d3f536f619b872184a7ab241be08307bf6e;hpb=7cc28be2015e4ebb56d585c9cee2949138e4d67e diff --git a/lib/python/Components/Network.py b/lib/python/Components/Network.py index f65d609..e8a3d45 100755 --- a/lib/python/Components/Network.py +++ b/lib/python/Components/Network.py @@ -14,7 +14,7 @@ class Network: self.NetworkState = 0 self.DnsState = 0 self.nameservers = [] - self.ethtool_bin = "/usr/sbin/ethtool" + self.ethtool_bin = "ethtool" self.container = eConsoleAppContainer() self.Console = Console() self.LinkConsole = Console() @@ -24,7 +24,11 @@ class Network: self.activateConsole = Console() self.resetNetworkConsole = Console() self.DnsConsole = Console() + self.PingConsole = Console() self.config_ready = None + self.friendlyNames = {} + self.lan_interfaces = [] + self.wlan_interfaces = [] self.getInterfaces() def onRemoteRootFS(self): @@ -233,7 +237,7 @@ class Network: self.configuredNetworkAdapters = self.configuredInterfaces # load ns only once self.loadNameserverConfig() - print "read configured interfac:", ifaces + print "read configured interface:", ifaces print "self.ifaces after loading:", self.ifaces self.config_ready = True self.msgPlugins() @@ -308,13 +312,47 @@ class Network: return len(self.ifaces) def getFriendlyAdapterName(self, x): - # maybe this needs to be replaced by an external list. - friendlyNames = { - "eth0": _("Integrated Ethernet"), - "wlan0": _("Wireless"), - "ath0": _("Integrated Wireless") - } - return friendlyNames.get(x, x) # when we have no friendly name, use adapter name + if x in self.friendlyNames.keys(): + return self.friendlyNames.get(x, x) + else: + self.friendlyNames[x] = self.getFriendlyAdapterNaming(x) + return self.friendlyNames.get(x, x) # when we have no friendly name, use adapter name + + def getFriendlyAdapterNaming(self, iface): + if iface.startswith('eth'): + if iface not in self.lan_interfaces and len(self.lan_interfaces) == 0: + self.lan_interfaces.append(iface) + return _("LAN connection") + elif iface not in self.lan_interfaces and len(self.lan_interfaces) >= 1: + self.lan_interfaces.append(iface) + return _("LAN connection") + " " + str(len(self.lan_interfaces)) + else: + if iface not in self.wlan_interfaces and len(self.wlan_interfaces) == 0: + self.wlan_interfaces.append(iface) + return _("WLAN connection") + elif iface not in self.wlan_interfaces and len(self.wlan_interfaces) >= 1: + self.wlan_interfaces.append(iface) + return _("WLAN connection") + " " + str(len(self.wlan_interfaces)) + + def getFriendlyAdapterDescription(self, iface): + if iface == 'eth0': + return _("Internal LAN adapter.") + else: + classdir = "/sys/class/net/" + iface + "/device/" + driverdir = "/sys/class/net/" + iface + "/device/driver/" + if os_path.exists(classdir): + files = listdir(classdir) + if 'driver' in files: + if os_path.realpath(driverdir).endswith('ath_pci'): + return _("Atheros")+ " " + str(os_path.basename(os_path.realpath(driverdir))) + " " + _("WLAN adapter.") + elif os_path.realpath(driverdir).endswith('zd1211b'): + return _("Zydas")+ " " + str(os_path.basename(os_path.realpath(driverdir))) + " " + _("WLAN adapter.") + elif os_path.realpath(driverdir).endswith('rt73'): + return _("Ralink")+ " " + str(os_path.basename(os_path.realpath(driverdir))) + " " + _("WLAN adapter.") + else: + return _("Unknown network adapter.") + else: + return _("Unknown network adapter.") def getAdapterName(self, iface): return iface @@ -424,6 +462,7 @@ class Network: def checkNetworkState(self,statecallback): # www.dream-multimedia-tv.de, www.heise.de, www.google.de + self.NetworkState = 0 cmd1 = "ping -c 1 82.149.226.170" cmd2 = "ping -c 1 193.99.144.85" cmd3 = "ping -c 1 209.85.135.103" @@ -475,10 +514,17 @@ class Network: def getLinkStateFinished(self, result, retval,extra_args): (callback) = extra_args + if self.LinkConsole is not None: if len(self.LinkConsole.appContainers) == 0: callback(result) + def stopPingConsole(self): + if self.PingConsole is not None: + if len(self.PingConsole.appContainers): + for name in self.PingConsole.appContainers.keys(): + self.PingConsole.kill(name) + def stopLinkStateConsole(self): if self.LinkConsole is not None: if len(self.LinkConsole.appContainers): @@ -571,11 +617,11 @@ class Network: self.wlanmodule = 'madwifi' if os_path.exists(rt73_dir): rtfiles = listdir(rt73_dir) - if len(rtfiles) == 2: + if len(rtfiles) == 2 or len(rtfiles) == 5: self.wlanmodule = 'ralink' if os_path.exists(zd1211b_dir): zdfiles = listdir(zd1211b_dir) - if len(zdfiles) == 1: + if len(zdfiles) == 1 or len(zdfiles) == 5: self.wlanmodule = 'zydas' return self.wlanmodule