Merge branch '1.9.1' into devel

Conflicts:
	VERSION
	airtime_mvc/application/configs/constants.php
	airtime_mvc/application/controllers/ScheduleController.php
	install_minimal/airtime-install
	install_minimal/include/AirtimeInstall.php
	install_minimal/include/airtime-upgrade.php
	python_apps/api_clients/api_client.py
	python_apps/pypo/pypofetch.py
	python_apps/pypo/pypopush.py
This commit is contained in:
martin 2011-09-09 15:07:43 -04:00
commit 9c7bab616d
50 changed files with 205 additions and 125 deletions

42
python_apps/pypo/pypofetch.py Executable file → Normal file
View file

@ -10,6 +10,7 @@ import string
import json
import telnetlib
import math
import socket
from threading import Thread
from subprocess import Popen, PIPE
from datetime import datetime
@ -251,7 +252,7 @@ class PypoFetch(Thread):
scheduled_data = dict()
scheduled_data['liquidsoap_playlists'] = liquidsoap_playlists
scheduled_data['schedule'] = playlists
scheduled_data['stream_metadata'] = schedule_data["stream_metadata"]
scheduled_data['stream_metadata'] = schedule_data["stream_metadata"]
self.queue.put(scheduled_data)
# cleanup
@ -425,12 +426,7 @@ class PypoFetch(Thread):
logger.error(e)
"""
Main loop of the thread:
Wait for schedule updates from RabbitMQ, but in case there arent any,
poll the server to get the upcoming schedule.
"""
def run(self):
def main(self):
logger = logging.getLogger('fetch')
while not self.init_rabbit_mq():
@ -455,11 +451,33 @@ class PypoFetch(Thread):
# Wait for messages from RabbitMQ. Timeout if we
# dont get any after POLL_INTERVAL.
self.connection.drain_events(timeout=POLL_INTERVAL)
except Exception, e:
# Hooray for globals!
schedule_data = SCHEDULE_PUSH_MSG
status = 1
except socket.timeout, se:
# We didnt get a message for a while, so poll the server
# to get an updated schedule.
logger.info("Exception %s", e)
status, self.schedule_data = self.api_client.get_schedule()
self.process_schedule(self.schedule_data, "scheduler", False)
loops += 1
status, schedule_data = self.api_client.get_schedule()
except Exception, e:
"""
This Generic exception is thrown whenever the RabbitMQ
Service is stopped. In this case let's check every few
seconds to see if it has come back up
"""
logger.info("Unknown exception")
return
#return based on the exception
if status == 1:
self.process_schedule(schedule_data, "scheduler", False)
loops += 1
"""
Main loop of the thread:
Wait for schedule updates from RabbitMQ, but in case there arent any,
poll the server to get the upcoming schedule.
"""
def run(self):
while True:
self.main()