Merge branch 'master' of dev.sourcefabric.org:airtime

Conflicts:
	python_apps/pypo/pypocli.py
	python_apps/pypo/pypofetch.py
	python_apps/pypo/pypopush.py
This commit is contained in:
Martin Konecny 2013-04-25 22:20:03 -04:00
commit 1a765e6cb9
17 changed files with 415 additions and 218 deletions
python_apps/pypo

View file

@ -37,7 +37,7 @@ signal.signal(signal.SIGINT, keyboardInterruptHandler)
POLL_INTERVAL = 1800
class PypoFetch(Thread):
def __init__(self, pypoFetch_q, pypoPush_q, media_q, telnet_lock, config):
def __init__(self, pypoFetch_q, pypoPush_q, media_q, telnet_lock, pypo_liquidsoap, config):
Thread.__init__(self)
self.api_client = api_client.AirtimeApiClient()
self.fetch_queue = pypoFetch_q
@ -49,7 +49,9 @@ class PypoFetch(Thread):
self.telnet_lock = telnet_lock
self.logger = logging.getLogger();
self.logger = logging.getLogger()
self.pypo_liquidsoap = pypo_liquidsoap
self.cache_dir = os.path.join(config["cache_dir"], "scheduler")
self.logger.debug("Cache dir %s", self.cache_dir)
@ -562,6 +564,14 @@ class PypoFetch(Thread):
# Bootstrap: since we are just starting up, we need to grab the
# most recent schedule. After that we can just wait for updates.
success = self.persistent_manual_schedule_fetch(max_attempts=5)
#Make sure all Liquidsoap queues are empty. This is important in the
#case where we've just restarted the pypo scheduler, but Liquidsoap still
#is playing tracks. In this case let's just restart everything from scratch
#so that we can repopulate our dictionary that keeps track of what
#Liquidsoap is playing much more easily.
self.pypo_liquidsoap.clear_all_queues()
if success:
self.logger.info("Bootstrap schedule received: %s", self.schedule_data)
self.set_bootstrap_variables()