Exemplo n.º 1
0
    def __init__(self, pypoFetch_q, pypoPush_q, media_q, pypo_liquidsoap, 
            config):
        Thread.__init__(self)

        self.api_client = api_client.AirtimeApiClient()
        self.fetch_queue = pypoFetch_q
        self.push_queue = pypoPush_q
        self.media_prepare_queue = media_q
        self.last_update_schedule_timestamp = time.time()
        self.config = config
        self.listener_timeout = POLL_INTERVAL

        self.logger = logging.getLogger()
        self.pypo_liquidsoap = pypo_liquidsoap

        self.cache_dir = os.path.join(config["cache_dir"], "scheduler")
        self.logger.debug("Cache dir %s", self.cache_dir)

        try:
            if not os.path.isdir(dir):
                """
                We get here if path does not exist, or path does exist but
                is a file. We are not handling the second case, but don't
                think we actually care about handling it.
                """
                self.logger.debug("Cache dir does not exist. Creating...")
                os.makedirs(dir)
        except Exception, e:
            pass
Exemplo n.º 2
0
 def __init__(self, logger=None):
     Thread.__init__(self)
     self.api_client = api_client.AirtimeApiClient()
     if logger is None:
         self.logger = logging.getLogger()
     else:
         self.logger = logger
Exemplo n.º 3
0
    def __init__(self, q, pypo_liquidsoap):
        Thread.__init__(self)
        self.api_client = api_client.AirtimeApiClient()
        self.queue = q

        self.logger = logging.getLogger('push')

        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()
Exemplo n.º 4
0
    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()
Exemplo n.º 5
0
 def setUp(self):
     test_path = prepare_tests.api_client_path
     print("Running from api_config: %s" % test_path)
     if not os.path.exists(test_path):
         print("path for config does not exist: '%s' % test_path")
         # TODO : is there a cleaner way to exit the unit testing?
         sys.exit(1)
     self.apc = apc.AirtimeApiClient(config_path=test_path)
     self.apc.register_component("api-client-tester")
     # All of the following requests should error out in some way
     self.bad_requests = [
         {
             'mode': 'foo',
             'is_record': 0
         },
         {
             'mode': 'bar',
             'is_record': 1
         },
         {
             'no_mode': 'at_all'
         },
     ]
Exemplo n.º 6
0
if __name__ == '__main__':
    logger.info('###########################################')
    logger.info('#             *** pypo  ***               #')
    logger.info('#   Liquidsoap Scheduled Playout System   #')
    logger.info('###########################################')

    #Although all of our calculations are in UTC, it is useful to know what timezone
    #the local machine is, so that we have a reference for what time the actual
    #log entries were made
    logger.info("Timezone: %s" % str(time.tzname))
    logger.info("UTC time: %s" % str(datetime.utcnow()))

    signal.signal(signal.SIGINT, keyboardInterruptHandler)

    api_client = api_client.AirtimeApiClient()
    g = Global(api_client)

    while not g.selfcheck():
        time.sleep(5)

    success = False
    while not success:
        try:
            api_client.register_component('pypo')
            success = True
        except Exception, e:
            logger.error(str(e))
            time.sleep(10)

    telnet_lock = Lock()
Exemplo n.º 7
0
# add ch to logger
logger.addHandler(ch)

if os.geteuid() != 0:
    print 'Must be a root user.'
    sys.exit(1)

# loading config file
try:
    config = ConfigObj('/etc/airtime/media-monitor.cfg')
except Exception, e:
    print('Error loading config file: %s', e)
    sys.exit(1)

api_client = apc.AirtimeApiClient(config)

try:
    # keep getting few rows at a time for current music_dir (stor
    # or watched folder).
    subtotal = 0
    while True:
        # return a list of pairs where the first value is the
        # file's database row id and the second value is the
        # filepath
        files = api_client.get_files_without_silan_value()
        total_files = len(files)
        if total_files == 0: break
        processed_data = []
        total = 0
        for f in files:
Exemplo n.º 8
0
 def setUp(self):
     self.ac = ac.AirtimeApiClient(logger=get_logger(),
                                   config_path=prepare_tests.real_config)
Exemplo n.º 9
0
 def selfcheck(self):
     self.api_client = api_client.AirtimeApiClient()
     return self.api_client.is_server_compatible()
Exemplo n.º 10
0
 def __init__(self):
     self.api_client = api_client.AirtimeApiClient()
def api_client(logger):
    """
    api_client returns the correct instance of AirtimeApiClient. Although there is only one
    instance to choose from at the moment.
    """
    return apc.AirtimeApiClient(logger)