print "D-fuzz v"+self.version
self.conf = self.get_conf_dict()
print self.conf
-
- nb_stations = len(self.conf['d-fuzz']['station'])
+
+ # Fix wrong type data from xmltodict when one station (*)
+ if isinstance(self.conf['d-fuzz']['station'], dict):
+ nb_stations = 1
+ else:
+ nb_stations = len(self.conf['d-fuzz']['station'])
print 'Number of stations : ' + str(nb_stations)
# Create a Queue:
#stream_pool = Queue.Queue ( 0 )
for i in range(0,nb_stations):
- station = self.conf['d-fuzz']['station'][i]
+ # (*) idem
+ if isinstance(self.conf['d-fuzz']['station'], dict):
+ station = self.conf['d-fuzz']['station']
+ else:
+ station = self.conf['d-fuzz']['station'][i]
print station
name = station['infos']['name']
channels = int(station['infos']['channels'])
import xml.dom.minidom
def haschilds(dom):
-
# Checks whether an element has any childs
# containing real tags opposed to just text.
-
for childnode in dom.childNodes:
if childnode.nodeName != "#text" and \
childnode.nodeName != "#cdata-section":
return True
-
return False
def indexchilds(dom, enc):
childsdict = dict()
-
for childnode in dom.childNodes:
name = childnode.nodeName.encode(enc)
if name == "#text" or name == "#cdata-section":
# ignore whitespaces
continue
-
if haschilds(childnode):
v = indexchilds(childnode, enc)
else:
v = childnode.childNodes[0].nodeValue.encode(enc)
-
if name in childsdict:
if isinstance(childsdict[name], dict):
# there is multiple instances of this node - convert to list
childsdict[name].append(v)
else:
childsdict[name] = v
-
return childsdict
def xmltodict(data, enc=None):