from deefuzzer.station import *
from deefuzzer.tools import *
-mimetypes.add_type('application/x-yaml','.yaml')
+mimetypes.add_type('application/x-yaml', '.yaml')
class DeeFuzzer(Thread):
self._info('Using libshout version %s' % shout.version())
self._info('Number of stations : ' + str(len(self.station_settings)))
-
def _log(self, level, msg):
try:
obj = {'msg': 'Core: ' + str(msg), 'level': level}
m3u.write('#EXTM3U\n')
for k in self.station_instances.keys():
s = self.station_instances[k]
- m3u.write('#EXTINF:%s,%s - %s\n' % ('-1',s.short_name, s.channel.name))
+ m3u.write('#EXTINF:%s,%s - %s\n' % ('-1', s.short_name, s.channel.name))
m3u.write('http://' + s.channel.host + ':' + str(s.channel.port) + s.channel.mount + '\n')
m3u.close()
self._info('Writing M3U file to : ' + self.m3u)
"""Scan a folder for subfolders containing media, and make stations from them all."""
options = self.watchfolder
- if not 'folder' in options.keys():
+ if 'folder' not in options.keys():
# We have no folder specified. Bail.
return
if self.mainLoop:
- if not 'livecreation' in options.keys():
+ if 'livecreation' not in options.keys():
# We have no folder specified. Bail.
return
# This makes the log file a lot more verbose. Commented out since we report on new stations anyway.
# self._info('Scanning folder ' + folder + ' for stations')
- if not 'infos' in options.keys():
+ if 'infos' not in options.keys():
options['infos'] = {}
- if not 'short_name' in options['infos'].keys():
+ if 'short_name' not in options['infos'].keys():
options['infos']['short_name'] = '[name]'
files = os.listdir(folder)
def station_exists(self, name):
try:
for s in self.station_settings:
- if not 'infos' in s.keys():
+ if 'infos' not in s.keys():
continue
- if not 'short_name' in s['infos'].keys():
+ if 'short_name' not in s['infos'].keys():
continue
if s['infos']['short_name'] == name:
return True
if self.station_exists(name):
return
self._info('Creating station for folder ' + folder)
- d = dict(path=folder,name=name)
+ d = dict(path=folder, name=name)
for i in options.keys():
- if not 'folder' in i:
+ if 'folder' not in i:
s[i] = replace_all(options[i], d)
- if not 'media' in s.keys():
+ if 'media' not in s.keys():
s['media'] = {}
s['media']['source'] = folder
if 'station_name' in self.station_settings[i].keys():
name = self.station_settings[i]['station_name']
- if not 'retries' in self.station_settings[i].keys():
+ if 'retries' not in self.station_settings[i].keys():
self.station_settings[i]['retries'] = 0
try:
if self.maxretry >= 0 and self.station_settings[i]['retries'] <= self.maxretry:
# Station passed the max retries count is will not be reloaded
- if not 'station_stop_logged' in self.station_settings[i].keys():
+ if 'station_stop_logged' not in self.station_settings[i].keys():
self._err('Station ' + name + ' is stopped and will not be restarted.')
self.station_settings[i]['station_stop_logged'] = True
continue
return False
return True
-
def icecastloop_metadata(self):
try:
self.update_twitter_current()
import datetime
+
# Could make this the base class; will need to add 'publish'
class WriteXmlMixin:
def __init__(self):
def get_args(self, options=None):
"""Get process options and return arguments for the encoder"""
args = []
- if not options is None:
+ if options is not None:
self.options = options
if not ('verbose' in self.options and self.options['verbose'] != '0'):
args.append('-Q ')
from xml.parsers import expat
# If we're in Dabo, get the default encoding.
-#import dabo
-#import dabo.lib.DesignerUtils as desUtil
-#from dabo.dLocalize import _
-#from dabo.lib.utils import resolvePath
-#app = dabo.dAppRef
-#if app is not None:
- #default_encoding = app.Encoding
-#else:
- #enc = locale.getlocale()[1]
- #if enc is None:
- #enc = dabo.defaultEncoding
- #default_encoding = enc
+# import dabo
+# import dabo.lib.DesignerUtils as desUtil
+# from dabo.dLocalize import _
+# from dabo.lib.utils import resolvePath
+# app = dabo.dAppRef
+# if app is not None:
+ # default_encoding = app.Encoding
+# else:
+ # enc = locale.getlocale()[1]
+ # if enc is None:
+ # enc = dabo.defaultEncoding
+ # default_encoding = enc
# Python seems to need to compile code with \n linesep:
code_linesep = "\n"
self._currPropAtt = ""
self._currPropDict = None
-
def StartElement(self, name, attributes):
"""SAX start element even handler"""
if name == "code":
self.root = element
self.nodeStack.append(element)
-
def EndElement(self, name):
"""SAX end element event handler"""
if self._inCode:
ParserStatus = Parser.Parse(xml, 1)
return self.root
-
def ParseFromFile(self, filename):
return self.Parse(open(filename,"r").read())
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</code>%s" % ("\t" * (level+1), eol)
if dct.has_key("properties"):
if len(dct["properties"].keys()):
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
-#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")}}
- #print "test_dict:", test_dict
- #xml = dicttoxml(test_dict)
- #print "xml:", xml
- #test_dict2 = xmltodict(xml)
- #print "test_dict2:", test_dict2
- #print "same?:", test_dict == test_dict2
+# 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")}}
+ # print "test_dict:", test_dict
+ # xml = dicttoxml(test_dict)
+ # print "xml:", xml
+ # test_dict2 = xmltodict(xml)
+ # print "test_dict2:", test_dict2
+ # print "same?:", test_dict == test_dict2