-small code cleanup..
This commit is contained in:
parent
1411987b01
commit
49c399b7a8
3 changed files with 13 additions and 17 deletions
|
@ -115,12 +115,6 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
signal.signal(signal.SIGINT, keyboardInterruptHandler)
|
signal.signal(signal.SIGINT, keyboardInterruptHandler)
|
||||||
|
|
||||||
#import daemonize
|
|
||||||
#daemonize.createDaemon()
|
|
||||||
#open("airtime.pid", "w").write(str(os.getpid()) + "\n")
|
|
||||||
#daemonize.drop_privileges("pypo", "pypo")
|
|
||||||
|
|
||||||
|
|
||||||
# initialize
|
# initialize
|
||||||
g = Global()
|
g = Global()
|
||||||
|
|
||||||
|
|
|
@ -83,8 +83,10 @@ class PypoFetch(Thread):
|
||||||
|
|
||||||
|
|
||||||
def set_export_source(self, export_source):
|
def set_export_source(self, export_source):
|
||||||
|
logger = logging.getLogger('fetch')
|
||||||
self.export_source = export_source
|
self.export_source = export_source
|
||||||
self.cache_dir = config["cache_dir"] + self.export_source + '/'
|
self.cache_dir = config["cache_dir"] + self.export_source + '/'
|
||||||
|
logger.info("Creating cache directory at %s", self.cache_dir)
|
||||||
|
|
||||||
def check_matching_timezones(self, server_timezone):
|
def check_matching_timezones(self, server_timezone):
|
||||||
logger = logging.getLogger('fetch')
|
logger = logging.getLogger('fetch')
|
||||||
|
@ -268,7 +270,7 @@ class PypoFetch(Thread):
|
||||||
|
|
||||||
fileExt = os.path.splitext(media['uri'])[1]
|
fileExt = os.path.splitext(media['uri'])[1]
|
||||||
try:
|
try:
|
||||||
dst = "%s%s/%s%s" % (self.cache_dir, str(pkey), str(media['id']), str(fileExt))
|
dst = "%s%s/%s%s" % (self.cache_dir, pkey, media['id'], fileExt)
|
||||||
|
|
||||||
# download media file
|
# download media file
|
||||||
self.handle_remote_file(media, dst)
|
self.handle_remote_file(media, dst)
|
||||||
|
@ -283,11 +285,11 @@ class PypoFetch(Thread):
|
||||||
if fsize > 0:
|
if fsize > 0:
|
||||||
pl_entry = \
|
pl_entry = \
|
||||||
'annotate:export_source="%s",media_id="%s",liq_start_next="%s",liq_fade_in="%s",liq_fade_out="%s",liq_cue_in="%s",liq_cue_out="%s",schedule_table_id="%s":%s' \
|
'annotate:export_source="%s",media_id="%s",liq_start_next="%s",liq_fade_in="%s",liq_fade_out="%s",liq_cue_in="%s",liq_cue_out="%s",schedule_table_id="%s":%s' \
|
||||||
% (str(media['export_source']), media['id'], 0, \
|
% (media['export_source'], media['id'], 0, \
|
||||||
str(float(media['fade_in']) / 1000), \
|
float(media['fade_in']) / 1000, \
|
||||||
str(float(media['fade_out']) / 1000), \
|
float(media['fade_out']) / 1000, \
|
||||||
str(float(media['cue_in'])), \
|
float(media['cue_in']), \
|
||||||
str(float(media['cue_out'])), \
|
float(media['cue_out']), \
|
||||||
media['row_id'], dst)
|
media['row_id'], dst)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
@ -375,7 +377,7 @@ class PypoFetch(Thread):
|
||||||
|
|
||||||
loops = 1
|
loops = 1
|
||||||
while True:
|
while True:
|
||||||
logger.info("Loop #"+str(loops))
|
logger.info("Loop #%s", loops)
|
||||||
try:
|
try:
|
||||||
# Wait for messages from RabbitMQ. Timeout if we
|
# Wait for messages from RabbitMQ. Timeout if we
|
||||||
# dont get any after POLL_INTERVAL.
|
# dont get any after POLL_INTERVAL.
|
||||||
|
|
|
@ -163,8 +163,8 @@ class PypoPush(Thread):
|
||||||
#Return the time as a floating point number expressed in seconds since the epoch, in UTC.
|
#Return the time as a floating point number expressed in seconds since the epoch, in UTC.
|
||||||
epoch_now = time.time()
|
epoch_now = time.time()
|
||||||
|
|
||||||
logger.debug("Epoch start: " + str(epoch_start))
|
logger.debug("Epoch start: %s" % epoch_start)
|
||||||
logger.debug("Epoch now: " + str(epoch_now))
|
logger.debug("Epoch now: %s" % epoch_now)
|
||||||
|
|
||||||
sleep_time = epoch_start - epoch_now;
|
sleep_time = epoch_start - epoch_now;
|
||||||
|
|
||||||
|
@ -184,8 +184,8 @@ class PypoPush(Thread):
|
||||||
liquidsoap_data = self.api_client.get_liquidsoap_data(pkey, schedule)
|
liquidsoap_data = self.api_client.get_liquidsoap_data(pkey, schedule)
|
||||||
|
|
||||||
#Sending schedule table row id string.
|
#Sending schedule table row id string.
|
||||||
logger.debug("vars.pypo_data %s\n"%(str(liquidsoap_data["schedule_id"])))
|
logger.debug("vars.pypo_data %s\n"%(liquidsoap_data["schedule_id"]))
|
||||||
tn.write(("vars.pypo_data %s\n"%str(liquidsoap_data["schedule_id"])).encode('latin-1'))
|
tn.write(("vars.pypo_data %s\n"%liquidsoap_data["schedule_id"]).encode('latin-1'))
|
||||||
|
|
||||||
logger.debug('Preparing to push playlist %s' % pkey)
|
logger.debug('Preparing to push playlist %s' % pkey)
|
||||||
for item in playlist:
|
for item in playlist:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue