def handle_event_type(self, media_item): if media_item['event_type'] == "kick_out": PypoFetch.disconnect_source(self.logger, self.telnet_lock, "live_dj") elif media_item['event_type'] == "switch_off": PypoFetch.switch_source(self.logger, self.telnet_lock, "live_dj", "off")
def push_to_liquidsoap(self, event_chain): try: for media_item in event_chain: if media_item['type'] == "file": """ Wait maximum 5 seconds (50 iterations) for file to become ready, otherwise give up on it. """ iter_num = 0 while not media_item['file_ready'] and iter_num < 50: time.sleep(0.1) iter_num += 1 if media_item['file_ready']: self.telnet_to_liquidsoap(media_item) else: self.logger.warn("File %s did not become ready in less than 5 seconds. Skipping...", media_item['dst']) elif media_item['type'] == "event": if media_item['event_type'] == "kick_out": PypoFetch.disconnect_source(self.logger, self.telnet_lock, "live_dj") elif media_item['event_type'] == "switch_off": PypoFetch.switch_source(self.logger, self.telnet_lock, "live_dj", "off") except Exception, e: self.logger.error('Pypo Push Exception: %s', e)
def push_to_liquidsoap(self, event_chain): try: for media_item in event_chain: if media_item['type'] == "file": """ Wait maximum 5 seconds (50 iterations) for file to become ready, otherwise give up on it. """ iter_num = 0 while not media_item['file_ready'] and iter_num < 50: time.sleep(0.1) iter_num += 1 if media_item['file_ready']: self.telnet_to_liquidsoap(media_item) else: self.logger.warn( "File %s did not become ready in less than 5 seconds. Skipping...", media_item['dst']) elif media_item['type'] == "event": if media_item['event_type'] == "kick_out": PypoFetch.disconnect_source(self.logger, self.telnet_lock, "live_dj") elif media_item['event_type'] == "switch_off": PypoFetch.switch_source(self.logger, self.telnet_lock, "live_dj", "off") except Exception, e: self.logger.error('Pypo Push Exception: %s', e)
def push_to_liquidsoap(self, event_chain): try: for media_item in event_chain: if media_item['type'] == "file": self.telnet_to_liquidsoap(media_item) elif media_item['type'] == "event": if media_item['event_type'] == "kick_out": PypoFetch.disconnect_source(self.logger, self.telnet_lock, "live_dj") elif media_item['event_type'] == "switch_off": PypoFetch.switch_source(self.logger, self.telnet_lock, "live_dj", "off") except Exception, e: self.logger.error('Pypo Push Exception: %s', e)
def push_to_liquidsoap(self, event_chain): try: for media_item in event_chain: if media_item['type'] == "file": """ Wait maximum 5 seconds (50 iterations) for file to become ready, otherwise give up on it. """ iter_num = 0 while not media_item['file_ready'] and iter_num < 50: time.sleep(0.1) iter_num += 1 if media_item['file_ready']: self.telnet_to_liquidsoap(media_item) else: self.logger.warn("File %s did not become ready in less than 5 seconds. Skipping...", media_item['dst']) elif media_item['type'] == "event": if media_item['event_type'] == "kick_out": PypoFetch.disconnect_source(self.logger, self.telnet_lock, "live_dj") elif media_item['event_type'] == "switch_off": PypoFetch.switch_source(self.logger, self.telnet_lock, "live_dj", "off") elif media_item['type'] == 'stream_buffer_start': self.start_web_stream_buffer(media_item) elif media_item['type'] == "stream_output_start": if media_item['row_id'] != self.current_prebuffering_stream_id: #this is called if the stream wasn't scheduled sufficiently ahead of time #so that the prebuffering stage could take effect. Let's do the prebuffering now. self.start_web_stream_buffer(media_item) self.start_web_stream(media_item) elif media_item['type'] == "stream_buffer_end": self.stop_web_stream_buffer(media_item) elif media_item['type'] == "stream_output_end": self.stop_web_stream_output(media_item) except Exception, e: self.logger.error('Pypo Push Exception: %s', e)
This queue is shared between pypo-fetch and pypo-file, where pypo-file is the consumer. Pypo-fetch will send every schedule it gets to pypo-file and pypo will parse this schedule to determine which file has the highest priority, and retrieve it. """ media_q = Queue() pmh = PypoMessageHandler(pypoFetch_q, recorder_q, config) pmh.daemon = True pmh.start() pfile = PypoFile(media_q, config) pfile.daemon = True pfile.start() pf = PypoFetch(pypoFetch_q, pypoPush_q, media_q, telnet_lock, pypo_liquidsoap, config) pf.daemon = True pf.start() pp = PypoPush(pypoPush_q, telnet_lock, pypo_liquidsoap, config) pp.daemon = True pp.start() recorder = Recorder(recorder_q) recorder.daemon = True recorder.start() stat = ListenerStat() stat.daemon = True stat.start()
This queue is shared between pypo-fetch and pypo-file, where pypo-file is the receiver. Pypo-fetch will send every schedule it gets to pypo-file and pypo will parse this schedule to determine which file has the highest priority, and will retrieve it. """ media_q = Queue() pmh = PypoMessageHandler(pypoFetch_q, recorder_q) pmh.daemon = True pmh.start() pfile = PypoFile(media_q) pfile.daemon = True pfile.start() pf = PypoFetch(pypoFetch_q, pypoPush_q, media_q, telnet_lock) pf.daemon = True pf.start() pp = PypoPush(pypoPush_q, telnet_lock) pp.daemon = True pp.start() recorder = Recorder(recorder_q) recorder.daemon = True recorder.start() stat = ListenerStat() stat.daemon = True stat.start()
This queue is shared between pypo-fetch and pypo-file, where pypo-file is the receiver. Pypo-fetch will send every schedule it gets to pypo-file and pypo will parse this schedule to determine which file has the highest priority, and will retrieve it. """ media_q = Queue() pmh = PypoMessageHandler(pypoFetch_q, recorder_q) pmh.daemon = True pmh.start() pfile = PypoFile(media_q) pfile.daemon = True pfile.start() pf = PypoFetch(pypoFetch_q, pypoPush_q, media_q, telnet_lock) pf.daemon = True pf.start() pp = PypoPush(pypoPush_q, telnet_lock) pp.daemon = True pp.start() recorder = Recorder(recorder_q) recorder.daemon = True recorder.start() # all join() are commented out becase we want to exit entire pypo # if pypofetch is exiting #pmh.join() #recorder.join()
g = Global() while not g.selfcheck(): time.sleep(5) logger = logging.getLogger() if options.test: g.test_api() sys.exit() q = Queue() pp = PypoPush(q) pp.start() pf = PypoFetch(q) pf.start() while True: time.sleep(3600) #pp.join() #pf.join() """ if options.check: try: g.check_schedule() except Exception, e: print e if options.cleanup: try: pf.cleanup('scheduler') except Exception, e:
while not g.selfcheck(): time.sleep(5) logger = logging.getLogger() if options.test: g.test_api() sys.exit() q = Queue() pp = PypoPush(q) pp.start() pf = PypoFetch(q) pf.start() while True: time.sleep(3600) #pp.join() #pf.join() """ if options.check: try: g.check_schedule() except Exception, e: print e if options.cleanup: try: pf.cleanup('scheduler')
is the consumer. Pypo-fetch will send every schedule it gets to pypo-file and pypo will parse this schedule to determine which file has the highest priority, and retrieve it. """ media_q = Queue() # Pass only the configuration sections needed; PypoMessageHandler only needs rabbitmq settings pmh = PypoMessageHandler(pypoFetch_q, recorder_q, config['rabbitmq']) pmh.daemon = True pmh.start() pfile = PypoFile(media_q, config['pypo']) pfile.daemon = True pfile.start() pf = PypoFetch(pypoFetch_q, pypoPush_q, media_q, telnet_lock, pypo_liquidsoap, config['pypo']) pf.daemon = True pf.start() pp = PypoPush(pypoPush_q, telnet_lock, pypo_liquidsoap, config['pypo']) pp.daemon = True pp.start() recorder = Recorder(recorder_q) recorder.daemon = True recorder.start() stat = ListenerStat() stat.daemon = True stat.start()