Update 'trashtalker.py'
This commit is contained in:
parent
b9b5fd4e5f
commit
357ecf994c
|
@ -158,6 +158,19 @@ def PjDeinit():
|
||||||
elog(1, "deinit", "pjsip error when clearing down: %s" % str(e))
|
elog(1, "deinit", "pjsip error when clearing down: %s" % str(e))
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def loadplaylist():
|
||||||
|
olog(2, "playlist-load", "loading playlist files")
|
||||||
|
global sourcepath
|
||||||
|
if not sourcepath.endswith('/'):
|
||||||
|
olog(1, "playlist-load", "appending trailing / to TT_MEDIA_SOURCE")
|
||||||
|
sourcepath="%s/" % sourcepath
|
||||||
|
global files
|
||||||
|
files=listdir(sourcepath)
|
||||||
|
files[:]=[sourcepath+file for file in files]
|
||||||
|
assert (len(files) > 1), "playlist path %s must contain more than one audio file" % sourcepath
|
||||||
|
olog(1, "playlist-load",
|
||||||
|
"load playlist from %s, got %s files" % (sourcepath, len(files)))
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
olog(1, "init", "initialising trashtalker")
|
olog(1, "init", "initialising trashtalker")
|
||||||
global mainloop
|
global mainloop
|
||||||
|
@ -168,14 +181,7 @@ def main():
|
||||||
signal(SIGTERM, sighandle)
|
signal(SIGTERM, sighandle)
|
||||||
assert sourcepath.startswith('/'), "Environment variable TT_MEDIA_PATH must be an absolute path!"
|
assert sourcepath.startswith('/'), "Environment variable TT_MEDIA_PATH must be an absolute path!"
|
||||||
try:
|
try:
|
||||||
if not sourcepath.endswith('/'):
|
loadplaylist()
|
||||||
olog(1, "playlist-load", "appending trailing / to TT_MEDIA_PATH")
|
|
||||||
sourcepath=''.join(sourcepath, '/')
|
|
||||||
files=listdir(sourcepath)
|
|
||||||
files[:]=[sourcepath+file for file in files]
|
|
||||||
assert (len(files) > 1), "Playlist path must contain more than one audio file"
|
|
||||||
olog(1, "playlist-load",
|
|
||||||
"load playlist from %s, got %s files" % (sourcepath, len(files)))
|
|
||||||
except:
|
except:
|
||||||
elog(1, "playlist-load", "exception encountered while loading playlist from path %s" % sourcepath)
|
elog(1, "playlist-load", "exception encountered while loading playlist from path %s" % sourcepath)
|
||||||
raise Exception("Unable to load playlist")
|
raise Exception("Unable to load playlist")
|
||||||
|
|
Loading…
Reference in New Issue