move comment before multi line command to make python happy
[enigma2.git] / lib / python / Components / Network.py
index 3abfc34c6c68d2dd7104c5dc44d7d4b3c79e0605..d94fa30cd68851e29407e0962c7ebe751c95ecf0 100644 (file)
@@ -1,4 +1,4 @@
-from os import system, popen
+from os import system, popen, path as os_path, listdir
 from re import compile as re_compile
 from socket import *
 from enigma import eConsoleAppContainer
@@ -21,6 +21,8 @@ class Network:
                for line in result:
                        try:
                                device = devicesPattern.search(line).group()
+                               if device == 'wifi0':
+                                       continue
                                self.ifaces[device] = self.getDataForInterface(device)
                                # Show only UP Interfaces in E2
                                #if self.getAdapterAttribute(device, 'up') is False:
@@ -267,7 +269,7 @@ class Network:
                        fp.write("iface wlan0 inet dhcp\n")
                if mode == 'wlan-mpci':
                        fp.write("auto ath0\n")
-                       fp.write("iface eth0 inet dhcp\n")
+                       fp.write("iface ath0 inet dhcp\n")
                if mode == 'lan':
                        fp.write("auto eth0\n")
                        fp.write("iface eth0 inet dhcp\n")
@@ -292,20 +294,10 @@ class Network:
                self.getInterfaces()    
 
        def checkNetworkState(self):
-               ok_counter = 0
-               ret1=system("ping -c 1 www.dream-multimedia-tv.de")
-               if ret1 != 0:
-                       ok_counter = ok_counter + 1
-               ret2=system("ping -c 1 www.heise.de")
-               if ret2 != 0:
-                       ok_counter = ok_counter + 1
-               ret3=system("ping -c 1 www.google.de")
-               if ret2 != 0:
-                       ok_counter = ok_counter + 1             
-               if ok_counter <= 2:
-                       return True
-               else:
-                       return False
+                # www.dream-multimedia-tv.de, www.heise.de, www.google.de
+               return system("ping -c 1 82.149.226.170") == 0 or \
+                       system("ping -c 1 193.99.144.85") == 0 or \
+                       system("ping -c 1 209.85.135.103") == 0
 
        def restartNetwork(self):
                iNetwork.deactivateNetworkConfig()
@@ -332,37 +324,29 @@ class Network:
                                return True
                        else:
                                return False
-               
+
        def checkDNSLookup(self):
-               ok_counter = 0
-               ret1=system("nslookup www.dream-multimedia-tv.de")
-               if ret1 != 0:
-                       ok_counter = ok_counter + 1
-               ret2=system("nslookup www.heise.de")
-               if ret2 != 0:
-                       ok_counter = ok_counter + 1
-               ret3=system("nslookup www.google.de")
-               if ret2 != 0:
-                       ok_counter = ok_counter + 1             
-               if ok_counter <= 2:
-                       return True
-               else:
-                       return False
-               
+               return system("nslookup www.dream-multimedia-tv.de") == 0 or \
+                       system("nslookup www.heise.de") == 0 or \
+                       system("nslookup www.google.de")
+
        def deactivateInterface(self,iface):
                system("ifconfig " + iface + " down")
-               
+
        def detectWlanModule(self):
                self.wlanmodule = None
                rt73_dir = "/sys/bus/usb/drivers/rt73/"
                zd1211b_dir = "/sys/bus/usb/drivers/zd1211b/"
-               if os_path.exists(rt73_dir):
-                       files = []
+               madwifi_dir = "/sys/bus/pci/drivers/ath_pci/"
+               if os_path.exists(madwifi_dir):
+                       files = listdir(madwifi_dir)
+                       if len(files) >= 1:
+                               self.wlanmodule = 'madwifi'
+               elif os_path.exists(rt73_dir):
                        files = listdir(rt73_dir)
                        if len(files) >= 1:
                                self.wlanmodule = 'ralink'
-               if os_path.exists(zd1211b_dir):
-                       files = []
+               elif os_path.exists(zd1211b_dir):
                        files = listdir(zd1211b_dir)
                        if len(files) != 0:
                                self.wlanmodule = 'zydas'