Merge branch '2.4.x'

Conflicts:
	airtime_mvc/public/js/airtime/showbuilder/builder.js
	python_apps/pypo/liquidsoap_scripts/fdkaac.liq
	python_apps/pypo/schedule/pypofetch.py
	python_apps/pypo/schedule/telnetliquidsoap.py
This commit is contained in:
Martin Konecny 2013-06-14 16:45:52 -04:00
commit 2a0c9769aa
40 changed files with 3341 additions and 3801 deletions

View file

@ -34,6 +34,7 @@ from subprocess import Popen, PIPE
from api_clients import api_client
from std_err_override import LogWriter
from timeout import ls_timeout
import pure
@ -55,6 +56,8 @@ class PypoFetch(Thread):
def __init__(self, pypoFetch_q, pypoPush_q, media_q, pypo_liquidsoap,
config):
Thread.__init__(self)
#Hacky...
PypoFetch.ref = self
self.api_client = api_client.AirtimeApiClient()
self.fetch_queue = pypoFetch_q
@ -198,15 +201,23 @@ class PypoFetch(Thread):
commands.append(('vars.default_dj_fade %s\n' % fade).encode('utf-8'))
self.pypo_liquidsoap.get_telnet_dispatcher().telnet_send(commands)
self.pypo_liquidsoap.clear_all_queues()
self.pypo_liquidsoap.clear_queue_tracker()
def restart_liquidsoap(self):
self.logger.info("Restarting Liquidsoap")
subprocess.call(['/etc/init.d/airtime-liquidsoap', 'restart'])
self.telnet_lock.acquire(False)
#Wait here and poll Liquidsoap until it has started up
self.logger.info("Waiting for Liquidsoap to start")
self.pypo_liquidsoap.liquidsoap_startup_test()
try:
self.logger.info("Restarting Liquidsoap")
subprocess.call(['/etc/init.d/airtime-liquidsoap', 'restart'])
#Wait here and poll Liquidsoap until it has started up
self.logger.info("Waiting for Liquidsoap to start")
self.pypo_liquidsoap.liquidsoap_startup_test()
except Exception, e:
self.logger.error(e)
finally:
self.telnet_lock.release()
"""
TODO: This function needs to be way shorter, and refactored :/ - MK
@ -306,6 +317,7 @@ class PypoFetch(Thread):
self.logger.info("No change detected in setting...")
self.update_liquidsoap_connection_status()
@ls_timeout
def update_liquidsoap_connection_status(self):
"""
updates the status of Liquidsoap connection to the streaming server
@ -333,6 +345,7 @@ class PypoFetch(Thread):
self.api_client.notify_liquidsoap_status("OK", stream_id,
str(fake_time))
"""
Process the schedule
- Reads the scheduled entries of a given range (actual time +/-

View file

@ -9,6 +9,7 @@
"""
import telnetlib
from threading import Lock
from timeout import ls_timeout
def create_liquidsoap_annotation(media):
# We need liq_start_next value in the annotate. That is the value that
@ -48,6 +49,7 @@ class TelnetLiquidsoap:
else:
raise Exception("Unexpected list length returned: %s" % output)
@ls_timeout
def queue_clear_all(self):
with self.telnet_lock:
tn = self.__connect()
@ -60,6 +62,7 @@ class TelnetLiquidsoap:
tn.write("exit\n")
self.logger.debug(tn.read_all())
@ls_timeout
def queue_remove(self, queue_id):
with self.telnet_lock:
tn = self.__connect()
@ -71,6 +74,7 @@ class TelnetLiquidsoap:
tn.write("exit\n")
self.logger.debug(tn.read_all())
@ls_timeout
def queue_push(self, queue_id, media_item):
with self.telnet_lock:
if not self.__is_empty(queue_id):
@ -90,6 +94,7 @@ class TelnetLiquidsoap:
tn.write("exit\n")
self.logger.debug(tn.read_all())
@ls_timeout
def stop_web_stream_buffer(self):
with self.telnet_lock:
tn = self.__connect()
@ -105,6 +110,7 @@ class TelnetLiquidsoap:
tn.write("exit\n")
self.logger.debug(tn.read_all())
@ls_timeout
def stop_web_stream_output(self):
with self.telnet_lock:
tn = self.__connect()
@ -116,6 +122,8 @@ class TelnetLiquidsoap:
tn.write("exit\n")
self.logger.debug(tn.read_all())
@ls_timeout
def start_web_stream(self, media_item):
with self.telnet_lock:
tn = self.__connect()
@ -133,6 +141,7 @@ class TelnetLiquidsoap:
self.current_prebuffering_stream_id = None
@ls_timeout
def start_web_stream_buffer(self, media_item):
with self.telnet_lock:
tn = self.__connect()
@ -150,6 +159,7 @@ class TelnetLiquidsoap:
self.current_prebuffering_stream_id = media_item['row_id']
@ls_timeout
def get_current_stream_id(self):
with self.telnet_lock:
tn = self.__connect()
@ -164,6 +174,7 @@ class TelnetLiquidsoap:
return stream_id
@ls_timeout
def disconnect_source(self, sourcename):
self.logger.debug('Disconnecting source: %s', sourcename)
command = ""
@ -179,6 +190,7 @@ class TelnetLiquidsoap:
tn.write('exit\n')
tn.read_all()
@ls_timeout
def telnet_send(self, commands):
with self.telnet_lock:
tn = self.__connect()
@ -189,6 +201,7 @@ class TelnetLiquidsoap:
tn.write('exit\n')
tn.read_all()
@ls_timeout
def switch_source(self, sourcename, status):
self.logger.debug('Switching source: %s to "%s" status', sourcename,
status)
@ -207,6 +220,7 @@ class TelnetLiquidsoap:
self.telnet_send([command])
@ls_timeout
def liquidsoap_get_info(self):
self.logger.debug("Checking to see if Liquidsoap is running")
response = ""
@ -219,6 +233,7 @@ class TelnetLiquidsoap:
return response
@ls_timeout
def update_liquidsoap_station_name(self, station_name):
with self.telnet_lock:
tn = self.__connect()
@ -229,6 +244,7 @@ class TelnetLiquidsoap:
tn.write('exit\n')
tn.read_all()
@ls_timeout
def get_liquidsoap_connection_status(self, current_time):
output = None
with self.telnet_lock:
@ -249,6 +265,7 @@ class TelnetLiquidsoap:
return output
@ls_timeout
def update_liquidsoap_stream_format(self, stream_format):
with self.telnet_lock:
tn = self.__connect()
@ -259,6 +276,7 @@ class TelnetLiquidsoap:
tn.write('exit\n')
tn.read_all()
@ls_timeout
def update_liquidsoap_transition_fade(self, fade):
with self.telnet_lock:
tn = self.__connect()
@ -278,6 +296,7 @@ class DummyTelnetLiquidsoap:
for i in range(4):
self.liquidsoap_mock_queues["s"+str(i)] = []
@ls_timeout
def queue_push(self, queue_id, media_item):
try:
self.telnet_lock.acquire()
@ -293,6 +312,7 @@ class DummyTelnetLiquidsoap:
finally:
self.telnet_lock.release()
@ls_timeout
def queue_remove(self, queue_id):
try:
self.telnet_lock.acquire()