some small fixes
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Thu, 14 Aug 2008 11:11:46 +0000 (11:11 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Thu, 14 Aug 2008 11:11:46 +0000 (11:11 +0000)
lib/python/Components/Network.py
lib/python/Screens/NetworkSetup.py

index b5b8e20113a164c02d8366ebd91c256168e8a4c8..cde6b7efcb0bde424f0c952ab7b4ecf576b1b705 100644 (file)
@@ -6,7 +6,7 @@ from enigma import eConsoleAppContainer
 class Network:
        def __init__(self):
                self.ifaces = {}
-               self.configuredInterfaces = {}
+               self.configuredInterfaces = []
                self.nameservers = []
                self.getInterfaces()
                self.ethtool_bin = "/usr/sbin/ethtool"
@@ -14,7 +14,7 @@ class Network:
 
        def getInterfaces(self):
                devicesPattern = re_compile('[a-z]+[0-9]+')
-
+               self.configuredInterfaces = []
                fp = file('/proc/net/dev', 'r')
                result = fp.readlines()
                fp.close()
@@ -63,7 +63,7 @@ class Network:
                ipPattern = re_compile(ipRegexp)
                upPattern = re_compile('UP ')
                macPattern = re_compile('[0-9]{2}\:[0-9]{2}\:[0-9]{2}\:[0-9]{2}\:[0-9]{2}\:[0-9]{2}')
-               
+
                fp = popen("ifconfig " + iface)
                result = fp.readlines()
                fp.close()
@@ -82,6 +82,8 @@ class Network:
                                data['bcast'] = self.convertIP(bcast)
                        if up is not None:
                                data['up'] = True
+                               if iface is not 'lo':
+                                       self.configuredInterfaces.append(iface)
                        if mac is not None:
                                data['mac'] = mac
                if not data.has_key('ip'):
@@ -102,6 +104,7 @@ class Network:
                return data
 
        def writeNetworkConfig(self):
+               self.configuredInterfaces = []
                fp = file('/etc/network/interfaces', 'w')
                fp.write("# automatically generated by enigma 2\n# do NOT change manually!\n\n")
                fp.write("auto lo\n")
@@ -109,9 +112,10 @@ class Network:
                for ifacename, iface in self.ifaces.items():
                        if iface['up'] == True:
                                fp.write("auto " + ifacename + "\n")
-                       if iface['dhcp'] == True:
+                               self.configuredInterfaces.append(ifacename)
+                       if iface['dhcp'] == True and iface['up'] == True:
                                fp.write("iface "+ ifacename +" inet dhcp\n")
-                       if iface['dhcp'] == False:
+                       if iface['dhcp'] == False and iface['up'] == True:
                                fp.write("iface "+ ifacename +" inet static\n")
                                if iface.has_key('ip'):
                                        print tuple(iface['ip'])
@@ -161,7 +165,7 @@ class Network:
                                if (split[0] == "gateway"):
                                        ifaces[currif]["gateway"] = map(int, split[1].split('.'))
                
-               self.configuredInterfaces = ifaces
+               #self.configuredInterfaces = ifaces
                print "read interfaces:", ifaces
                for ifacename, iface in ifaces.items():
                        if self.ifaces.has_key(ifacename):
@@ -342,13 +346,13 @@ class Network:
                        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:
+               if os_path.exists(rt73_dir):
+                       rtfiles = listdir(rt73_dir)
+                       if len(rtfiles) == 2:
                                self.wlanmodule = 'ralink'
-               elif os_path.exists(zd1211b_dir):
-                       files = listdir(zd1211b_dir)
-                       if len(files) != 0:
+               if os_path.exists(zd1211b_dir):
+                       zdfiles = listdir(zd1211b_dir)
+                       if len(zdfiles) == 1:
                                self.wlanmodule = 'zydas'
                return self.wlanmodule
        
index 971ae5aa2c8b41cfbd59b2c4943806536e5812ad..d9679bb18dc031e9014b3247608cef7c2e3aa186 100644 (file)
@@ -45,7 +45,7 @@ def InterfaceEntryComponent(index,name,default,active ):
 class NetworkAdapterSelection(Screen):
        def __init__(self, session):
                Screen.__init__(self, session)
-               iNetwork.getInterfaces()
+
                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.")
                
@@ -74,8 +74,14 @@ class NetworkAdapterSelection(Screen):
 
        def updateList(self):
                print "update list"
+               iNetwork.getInterfaces()
                self.list = []
                default_gw = None
+               num_configured_if = len(iNetwork.configuredInterfaces)
+               print "num_configured_if :",num_configured_if 
+               if num_configured_if < 2 and os_path.exists("/etc/default_gw"):
+                       unlink("/etc/default_gw")
+                       
                if os_path.exists("/etc/default_gw"):
                        fp = file('/etc/default_gw', 'r')
                        result = fp.read()
@@ -125,6 +131,8 @@ class NetworkAdapterSelection(Screen):
        def AdapterSetupClosed(self, *ret):
                if len(self.adapters) == 1:
                        self.close()
+               else:
+                       self.updateList()
 
        def NetworkFallback(self):
                if iNetwork.configuredInterfaces.has_key('wlan0') is True: