Esempio n. 1
0
class PypoPush(Thread):
    def __init__(self, q, telnet_lock, pypo_liquidsoap, config):
        Thread.__init__(self)
        self.api_client = api_client.AirtimeApiClient()
        self.queue = q

        self.telnet_lock = telnet_lock
        self.config = config

        self.pushed_objects = {}
        self.logger = logging.getLogger('push')
        self.current_prebuffering_stream_id = None
        self.queue_id = 0

        self.future_scheduled_queue = Queue()
        self.pypo_liquidsoap = pypo_liquidsoap

        self.plq = PypoLiqQueue(self.future_scheduled_queue, \
                self.pypo_liquidsoap, \
                self.logger)
        self.plq.daemon = True
        self.plq.start()

    def main(self):
        loops = 0
        heartbeat_period = math.floor(30 / PUSH_INTERVAL)

        media_schedule = None

        while True:
            try:
                media_schedule = self.queue.get(block=True)
            except Exception, e:
                self.logger.error(str(e))
                raise
            else:
                self.logger.debug(media_schedule)
                #separate media_schedule list into currently_playing and
                #scheduled_for_future lists
                currently_playing, scheduled_for_future = \
                        self.separate_present_future(media_schedule)

                self.pypo_liquidsoap.verify_correct_present_media(
                    currently_playing)
                self.future_scheduled_queue.put(scheduled_for_future)

            if loops % heartbeat_period == 0:
                self.logger.info("heartbeat")
                loops = 0
            loops += 1
Esempio n. 2
0
class PypoPush(Thread):
    def __init__(self, q, telnet_lock, pypo_liquidsoap, config):
        Thread.__init__(self)
        self.api_client = api_client.AirtimeApiClient()
        self.queue = q

        self.telnet_lock = telnet_lock
        self.config = config

        self.pushed_objects = {}
        self.logger = logging.getLogger('push')
        self.current_prebuffering_stream_id = None
        self.queue_id = 0

        self.future_scheduled_queue = Queue()
        self.pypo_liquidsoap = pypo_liquidsoap

        self.plq = PypoLiqQueue(self.future_scheduled_queue, \
                self.pypo_liquidsoap, \
                self.logger)
        self.plq.daemon = True
        self.plq.start()


    def main(self):
        loops = 0
        heartbeat_period = math.floor(30 / PUSH_INTERVAL)

        media_schedule = None

        while True:
            try:
                media_schedule = self.queue.get(block=True)
            except Exception, e:
                self.logger.error(str(e))
                raise
            else:
                self.logger.debug(media_schedule)
                #separate media_schedule list into currently_playing and
                #scheduled_for_future lists
                currently_playing, scheduled_for_future = \
                        self.separate_present_future(media_schedule)

                self.pypo_liquidsoap.verify_correct_present_media(currently_playing)
                self.future_scheduled_queue.put(scheduled_for_future)

            if loops % heartbeat_period == 0:
                self.logger.info("heartbeat")
                loops = 0
            loops += 1
Esempio n. 3
0
class PypoPush(Thread):
    def __init__(self, q, pypo_liquidsoap):
        
        print 'init PypoPush'
        
        Thread.__init__(self)
        self.api_client = api_client.AirtimeApiClient()
        self.queue = q

        self.logger = logger

        self.future_scheduled_queue = Queue()
        self.pypo_liquidsoap = pypo_liquidsoap

        self.plq = PypoLiqQueue(self.future_scheduled_queue, \
                self.pypo_liquidsoap, \
                self.logger)
        self.plq.daemon = True
        self.plq.start()


    def main(self):
        media_schedule = None

        while True:
            try:
                print 'try to get media_schedule'
                media_schedule = self.queue.get(block=True)
            except Exception, e:
                self.logger.error(str(e))
                raise
            else:
                #self.logger.debug(media_schedule)
                #separate media_schedule list into currently_playing and
                #scheduled_for_future lists
                currently_playing, scheduled_for_future = \
                        self.separate_present_future(media_schedule)

                """
                print 'currently:'
                print currently_playing
                print 'future:'
                print scheduled_for_future
                """
                self.pypo_liquidsoap.verify_correct_present_media(
                        currently_playing)
                self.future_scheduled_queue.put(scheduled_for_future)
Esempio n. 4
0
class PypoPush(Thread):
    def __init__(self, q, pypo_liquidsoap):

        print 'init PypoPush'

        Thread.__init__(self)
        self.api_client = api_client.AirtimeApiClient()
        self.queue = q

        self.logger = logger

        self.future_scheduled_queue = Queue()
        self.pypo_liquidsoap = pypo_liquidsoap

        self.plq = PypoLiqQueue(self.future_scheduled_queue, \
                self.pypo_liquidsoap, \
                self.logger)
        self.plq.daemon = True
        self.plq.start()

    def main(self):
        media_schedule = None

        while True:
            try:
                print 'try to get media_schedule'
                media_schedule = self.queue.get(block=True)
            except Exception, e:
                self.logger.error(str(e))
                raise
            else:
                #self.logger.debug(media_schedule)
                #separate media_schedule list into currently_playing and
                #scheduled_for_future lists
                currently_playing, scheduled_for_future = \
                        self.separate_present_future(media_schedule)
                """
                print 'currently:'
                print currently_playing
                print 'future:'
                print scheduled_for_future
                """
                self.pypo_liquidsoap.verify_correct_present_media(
                    currently_playing)
                self.future_scheduled_queue.put(scheduled_for_future)
Esempio n. 5
0
liq_queue_tracker = {
        "s0": None,
        "s1": None,
        "s2": None,
        "s3": None,
        }

#dummy_telnet_liquidsoap = DummyTelnetLiquidsoap(telnet_lock, logging)
dummy_telnet_liquidsoap = TelnetLiquidsoap(telnet_lock, logging, \
        "localhost", \
        1234)

plq = PypoLiqQueue(pypoLiq_q, telnet_lock, logging, liq_queue_tracker, \
        dummy_telnet_liquidsoap)
plq.daemon = True
plq.start()


print "Time now: %s" % datetime.utcnow()

media_schedule = {}

start_dt = datetime.utcnow() + timedelta(seconds=1)
end_dt = datetime.utcnow() + timedelta(seconds=6)

media_schedule[start_dt] = {"id": 5, \
        "type":"file", \
        "row_id":9, \
        "uri":"", \
        "dst":"/home/martin/Music/ipod/Hot Chocolate - You Sexy Thing.mp3", \
        "fade_in":0, \
Esempio n. 6
0
liq_queue_tracker = {
    "s0": None,
    "s1": None,
    "s2": None,
    "s3": None,
}

#dummy_telnet_liquidsoap = DummyTelnetLiquidsoap(telnet_lock, logging)
dummy_telnet_liquidsoap = TelnetLiquidsoap(telnet_lock, logging, \
        "localhost", \
        1234)

plq = PypoLiqQueue(pypoLiq_q, telnet_lock, logging, liq_queue_tracker, \
        dummy_telnet_liquidsoap)
plq.daemon = True
plq.start()

print "Time now: %s" % datetime.utcnow()

media_schedule = {}

start_dt = datetime.utcnow() + timedelta(seconds=1)
end_dt = datetime.utcnow() + timedelta(seconds=6)

media_schedule[start_dt] = {"id": 5, \
        "type":"file", \
        "row_id":9, \
        "uri":"", \
        "dst":"/home/martin/Music/ipod/Hot Chocolate - You Sexy Thing.mp3", \
        "fade_in":0, \
        "fade_out":0, \