ignore unknown nim types in /proc/bus/nim_sockets
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Wed, 21 Feb 2007 19:58:06 +0000 (19:58 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Wed, 21 Feb 2007 19:58:06 +0000 (19:58 +0000)
lib/python/Components/NimManager.py

index befcc56..741f1db 100644 (file)
@@ -470,6 +470,7 @@ class NimManager:
                        
                lastsocket = -1
 
                        
                lastsocket = -1
 
+               entries = {}
                while 1:                
                        line = nimfile.readline()
                        if line == "":
                while 1:                
                        line = nimfile.readline()
                        if line == "":
@@ -478,17 +479,24 @@ class NimManager:
                                parts = line.strip().split(" ")
                                id = int(parts[2][:1])
                                lastsocket = int(id)
                                parts = line.strip().split(" ")
                                id = int(parts[2][:1])
                                lastsocket = int(id)
-                               self.nimSocketCount += 1
+                               entries[lastsocket] = {}
                        elif line.strip().startswith("Type:"):
                        elif line.strip().startswith("Type:"):
-                               self.nimTypes[lastsocket] = str(line.strip()[6:])
-                               #self.nimTypes[lastsocket] = str("DVB-T")
+                               entries[lastsocket]["type"] = str(line.strip()[6:])
+                               #entries[lastsocket]["type"] = str("DVB-S2")
                        elif line.strip().startswith("Name:"):
                        elif line.strip().startswith("Name:"):
-                               self.nimNames[lastsocket] = str(line.strip()[6:])
+                               entries[lastsocket]["name"] = str(line.strip()[6:])
                        elif line.strip().startswith("empty"):
                        elif line.strip().startswith("empty"):
-                               self.nimNames[lastsocket] = _("N/A")
-                               self.nimTypes[lastsocket] = "empty/unknown"
-
+                               entries[lastsocket]["type"] = "empty/unknown"
+                               entries[lastsocket]["name"] = _("N/A")
                nimfile.close()
                nimfile.close()
+               
+               for id,entry  in entries.items():
+                       if not(entry.has_key("name") and entry.has_key("type") and self.nimType.has_key(entry["type"])):
+                               entry["name"] =  _("N/A")
+                               entry["type"] = "empty/unknown"
+                       self.nimNames[id] = entry["name"]
+                       self.nimTypes[id] = entry["type"]
+                       self.nimSocketCount += 1
 
        def getNimType(self, slotID):
                if slotID >= self.nimCount:
 
        def getNimType(self, slotID):
                if slotID >= self.nimCount: