from skin import elementsWithTag
from Tools import XMLTools
+from xml.sax import make_parser
+from xml.sax.handler import ContentHandler
+
class boundFunction:
def __init__(self, fnc, *args):
self.fnc = fnc
self.name = name
class NimManager:
+ class parseSats(ContentHandler):
+ def __init__(self, satList, satellites):
+ self.isPointsElement, self.isReboundsElement = 0, 0
+ self.satList = satList
+ self.satellites = satellites
+
+ def startElement(self, name, attrs):
+ if (name == "sat"):
+ #print "found sat " + attrs.get('name',"") + " " + str(attrs.get('position',""))
+ tpos = attrs.get('position',"")
+ tname = attrs.get('name',"")
+ self.satellites[tpos] = tname
+ self.satList.append( (tname, tpos) )
+
def readSatsfromFile(self):
self.satellites = { }
- #FIXME: path ok???
- satdom = xml.dom.minidom.parse('/etc/tuxbox/satellites.xml')
-
- for entries in elementsWithTag(satdom.childNodes, "satellites"):
- for x in elementsWithTag(entries.childNodes, "sat"):
- #print "found sat " + x.getAttribute('name') + " " + str(x.getAttribute('position'))
- tpos = x.getAttribute('position')
- tname = x.getAttribute('name')
- #tname.encode('utf8')
- self.satellites[tpos] = tname
- self.satList.append( (tname, tpos) )
+ #FIXME: path ok???
+ print "Reading satellites.xml"
+ parser = make_parser()
+ satHandler = self.parseSats(self.satList, self.satellites)
+ parser.setContentHandler(satHandler)
+ parser.parse('/etc/tuxbox/satellites.xml')
+
+ #satdom = xml.dom.minidom.parse('/etc/tuxbox/satellites.xml')
+
+
+ #for entries in elementsWithTag(satdom.childNodes, "satellites"):
+ #for x in elementsWithTag(entries.childNodes, "sat"):
+ ##print "found sat " + x.getAttribute('name') + " " + str(x.getAttribute('position'))
+ #tpos = x.getAttribute('position')
+ #tname = x.getAttribute('name')
+ ##tname.encode('utf8')
+ #self.satellites[tpos] = tname
+ #self.satList.append( (tname, tpos) )
def getNimType(self, slotID):
#FIXME get it from /proc
self.readSatsfromFile()
self.nimCount = self.getNimSocketCount()
-
+
self.nimslots = [ ]
x = 0
while x < self.nimCount: