try:
if 'station_instance' in self.station_settings[i]:
# Check for station running here
- if self.station_settings[i]['station_instance'].isAlive():
+ if self.station_settings[i]['station_instance'].is_alive:
# Station exists and is alive. Don't recreate.
self.station_settings[i]['retries'] = 0
continue
# -*- coding: utf-8 -*-
-from .xmltodict import *
+from .xmltodict3 import *
from .PyRSS2Gen import *
from .mediabase import *
from .mp3 import *
import string
import mimetypes
from itertools import chain
+from xml.etree import cElementTree as ElementTree
from deefuzzer.tools import *
-import xmltodict
+
mimetypes.add_type('application/x-yaml', '.yaml')
# Do the type check first, so we don't load huge files that won't be used
if 'xml' in mime_type:
- confile = open(file, 'r')
- data = confile.read()
- confile.close()
- return xmltodict.parse(data)
+ tree = ElementTree.parse(file)
+ root = tree.getroot()
+ xmldict = etree_to_dict(root)
+ return xmldict
elif 'yaml' in mime_type or 'yml' in mime_type:
import yaml
--- /dev/null
+# -*- coding: utf-8 -*-
+# taken from https://stackoverflow.com/questions/2148119/how-to-convert-an-xml-string-to-a-dictionary
+# thanks to K3---rnc
+
+
+from collections import defaultdict
+
+def etree_to_dict(t):
+ d = {t.tag: {} if t.attrib else None}
+ children = list(t)
+ if children:
+ dd = defaultdict(list)
+ for dc in map(etree_to_dict, children):
+ for k, v in dc.items():
+ dd[k].append(v)
+ d = {t.tag: {k:v[0] if len(v) == 1 else v for k, v in dd.items()}}
+ if t.attrib:
+ d[t.tag].update(('@' + k, v) for k, v in t.attrib.items())
+ if t.text:
+ text = t.text.strip()
+ if children or t.attrib:
+ if text:
+ d[t.tag]['#text'] = text
+ else:
+ d[t.tag] = text
+ return d
\ No newline at end of file