Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
38256de606
22 changed files with 199 additions and 184 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,6 +1,7 @@
|
|||
import os
|
||||
import sys
|
||||
import time
|
||||
import calendar
|
||||
import logging
|
||||
import logging.config
|
||||
import shutil
|
||||
|
@ -53,12 +54,9 @@ Hopefully there is a better way to do this.
|
|||
|
||||
if(command == 'update_schedule'):
|
||||
SCHEDULE_PUSH_MSG = m['schedule']
|
||||
elif (command == 'update_timezone'):
|
||||
logger.info("Setting timezone to %s", m['timezone'])
|
||||
os.environ['TZ'] = m['timezone']
|
||||
time.tzset()
|
||||
elif (command == 'update_stream_setting'):
|
||||
logger.info("Updating stream setting: %s", m['setting'])
|
||||
|
||||
# ACK the message to take it off the queue
|
||||
message.ack()"""
|
||||
|
||||
|
@ -104,10 +102,6 @@ class PypoFetch(Thread):
|
|||
if(command == 'update_schedule'):
|
||||
self.schedule_data = m['schedule']
|
||||
self.process_schedule(self.schedule_data, "scheduler", False)
|
||||
elif (command == 'update_timezone'):
|
||||
logger.info("Setting timezone to %s", m['timezone'])
|
||||
os.environ['TZ'] = m['timezone']
|
||||
time.tzset()
|
||||
elif (command == 'update_stream_setting'):
|
||||
logger.info("Updating stream setting...")
|
||||
self.regenerateLiquidsoapConf(m['setting'])
|
||||
|
@ -212,20 +206,6 @@ class PypoFetch(Thread):
|
|||
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):
|
||||
logger = logging.getLogger('fetch')
|
||||
|
||||
process = Popen(["date", "+%z"], stdout=PIPE)
|
||||
pypo_timezone = (process.communicate()[0]).strip(' \r\n\t')
|
||||
|
||||
if server_timezone != pypo_timezone:
|
||||
logger.error("ERROR: Airtime server and pypo timezone offsets do not match. Audio playback will not start when expected!!!")
|
||||
logger.error(" * Server timezone offset: %s", server_timezone)
|
||||
logger.error(" * Pypo timezone offset: %s", pypo_timezone)
|
||||
logger.error(" * To fix this, you need to set the 'date.timezone' value in your php.ini file and restart apache.")
|
||||
logger.error(" * See this page for more info (v1.7): http://wiki.sourcefabric.org/x/BQBF")
|
||||
logger.error(" * and also the 'FAQ and Support' page underneath it.")
|
||||
|
||||
"""
|
||||
def get_currently_scheduled(self, playlistsOrMedias, str_tnow_s):
|
||||
for key in playlistsOrMedias:
|
||||
|
@ -274,12 +254,6 @@ class PypoFetch(Thread):
|
|||
logger = logging.getLogger('fetch')
|
||||
playlists = schedule_data["playlists"]
|
||||
|
||||
#if bootstrapping:
|
||||
#TODO: possible allow prepare_playlists to handle this.
|
||||
#self.handle_shows_currently_scheduled(playlists)
|
||||
|
||||
self.check_matching_timezones(schedule_data["server_timezone"])
|
||||
|
||||
# Push stream metadata to liquidsoap
|
||||
# TODO: THIS LIQUIDSOAP STUFF NEEDS TO BE MOVED TO PYPO-PUSH!!!
|
||||
stream_metadata = schedule_data['stream_metadata']
|
||||
|
@ -465,7 +439,7 @@ class PypoFetch(Thread):
|
|||
for r, d, f in os.walk(self.cache_dir):
|
||||
for dir in d:
|
||||
try:
|
||||
timestamp = time.mktime(time.strptime(dir, "%Y-%m-%d-%H-%M-%S"))
|
||||
timestamp = calendar.timegm(time.strptime(dir, "%Y-%m-%d-%H-%M-%S"))
|
||||
if (now - timestamp) > offset:
|
||||
try:
|
||||
logger.debug('trying to remove %s - timestamp: %s', os.path.join(r, dir), timestamp)
|
||||
|
|
|
@ -85,23 +85,19 @@ class PypoPush(Thread):
|
|||
playedItems = self.load_schedule_tracker()
|
||||
|
||||
timenow = time.time()
|
||||
tcoming = time.localtime(timenow + self.push_ahead)
|
||||
tcoming = time.gmtime(timenow + self.push_ahead)
|
||||
str_tcoming_s = "%04d-%02d-%02d-%02d-%02d-%02d" % (tcoming[0], tcoming[1], tcoming[2], tcoming[3], tcoming[4], tcoming[5])
|
||||
|
||||
tcoming2 = time.localtime(timenow + self.push_ahead2)
|
||||
tcoming2 = time.gmtime(timenow + self.push_ahead2)
|
||||
str_tcoming2_s = "%04d-%02d-%02d-%02d-%02d-%02d" % (tcoming2[0], tcoming2[1], tcoming2[2], tcoming2[3], tcoming2[4], tcoming2[5])
|
||||
|
||||
tnow = time.localtime(timenow)
|
||||
tnow = time.gmtime(timenow)
|
||||
str_tnow_s = "%04d-%02d-%02d-%02d-%02d-%02d" % (tnow[0], tnow[1], tnow[2], tnow[3], tnow[4], tnow[5])
|
||||
|
||||
for pkey in schedule:
|
||||
plstart = schedule[pkey]['start'][0:19]
|
||||
#plstart = pkey[0:19]
|
||||
|
||||
#playedFlag = (pkey in playedItems) and playedItems[pkey].get("played", 0)
|
||||
playedFlag = False
|
||||
|
||||
if plstart == str_tcoming_s or (plstart < str_tcoming_s and plstart > str_tcoming2_s and not playedFlag):
|
||||
if plstart == str_tcoming_s or (plstart < str_tcoming_s and plstart > str_tcoming2_s):
|
||||
logger.debug('Preparing to push playlist scheduled at: %s', pkey)
|
||||
playlist = schedule[pkey]
|
||||
|
||||
|
@ -156,7 +152,7 @@ class PypoPush(Thread):
|
|||
#mktime takes a time_struct and returns a floating point
|
||||
#gmtime Convert a time expressed in seconds since the epoch to a struct_time in UTC
|
||||
#mktime: expresses the time in local time, not UTC. It returns a floating point number, for compatibility with time().
|
||||
epoch_start = calendar.timegm(time.gmtime(time.mktime(time.strptime(pkey, '%Y-%m-%d-%H-%M-%S'))))
|
||||
epoch_start = calendar.timegm(time.strptime(pkey, '%Y-%m-%d-%H-%M-%S'))
|
||||
|
||||
#Return the time as a floating point number expressed in seconds since the epoch, in UTC.
|
||||
epoch_now = time.time()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue