CC-2089: create "cancel show" command for pypo

- done
This commit is contained in:
James 2011-08-29 11:54:44 -04:00
parent 59a3076e42
commit 83bba9532e
3 changed files with 25 additions and 8 deletions

View file

@ -695,6 +695,8 @@ class ScheduleController extends Zend_Controller_Action
$show = new ShowInstance($showInstanceId); $show = new ShowInstance($showInstanceId);
$show->clearShow(); $show->clearShow();
$show->deleteShow(); $show->deleteShow();
// send 'cancel-current-show' command to pypo
RabbitMq::SendMessageToPypo("cancel_current_show", array());
} }
} }

View file

@ -105,9 +105,24 @@ class PypoFetch(Thread):
elif (command == 'update_stream_setting'): elif (command == 'update_stream_setting'):
logger.info("Updating stream setting...") logger.info("Updating stream setting...")
self.regenerateLiquidsoapConf(m['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 # ACK the message to take it off the queue
message.ack() 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): def regenerateLiquidsoapConf(self, setting):
logger = logging.getLogger('fetch') logger = logging.getLogger('fetch')
existing = {} existing = {}

View file

@ -51,7 +51,7 @@ class PypoPush(Thread):
#toggle between "stop" and "play". Keeps track of the state of #toggle between "stop" and "play". Keeps track of the state of
#liquidsoap #liquidsoap
self.liquidsoap_state_play = True #self.liquidsoap_state_play = True
def set_export_source(self, export_source): def set_export_source(self, export_source):
self.export_source = export_source self.export_source = export_source
@ -80,7 +80,7 @@ class PypoPush(Thread):
schedule = self.schedule schedule = self.schedule
playlists = self.playlists playlists = self.playlists
currently_on_air = False #currently_on_air = False
if schedule: if schedule:
playedItems = self.load_schedule_tracker() playedItems = self.load_schedule_tracker()
@ -101,7 +101,7 @@ class PypoPush(Thread):
logger.debug('Preparing to push playlist scheduled at: %s', pkey) logger.debug('Preparing to push playlist scheduled at: %s', pkey)
playlist = schedule[pkey] playlist = schedule[pkey]
currently_on_air = True #currently_on_air = True
# We have a match, replace the current playlist and # We have a match, replace the current playlist and
# force liquidsoap to refresh. # force liquidsoap to refresh.
@ -123,12 +123,12 @@ class PypoPush(Thread):
show_start = schedule[pkey]['show_start'] show_start = schedule[pkey]['show_start']
show_end = schedule[pkey]['show_end'] show_end = schedule[pkey]['show_end']
if show_start <= str_tnow_s and str_tnow_s < show_end: """if show_start <= str_tnow_s and str_tnow_s < show_end:
currently_on_air = True currently_on_air = True"""
else: else:
pass 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.') logger.debug('Notifying Liquidsoap to stop playback.')
try: try:
tn = telnetlib.Telnet(LS_HOST, LS_PORT) tn = telnetlib.Telnet(LS_HOST, LS_PORT)
@ -139,7 +139,7 @@ class PypoPush(Thread):
logger.debug(e) logger.debug(e)
logger.debug('Could not connect to liquidsoap') logger.debug('Could not connect to liquidsoap')
self.liquidsoap_state_play = False self.liquidsoap_state_play = False"""
def push_liquidsoap(self, pkey, schedule, playlists): def push_liquidsoap(self, pkey, schedule, playlists):
@ -190,7 +190,7 @@ class PypoPush(Thread):
tn.write("exit\n") tn.write("exit\n")
logger.debug(tn.read_all()) logger.debug(tn.read_all())
self.liquidsoap_state_play = True #self.liquidsoap_state_play = True
status = 1 status = 1
except Exception, e: except Exception, e: