From 83bba9532e510df3c8cb0d644b57f9d5f5779d23 Mon Sep 17 00:00:00 2001 From: James Date: Mon, 29 Aug 2011 11:54:44 -0400 Subject: [PATCH] CC-2089: create "cancel show" command for pypo - done --- .../controllers/ScheduleController.php | 2 ++ python_apps/pypo/pypofetch.py | 15 +++++++++++++++ python_apps/pypo/pypopush.py | 16 ++++++++-------- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/airtime_mvc/application/controllers/ScheduleController.php b/airtime_mvc/application/controllers/ScheduleController.php index 1dfd4bcb9..8b0368daa 100644 --- a/airtime_mvc/application/controllers/ScheduleController.php +++ b/airtime_mvc/application/controllers/ScheduleController.php @@ -695,6 +695,8 @@ class ScheduleController extends Zend_Controller_Action $show = new ShowInstance($showInstanceId); $show->clearShow(); $show->deleteShow(); + // send 'cancel-current-show' command to pypo + RabbitMq::SendMessageToPypo("cancel_current_show", array()); } } diff --git a/python_apps/pypo/pypofetch.py b/python_apps/pypo/pypofetch.py index 7ad930170..14193cac8 100755 --- a/python_apps/pypo/pypofetch.py +++ b/python_apps/pypo/pypofetch.py @@ -105,9 +105,24 @@ class PypoFetch(Thread): elif (command == 'update_stream_setting'): logger.info("Updating stream setting...") self.regenerateLiquidsoapConf(m['setting']) + elif (command == 'cancel_current_show'): + logger.info("Cancel current show command received...") + self.stop_current_show() # ACK the message to take it off the queue message.ack() + def stop_current_show(self): + logger = logging.getLogger('fetch') + logger.debug('Notifying Liquidsoap to stop playback.') + try: + tn = telnetlib.Telnet(LS_HOST, LS_PORT) + tn.write('source.skip\n') + tn.write('exit\n') + tn.read_all() + except Exception, e: + logger.debug(e) + logger.debug('Could not connect to liquidsoap') + def regenerateLiquidsoapConf(self, setting): logger = logging.getLogger('fetch') existing = {} diff --git a/python_apps/pypo/pypopush.py b/python_apps/pypo/pypopush.py index a9dc79a14..0a7d87106 100755 --- a/python_apps/pypo/pypopush.py +++ b/python_apps/pypo/pypopush.py @@ -51,7 +51,7 @@ class PypoPush(Thread): #toggle between "stop" and "play". Keeps track of the state of #liquidsoap - self.liquidsoap_state_play = True + #self.liquidsoap_state_play = True def set_export_source(self, export_source): self.export_source = export_source @@ -80,7 +80,7 @@ class PypoPush(Thread): schedule = self.schedule playlists = self.playlists - currently_on_air = False + #currently_on_air = False if schedule: playedItems = self.load_schedule_tracker() @@ -101,7 +101,7 @@ class PypoPush(Thread): logger.debug('Preparing to push playlist scheduled at: %s', pkey) playlist = schedule[pkey] - currently_on_air = True + #currently_on_air = True # We have a match, replace the current playlist and # force liquidsoap to refresh. @@ -123,12 +123,12 @@ class PypoPush(Thread): show_start = schedule[pkey]['show_start'] show_end = schedule[pkey]['show_end'] - if show_start <= str_tnow_s and str_tnow_s < show_end: - currently_on_air = True + """if show_start <= str_tnow_s and str_tnow_s < show_end: + currently_on_air = True""" else: pass - if not currently_on_air and self.liquidsoap_state_play: + """if not currently_on_air and self.liquidsoap_state_play: logger.debug('Notifying Liquidsoap to stop playback.') try: tn = telnetlib.Telnet(LS_HOST, LS_PORT) @@ -139,7 +139,7 @@ class PypoPush(Thread): logger.debug(e) logger.debug('Could not connect to liquidsoap') - self.liquidsoap_state_play = False + self.liquidsoap_state_play = False""" def push_liquidsoap(self, pkey, schedule, playlists): @@ -190,7 +190,7 @@ class PypoPush(Thread): tn.write("exit\n") logger.debug(tn.read_all()) - self.liquidsoap_state_play = True + #self.liquidsoap_state_play = True status = 1 except Exception, e: