-Remove useless api_client interface

This commit is contained in:
Martin Konecny 2012-07-12 16:51:11 -04:00
parent 7ce4934cdc
commit 62287a2313
9 changed files with 28 additions and 156 deletions

View file

@ -1,7 +1,6 @@
import logging
import sys
from api_clients import api_client
from configobj import ConfigObj
def generate_liquidsoap_config(ss):
data = ss['msg']
@ -10,30 +9,22 @@ def generate_liquidsoap_config(ss):
fh.write("# THIS FILE IS AUTO GENERATED. DO NOT CHANGE!! #\n")
fh.write("################################################\n")
for d in data:
buffer = d[u'keyname'] + " = "
str_buffer = d[u'keyname'] + " = "
if(d[u'type'] == 'string'):
temp = d[u'value']
buffer += '"%s"' % temp
str_buffer += '"%s"' % temp
else:
temp = d[u'value']
if(temp == ""):
temp = "0"
buffer += temp
buffer += "\n"
fh.write(api_client.encode_to(buffer))
str_buffer += temp
str_buffer += "\n"
fh.write(api_client.encode_to(str_buffer))
fh.write('log_file = "/var/log/airtime/pypo-liquidsoap/<script>.log"\n')
fh.close()
PATH_INI_FILE = '/etc/airtime/pypo.cfg'
try:
config = ConfigObj(PATH_INI_FILE)
except Exception, e:
print 'Error loading config file: ', e
sys.exit(1)
logging.basicConfig(format='%(message)s')
ac = api_client.api_client_factory(config, logging.getLogger())
ac = api_client(logging.getLogger())
ss = ac.get_stream_setting()
if ss is not None:

View file

@ -1,27 +1,18 @@
from api_clients import *
from configobj import ConfigObj
import sys
import json
try:
config = ConfigObj('/etc/airtime/pypo.cfg')
except Exception, e:
print 'error: ', e
sys.exit()
api_clients = api_client.api_client_factory(config)
api_clients = api_client.AirTimeApiClient()
dj_type = sys.argv[1]
username = sys.argv[2]
password = sys.argv[3]
type = ''
source_type = ''
if dj_type == '--master':
type = 'master'
source_type = 'master'
elif dj_type == '--dj':
type = 'dj'
source_type = 'dj'
response = api_clients.check_live_stream_auth(username, password, type)
print response['msg']
print response['msg']

View file

@ -107,10 +107,10 @@ except Exception, e:
class Global:
def __init__(self):
self.api_client = api_client.api_client_factory(config)
self.api_client = api_client.AirTimeApiClient()
def selfcheck(self):
self.api_client = api_client.api_client_factory(config)
self.api_client = api_client.AirTimeApiClient()
return self.api_client.is_server_compatible()
def test_api(self):
@ -172,7 +172,7 @@ if __name__ == '__main__':
g.test_api()
sys.exit()
api_client = api_client.api_client_factory(config)
api_client = api_client.AirTimeApiClient()
api_client.register_component("pypo")
pypoFetch_q = Queue()

View file

@ -40,7 +40,7 @@ except Exception, e:
class PypoFetch(Thread):
def __init__(self, pypoFetch_q, pypoPush_q, media_q, telnet_lock):
Thread.__init__(self)
self.api_client = api_client.api_client_factory(config)
self.api_client = api_client.AirTimeApiClient()
self.fetch_queue = pypoFetch_q
self.push_queue = pypoPush_q
self.media_prepare_queue = media_q

View file

@ -64,7 +64,7 @@ except Exception, e:
class Notify:
def __init__(self):
self.api_client = api_client.api_client_factory(config)
self.api_client = api_client.AirTimeApiClient()
def notify_media_start_playing(self, data, media_id):
logger = logging.getLogger("notify")

View file

@ -42,7 +42,7 @@ except Exception, e:
class PypoPush(Thread):
def __init__(self, q, telnet_lock):
Thread.__init__(self)
self.api_client = api_client.api_client_factory(config)
self.api_client = api_client.AirTimeApiClient()
self.queue = q
self.telnet_lock = telnet_lock

View file

@ -46,7 +46,7 @@ class ShowRecorder(Thread):
def __init__ (self, show_instance, show_name, filelength, start_time):
Thread.__init__(self)
self.logger = logging.getLogger('recorder')
self.api_client = api_client.api_client_factory(config, self.logger)
self.api_client = api_client(self.logger)
self.filelength = filelength
self.start_time = start_time
self.show_instance = show_instance
@ -168,7 +168,7 @@ class Recorder(Thread):
def __init__(self, q):
Thread.__init__(self)
self.logger = logging.getLogger('recorder')
self.api_client = api_client.api_client_factory(config, self.logger)
self.api_client = api_client(self.logger)
self.api_client.register_component("show-recorder")
self.sr = None
self.shows_to_record = {}