CC-3484: Pypo: On bootup, it should grab station name and stream
label for liquidsoap - fixed - created new function set_bootstrap_variables()
This commit is contained in:
parent
e76cffd8b0
commit
d4142f8b8b
5 changed files with 21 additions and 20 deletions
|
@ -107,5 +107,5 @@ check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%
|
|||
#URL to update source status
|
||||
update_source_status = 'update-source-status/format/json/api_key/%%api_key%%/sourcename/%%sourcename%%/status/%%status%%'
|
||||
|
||||
get_switch_status = 'get-switch-status/format/json/api_key/%%api_key%%'
|
||||
get_bootstrap_info = 'get-bootstrap-info/format/json/api_key/%%api_key%%'
|
||||
|
||||
|
|
|
@ -646,19 +646,19 @@ class AirTimeApiClient(ApiClientInterface):
|
|||
logger.error("traceback: %s", top)
|
||||
|
||||
"""
|
||||
Retrive current switch status of streams sources
|
||||
Retrive infomations needed on bootstrap time
|
||||
"""
|
||||
def get_switch_status(self):
|
||||
def get_bootstrap_info(self):
|
||||
logger = self.logger
|
||||
try:
|
||||
url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["get_switch_status"])
|
||||
url = "http://%s:%s/%s/%s" % (self.config["base_url"], str(self.config["base_port"]), self.config["api_base"], self.config["get_bootstrap_info"])
|
||||
|
||||
url = url.replace("%%api_key%%", self.config["api_key"])
|
||||
|
||||
req = urllib2.Request(url)
|
||||
response = urllib2.urlopen(req).read()
|
||||
response = json.loads(response)
|
||||
logger.info("Switch status retrieved %s", response)
|
||||
logger.info("Bootstrap info retrieved %s", response)
|
||||
except Exception, e:
|
||||
import traceback
|
||||
top = traceback.format_exc()
|
||||
|
|
|
@ -139,16 +139,19 @@ class PypoFetch(Thread):
|
|||
self.logger.error(str(e))
|
||||
finally:
|
||||
self.telnet_lock.release()
|
||||
|
||||
|
||||
"""
|
||||
This check current switch status from Airtime and update the status
|
||||
grabs some information that are needed to be set on bootstrap time
|
||||
and configures them
|
||||
"""
|
||||
def check_switch_status(self):
|
||||
self.logger.debug('Checking current switch status with Airtime')
|
||||
switch_status = self.api_client.get_switch_status()
|
||||
self.logger.debug('switch_status:%s',switch_status)
|
||||
for k, v in switch_status['status'].iteritems():
|
||||
def set_bootstrap_variables(self):
|
||||
self.logger.debug('Getting information needed on bootstrap from Airtime')
|
||||
info = self.api_client.get_bootstrap_info()
|
||||
self.logger.debug('info:%s',info)
|
||||
for k, v in info['switch_status'].iteritems():
|
||||
self.switch_source(k, v)
|
||||
self.update_liquidsoap_stream_format(info['stream_label'])
|
||||
self.update_liquidsoap_station_name(info['station_name'])
|
||||
|
||||
def regenerateLiquidsoapConf(self, setting_p):
|
||||
existing = {}
|
||||
|
@ -509,7 +512,7 @@ class PypoFetch(Thread):
|
|||
if success:
|
||||
self.logger.info("Bootstrap schedule received: %s", self.schedule_data)
|
||||
self.process_schedule(self.schedule_data)
|
||||
self.check_switch_status()
|
||||
self.set_bootstrap_variables()
|
||||
|
||||
loops = 1
|
||||
while True:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue