self.conf_file = conf_file
self.conf = get_conf_dict(self.conf_file)
- if not 'deefuzzer' in self.conf.keys():
+ if 'deefuzzer' not in self.conf.keys():
return
# Get the log setting first (if possible)
while True:
self.create_stations_fromfolder()
ns_new = len(self.station_settings)
- if(ns_new > ns):
+ if ns_new > ns:
self._info('Loading new stations')
for i in range(0, ns_new):
+ name = ''
try:
- name = ''
if 'station_name' in self.station_settings[i].keys():
name = self.station_settings[i]['station_name']
continue
self.station_settings[i]['retries'] += 1
- self._info('Restarting station ' + name + ' (try ' + str(self.station_settings[i]['retries']) + ')')
+ trynum = str(self.station_settings[i]['retries'])
+ self._info('Restarting station ' + name + ' (try ' + trynum + ')')
except Exception as e:
self._err('Error checking status for ' + name)
self._err(str(e))
- if not ignoreErrors:
+ if not self.ignoreErrors:
raise
# Apply station defaults if they exist
if 'stationdefaults' in self.conf['deefuzzer']:
if isinstance(self.conf['deefuzzer']['stationdefaults'], dict):
- self.station_settings[i] = merge_defaults(self.station_settings[i], self.conf['deefuzzer']['stationdefaults'])
+ self.station_settings[i] = merge_defaults(
+ self.station_settings[i],
+ self.conf['deefuzzer']['stationdefaults']
+ )
if name == '':
name = 'Station ' + str(i)
self._err('Error validating station ' + name)
except Exception:
self._err('Error initializing station ' + name)
- if not ignoreErrors:
+ if not self.ignoreErrors:
raise
continue
if self.type == 'icecast':
date = datetime.datetime.now().strftime("%Y")
+ media = None
if self.channel.format == 'mp3':
media = Mp3(self.record_dir + os.sep + self.rec_file)
if self.channel.format == 'ogg':
media = Ogg(self.record_dir + os.sep + self.rec_file)
- media.metadata = {'artist': self.artist.encode('utf-8'),
- 'title': self.title.encode('utf-8'),
- 'album': self.short_name.encode('utf-8'),
- 'genre': self.channel.genre.encode('utf-8'),
- 'date': date.encode('utf-8'), }
- media.write_tags()
+ if media:
+ media.metadata = {'artist': self.artist.encode('utf-8'),
+ 'title': self.title.encode('utf-8'),
+ 'album': self.short_name.encode('utf-8'),
+ 'genre': self.channel.genre.encode('utf-8'),
+ 'date': date.encode('utf-8'), }
+ media.write_tags()
self.record_mode = value
message = "received OSC message '%s' with arguments '%d'" % (path, value)
for media_obj in new_tracks_objs:
title = ''
artist = ''
- if media_obj.metadata.has_key('title'):
+ if 'title' in media_obj.metadata:
title = media_obj.metadata['title']
- if media_obj.metadata.has_key('artist'):
+ if 'artist' in media_obj.metadata:
artist = media_obj.metadata['artist']
if not (title or artist):
song = str(media_obj.file_name)
else:
song = artist + ' - ' + title
- song = song.encode('utf-8')
- artist = artist.encode('utf-8')
- artist_names = artist.split(' ')
- artist_tags = ' #'.join(list(set(artist_names) - {'&', '-'}))
- message = '#NEWTRACK ! %s #%s on #%s RSS: ' % \
- (song.replace('_', ' '), artist_tags, self.short_name)
- message = message[:113] + self.feeds_url
- self.update_twitter(message)
+ song = song.encode('utf-8')
+ artist = artist.encode('utf-8')
+
+ artist_names = artist.split(' ')
+ artist_tags = ' #'.join(list(set(artist_names) - {'&', '-'}))
+ message = '#NEWTRACK ! %s #%s on #%s RSS: ' % \
+ (song.replace('_', ' '), artist_tags, self.short_name)
+ message = message[:113] + self.feeds_url
+ self.update_twitter(message)
def get_next_media(self):
# Init playlist
if not self.__twitter_should_update():
return
artist_names = self.artist.split(' ')
- artist_tags = ' #'.join(list(set(artist_names) - {'&', '-'}))
+ # artist_tags = ' #'.join(list(set(artist_names) - {'&', '-'}))
message = '%s %s on #%s' % (self.prefix, self.song, self.short_name)
tags = '#' + ' #'.join(self.twitter_tags)
message = message + ' ' + tags
decription = str
format = str
url = str
- delay = 0
+ _delay = 0
def __init__(self):
Thread.__init__(self)
self.read_callback = read_callback
def delay(self):
- return self.delay
+ return self._delay
def open(self):
import pycurl
return f.getvalue()
-def _element(handler, name, obj, d={}):
+def _element(handler, name, obj, d=None):
+ if not d:
+ d = {}
if isinstance(obj, basestring) or obj is None:
# special-case handling to make the API easier
# to use for the common case.
self.type = type
def publish(self, handler):
- _element(handler, "enclosure", None,
- {"url": self.url,
- "length": str(self.length),
- "type": self.type,
- })
+ _element(handler, "enclosure", None, {
+ "url": self.url,
+ "length": str(self.length),
+ "type": self.type
+ })
class Source:
rss_attrs = {"version": "2.0"}
element_attrs = {}
- def __init__(self,
- title,
- link,
- description,
-
- language=None,
- copyright=None,
- managingEditor=None,
- webMaster=None,
- pubDate=None, # a datetime, *in* *GMT*
- lastBuildDate=None, # a datetime
-
- categories=None, # list of strings or Category
- generator=_generator_name,
- docs="http://blogs.law.harvard.edu/tech/rss",
- cloud=None, # a Cloud
- ttl=None, # integer number of minutes
-
- image=None, # an Image
- rating=None, # a string; I don't know how it's used
- textInput=None, # a TextInput
- skipHours=None, # a SkipHours with a list of integers
- skipDays=None, # a SkipDays with a list of strings
-
- items=None, # list of RSSItems
+ def __init__(
+ self,
+ title,
+ link,
+ description,
+
+ language=None,
+ copyright=None,
+ managingEditor=None,
+ webMaster=None,
+ pubDate=None, # a datetime, *in* *GMT*
+ lastBuildDate=None, # a datetime
+
+ categories=None, # list of strings or Category
+ generator=_generator_name,
+ docs="http://blogs.law.harvard.edu/tech/rss",
+ cloud=None, # a Cloud
+ ttl=None, # integer number of minutes
+
+ image=None, # an Image
+ rating=None, # a string; I don't know how it's used
+ textInput=None, # a TextInput
+ skipHours=None, # a SkipHours with a list of integers
+ skipDays=None, # a SkipDays with a list of strings
+ items=None # list of RSSItems
):
self.title = title
self.link = link
"""Publish an RSS Item"""
element_attrs = {}
- def __init__(self,
- title=None, # string
- link=None, # url as string
- description=None, # string
- author=None, # email address as string
- categories=None, # list of string or Category
- comments=None, # url as string
- enclosure=None, # an Enclosure
- guid=None, # a unique string
- pubDate=None, # a datetime
- source=None, # a Source
+ def __init__(
+ self,
+ title=None, # string
+ link=None, # url as string
+ description=None, # string
+ author=None, # email address as string
+ categories=None, # list of string or Category
+ comments=None, # url as string
+ enclosure=None, # an Enclosure
+ guid=None, # a unique string
+ pubDate=None, # a datetime
+ source=None # a Source
):
if title is None and description is None:
self.options = {}
self.bitrate_default = '192'
self.cache_dir = os.sep + 'tmp'
- self.keys2id3 = {'title': 'TIT2',
- 'artist': 'TPE1',
- 'album': 'TALB',
- 'date': 'TDRC',
- 'comment': 'COMM',
- 'country': 'COUNTRY',
- 'genre': 'TCON',
- 'copyright': 'TCOP',
+ self.keys2id3 = {
+ 'title': 'TIT2',
+ 'artist': 'TPE1',
+ 'album': 'TALB',
+ 'date': 'TDRC',
+ 'comment': 'COMM',
+ 'country': 'COUNTRY',
+ 'genre': 'TCON',
+ 'copyright': 'TCOP'
}
self.mp3 = MP3(self.media, ID3=EasyID3)
self.info = self.mp3.info
try:
self.metadata = self.get_file_metadata()
except:
- self.metadata = {'title': '',
- 'artist': '',
- 'album': '',
- 'date': '',
- 'comment': '',
- 'country': '',
- 'genre': '',
- 'copyright': '',
+ self.metadata = {
+ 'title': '',
+ 'artist': '',
+ 'album': '',
+ 'date': '',
+ 'comment': '',
+ 'country': '',
+ 'genre': '',
+ 'copyright': ''
}
self.description = self.get_description()
self.mp3.tags['TIT2'] = id3.TIT2(encoding=2, text=u'text')
self.mp3.save()
+ '''
# media_id3 = id3.ID3(self.media)
# for tag in self.metadata.keys():
# if tag in self.dub2id3_dict.keys():
# media_id3.save()
# except:
# raise IOError('ExporterError: cannot write tags')
+ '''
media = id3.ID3(self.media)
media.add(id3.TIT2(encoding=3, text=self.metadata['title'].decode('utf8')))
self.options = {}
self.bitrate_default = '192'
self.cache_dir = os.sep + 'tmp'
- self.keys2ogg = {'title': 'title',
- 'artist': 'artist',
- 'album': 'album',
- 'date': 'date',
- 'comment': 'comment',
- 'genre': 'genre',
- 'copyright': 'copyright',
+ self.keys2ogg = {
+ 'title': 'title',
+ 'artist': 'artist',
+ 'album': 'album',
+ 'date': 'date',
+ 'comment': 'comment',
+ 'genre': 'genre',
+ 'copyright': 'copyright'
}
self.info = self.ogg.info
self.bitrate = int(str(self.info.bitrate)[:-3])
# 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":
+ if childnode.nodeName != "#text" and childnode.nodeName != "#cdata-section":
return True
return False
import locale
from xml.parsers import expat
+""" """
+
+'''
# If we're in Dabo, get the default encoding.
# import dabo
# import dabo.lib.DesignerUtils as desUtil
# if enc is None:
# enc = dabo.defaultEncoding
# default_encoding = enc
+'''
# Python seems to need to compile code with \n linesep:
code_linesep = "\n"
else:
self.nodeStack = self.nodeStack[:-1]
-
def CharacterData(self, data):
"""SAX character data event handler"""
if self._inCode or data.strip():
element["cdata"] = ""
element["cdata"] += data
-
def Parse(self, xml):
# Create a SAX parser
Parser = expat.ParserCreate()
return self.root
def ParseFromFile(self, filename):
- return self.Parse(open(filename,"r").read())
+ return self.Parse(open(filename, "r").read())
-def xmltodict(xml, attsToSkip=[], addCodeFile=False):
+def xmltodict(xml, attsToSkip=None, addCodeFile=False):
"""Given an xml string or file, return a Python dictionary."""
+ if not attsToSkip:
+ attsToSkip = []
parser = Xml2Obj()
parser.attsToSkip = attsToSkip
isPath = os.path.exists(xml)
errmsg = ""
+ ret = None
if eol not in xml and isPath:
# argument was a file
try:
qt = ''
else:
qt = '"'
- slsh = "\\"
-# val = val.replace(slsh, slsh+slsh)
+ # slsh = "\\"
+ # val = val.replace(slsh, slsh+slsh)
if not noEscape:
# First escape internal ampersands. We need to double them up due to a
# quirk in wxPython and the way it displays this character.
if dct.has_key("code"):
if len(dct["code"].keys()):
- ret += "%s%s<code>%s" % (eol, "\t" * (level+1), eol)
- methodTab = "\t" * (level+2)
+ ret += "%s%s<code>%s" % (eol, "\t" * (level + 1), eol)
+ methodTab = "\t" * (level + 2)
for mthd, cd in dct["code"].items():
# Convert \n's in the code to eol:
cd = eol.join(cd.splitlines())
if not cd.endswith(eol):
cd += eol
- ret += "%s<%s><![CDATA[%s%s]]>%s%s</%s>%s" % (methodTab,
- mthd, eol, cd, eol,
- methodTab, mthd, eol)
- ret += "%s</code>%s" % ("\t" * (level+1), eol)
+ ret += "%s<%s><![CDATA[%s%s]]>%s%s</%s>%s" % (
+ methodTab, mthd, eol,
+ cd, eol,
+ methodTab, mthd, eol
+ )
+ ret += "%s</code>%s" % ("\t" * (level + 1), eol)
if dct.has_key("properties"):
if len(dct["properties"].keys()):
- ret += "%s%s<properties>%s" % (eol, "\t" * (level+1), eol)
- currTab = "\t" * (level+2)
+ ret += "%s%s<properties>%s" % (eol, "\t" * (level + 1), eol)
+ currTab = "\t" * (level + 2)
for prop, val in dct["properties"].items():
ret += "%s<%s>%s" % (currTab, prop, eol)
for propItm, itmVal in val.items():
- itmTab = "\t" * (level+3)
- ret += "%s<%s>%s</%s>%s" % (itmTab, propItm, itmVal,
- propItm, eol)
+ itmTab = "\t" * (level + 3)
+ ret += "%s<%s>%s</%s>%s" % (itmTab, propItm, itmVal, propItm, eol)
ret += "%s</%s>%s" % (currTab, prop, eol)
- ret += "%s</properties>%s" % ("\t" * (level+1), eol)
+ ret += "%s</properties>%s" % ("\t" * (level + 1), eol)
if dct.has_key("children") and len(dct["children"]) > 0:
ret += eol
for child in dct["children"]:
- ret += dicttoxml(child, level+1, linesep=linesep)
+ ret += dicttoxml(child, level + 1, linesep=linesep)
indnt = ""
if ret.endswith(eol):
# Indent the closing tag
if level == 0:
if header is None:
- header = '<?xml version="1.0" encoding="%s" standalone="no"?>%s' \
- % (default_encoding, eol)
+ header = '<?xml version="1.0" encoding="%s" standalone="no"?>%s' % (default_encoding, eol)
ret = header + ret
return ret
classCode = classCD.get("code", {})
classKids = classCD.get("children", [])
currDict = retDict.get(classID, {})
- retDict[classID] = {"attributes": classAtts, "code": classCode,
- "properties": classProps}
+ retDict[classID] = {
+ "attributes": classAtts,
+ "code": classCode,
+ "properties": classProps
+ }
retDict[classID].update(currDict)
# Now update the child objects in the dict
for kid in classKids:
else:
# Not a file; most likely just a component in another class
currDict = retDict.get(classID, {})
- retDict[classID] = {"attributes": atts, "code": code,
- "properties": props}
+ retDict[classID] = {
+ "attributes": atts,
+ "code": code,
+ "properties": props
+ }
retDict[classID].update(currDict)
if kids:
for kid in kids:
for kid in kids:
addInheritedInfo(kid, super, updateCode)
-
-
+'''
# if __name__ == "__main__":
# test_dict = {"name": "test", "attributes":{"path": "c:\\temp\\name",
# "problemChars": "Welcome to <Jos\xc3\xa9's \ Stuff!>\xc2\xae".decode("latin-1")}}
# test_dict2 = xmltodict(xml)
# print "test_dict2:", test_dict2
# print "same?:", test_dict == test_dict2
+'''
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import liblo, sys
+import liblo
+import sys
# send all messages to port 1234 on the local machine
try:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import liblo, sys
+import liblo
+import sys
# send all messages to port 1234 on the local machine
try:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import liblo, sys
+import liblo
+import sys
# send all messages to port 1234 on the local machine
try:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import liblo, sys
+import liblo
+import sys
# send all messages to port 1234 on the local machine
try:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import liblo, sys
+import liblo
+import sys
# send all messages to port 1234 on the local machine
try:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import liblo, sys
+import liblo
+import sys
# send all messages to port 1234 on the local machine
try:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import liblo, sys
+import liblo
+import sys
# send all messages to port 1234 on the local machine
try:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import liblo, sys
+import liblo
+import sys
# send all messages to port 1234 on the local machine
try:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import liblo, sys
+import liblo
+import sys
# send all messages to port 1234 on the local machine
try:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import liblo, sys
+import liblo
+import sys
# send all messages to port 1234 on the local machine
try:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-import liblo, sys
+import liblo
+import sys
# send all messages to port 1234 on the local machine
try:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-'''The setup and build script for the library.'''
+"""The setup and build script for the library."""
from setuptools import setup, find_packages
-CLASSIFIERS = ['Programming Language :: Python',
- 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
- 'Topic :: Multimedia :: Sound/Audio',
- 'Topic :: Multimedia :: Sound/Audio :: Players',]
+CLASSIFIERS = [
+ 'Programming Language :: Python',
+ 'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
+ 'Topic :: Multimedia :: Sound/Audio',
+ 'Topic :: Multimedia :: Sound/Audio :: Players'
+]
setup(
- name = "DeeFuzzer",
- url = "http://github.com/yomguy/DeeFuzzer",
- description = "open, light and instant media streaming tool",
- long_description = open('README.rst').read(),
- author = "Guillaume Pellerin",
- author_email = "yomguy@parisson.com",
- version = '0.7',
- install_requires = [
+ name="DeeFuzzer",
+ url="http://github.com/yomguy/DeeFuzzer",
+ description="open, light and instant media streaming tool",
+ long_description=open('README.rst').read(),
+ author="Guillaume Pellerin",
+ author_email="yomguy@parisson.com",
+ version='0.7',
+ install_requires=[
'setuptools',
'python-shout',
'python-twitter',
'mutagen',
'pyliblo',
- 'pycurl',
- ],
- platforms=['OS Independent'],
- license='CeCILL v2',
- scripts=['scripts/deefuzzer'],
- classifiers = CLASSIFIERS,
- packages = find_packages(),
- include_package_data = True,
- zip_safe = False,
+ 'pycurl'
+ ],
+ platforms=['OS Independent'],
+ license='CeCILL v2',
+ scripts=['scripts/deefuzzer'],
+ classifiers=CLASSIFIERS,
+ packages=find_packages(),
+ include_package_data=True,
+ zip_safe=False
)
-