From: yomguy Date: Fri, 2 Jul 2010 16:01:24 +0000 (+0000) Subject: add dicttoxml methods, prepare deefuzzer integration X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=d6e017d6af51fe40bfe94304c9e2b760b1318f7f;p=telecaster-cgi.git add dicttoxml methods, prepare deefuzzer integration --- diff --git a/README b/README index 09f3ad3..92390fc 100644 --- a/README +++ b/README @@ -1,5 +1,6 @@ -TELECASTER -========== +=================== +README - TELECASTER +=================== LICENCE ======= @@ -35,17 +36,23 @@ LICENCE # Author: Guillaume Pellerin + ARCHITECTURE ============ Builds well on Debian GNU/Linux 5.0.4 + DEPENDS ======== -required : python, icecast2, jackd, edcast-jack (=3.1.7), vorbis-tools, python-mutagen, streamrippper, procps +required : python, icecast2, apache2, jackd, edcast-jack (=3.1.7), vorbis-tools, + python-mutagen, streamrippper, procps + optional : lame + MORE INFOS ========== + See http://svn.parisson.org/telecaster/ diff --git a/conf/etc/telecaster/deefuzzer.xml b/conf/etc/telecaster/deefuzzer.xml new file mode 100644 index 0000000..bb38824 --- /dev/null +++ b/conf/etc/telecaster/deefuzzer.xml @@ -0,0 +1,57 @@ + + /var/log/deefuzzer/deefuzzer.log + /var/www/m3u/deefuzzer.m3u + + + TeleCaster + TeleCaster Live Session + LIVE Talk and Music + http://parisson.com + Various Funk Groove + + + parisson.com + 8000 + source2parisson + 0 + + + /path/to/mp3/ + mp3 + 192 + 7 + 44100 + 1 + 1 + + + /var/www/rss/ + 1 + + + 0 + my_twitter_user + my_twitter_password + bla bla + + + 0 + /path/to/jingles + 1 + + + 0 + 1234 + + + 0 + http://localhost:8000/telecaster_live.mp3 + + + 0 + /path/to/archives + + + + + diff --git a/conf/etc/telecaster/telecaster.xml b/conf/etc/telecaster/telecaster.xml index d4d1bd0..aae79ea 100644 --- a/conf/etc/telecaster/telecaster.xml +++ b/conf/etc/telecaster/telecaster.xml @@ -3,31 +3,27 @@ Pre-Barreau Pre-Barreau La preparation au Barreau de Paris - http:///telecaster-04.parisson.com + http://telecaster-04.parisson.com Other - localhost + stream.pre-barreau.com 8000 source2parisson 0 /var/www/telecaster/ - /etc/telecaster/telecaster_edcast_mp3.cfg - lock/telecaster.lock - localhost/tmp/ /var/www/rss/ true - /home/pre-barreau/media - /home/pre-barreau/backup + /home/prebarreau/media mp3 - 96 + 48 1 3 - 44100 + 48000 diff --git a/tools/xmltodict.py b/tools/xmltodict.py index b85d556..90db081 100644 --- a/tools/xmltodict.py +++ b/tools/xmltodict.py @@ -1,9 +1,13 @@ #!/usr/bin/env python +# -*- coding: utf-8 -*- # Easily import simple XML data to Python dictionary # http://www.gmta.info/publications/parsing-simple-xml-structure-to-a-python-dictionary import xml.dom.minidom +import xml.dom.ext +from xml.sax.saxutils import escape + def haschilds(dom): # Checks whether an element has any childs @@ -14,6 +18,7 @@ def haschilds(dom): return True return False + def indexchilds(dom, enc): childsdict = dict() for childnode in dom.childNodes: @@ -34,8 +39,38 @@ def indexchilds(dom, enc): childsdict[name] = v return childsdict + def xmltodict(data, enc=None): dom = xml.dom.minidom.parseString(data.strip()) return indexchilds(dom, enc) +def dicttoxml(d): + + def unicodify(o): + if o is None: + return u''; + return unicode(o) + + lines = [] + def addDict(node, offset): + for name, value in node.iteritems(): + if isinstance(value, dict): + lines.append(offset + u"<%s>" % name) + addDict(value, offset + u" " * 4) + lines.append(offset + u"" % name) + elif isinstance(value, list): + for item in value: + if isinstance(item, dict): + lines.append(offset + u"<%s>" % name) + addDict(item, offset + u" " * 4) + lines.append(offset + u"" % name) + else: + lines.append(offset + u"<%s>%s" % (name, escape(unicodify(item)), name)) + else: + lines.append(offset + u"<%s>%s" % (name, escape(unicodify(value)), name)) + + addDict(d, u"") + lines.append(u"") + return u"\n".join(lines) +