add sat.xml to get all satellites
authorRonny Strutz <ronny.strutz@multimedia-labs.de>
Wed, 5 Oct 2005 02:00:38 +0000 (02:00 +0000)
committerRonny Strutz <ronny.strutz@multimedia-labs.de>
Wed, 5 Oct 2005 02:00:38 +0000 (02:00 +0000)
lib/python/Components/NimManager.py

index 62b1fd8ddffebcb78b6a82f98d2b94dd4054af5f..0ba7a392a05dfcc94d1f86fdeee4921043735c2f 100644 (file)
@@ -5,6 +5,11 @@ from config import ConfigSubsection
 from config import ConfigSlider
 from config import configSelection
 
 from config import ConfigSlider
 from config import configSelection
 
+import xml.dom.minidom
+from xml.dom import EMPTY_NAMESPACE
+from skin import elementsWithTag
+from Tools import XMLTools
+
 class nimSlot:
        def __init__(self, slotid, nimtype, name):
                self.slotid = slotid
 class nimSlot:
        def __init__(self, slotid, nimtype, name):
                self.slotid = slotid
@@ -12,6 +17,18 @@ class nimSlot:
                self.name = name
 
 class NimManager:
                self.name = name
 
 class NimManager:
+       def readSatsfromFile(self):
+               self.satellites = { }
+               #FIXME: path ok???
+               satfile = file('/etc/tuxbox/satellites.xml', 'r')
+               satdom = xml.dom.minidom.parseString(satfile.read())
+               satfile.close()
+
+               for entries in elementsWithTag(satdom.childNodes, "satellites"):
+                       for x in elementsWithTag(entries.childNodes, "sat"):
+                               #print "found sat " + x.getAttribute('name') + " " + str(x.getAttribute('position'))
+                               self.satellites[x.getAttribute('position')] = x.getAttribute('name')
+
        def getNimType(self, slotID):
                #FIXME get it from /proc
                if slotID == 0:
        def getNimType(self, slotID):
                #FIXME get it from /proc
                if slotID == 0:
@@ -37,6 +54,8 @@ class NimManager:
                                                                                                "DVB-C": 1,
                                                                                                "DVB-T": 2}
                                                                                                
                                                                                                "DVB-C": 1,
                                                                                                "DVB-T": 2}
                                                                                                
+               self.readSatsfromFile()                                                                         
+                                                                                               
                self.nimCount = self.getNimSocketCount()
 
                self.nimslots = [ ]
                self.nimCount = self.getNimSocketCount()
 
                self.nimslots = [ ]
@@ -70,10 +89,9 @@ def InitNimManager(nimmgr):
                cname = nimmgr.getConfigPrefix(x)
                
                if slot.nimType == nimmgr.nimType["DVB-S"]:
                cname = nimmgr.getConfigPrefix(x)
                
                if slot.nimType == nimmgr.nimType["DVB-S"]:
+                       #use custom configElement which can handle a dict (for sats)
                        config.Nims[x].configMode = configElement(cname + "configMode",configSelection, 0, ("Simple", "Advanced"));
                        config.Nims[x].diseqcMode = configElement(cname + "diseqcMode",configSelection, 0, ("Single", "Toneburst A/B", "DiSEqC A/B"));
                        config.Nims[x].configMode = configElement(cname + "configMode",configSelection, 0, ("Simple", "Advanced"));
                        config.Nims[x].diseqcMode = configElement(cname + "diseqcMode",configSelection, 0, ("Single", "Toneburst A/B", "DiSEqC A/B"));
-                       config.Nims[x].diseqcMode = configElement(cname + "toneburstA",configSelection, 0, ("Astra", "Hotbird"));
-                       config.Nims[x].diseqcMode = configElement(cname + "toneburstB",configSelection, 0, ("Astra", "Hotbird"));
                        config.Nims[x].diseqcMode = configElement(cname + "diseqcA",configSelection, 0, ("Astra", "Hotbird"));
                        config.Nims[x].diseqcMode = configElement(cname + "diseqcB",configSelection, 0, ("Astra", "Hotbird"));
                        config.Nims[x].diseqcMode = configElement(cname + "diseqcC",configSelection, 0, ("Astra", "Hotbird"));
                        config.Nims[x].diseqcMode = configElement(cname + "diseqcA",configSelection, 0, ("Astra", "Hotbird"));
                        config.Nims[x].diseqcMode = configElement(cname + "diseqcB",configSelection, 0, ("Astra", "Hotbird"));
                        config.Nims[x].diseqcMode = configElement(cname + "diseqcC",configSelection, 0, ("Astra", "Hotbird"));