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
|
@ -30,7 +30,7 @@ class ApiController extends Zend_Controller_Action
|
||||||
->addActionContext('rabbitmq-do-push', 'json')
|
->addActionContext('rabbitmq-do-push', 'json')
|
||||||
->addActionContext('check-live-stream-auth', 'json')
|
->addActionContext('check-live-stream-auth', 'json')
|
||||||
->addActionContext('update-source-status', 'json')
|
->addActionContext('update-source-status', 'json')
|
||||||
->addActionContext('get-switch-status', 'json')
|
->addActionContext('get-bootstrap-info', 'json')
|
||||||
->initContext();
|
->initContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1000,13 +1000,15 @@ class ApiController extends Zend_Controller_Action
|
||||||
Application_Model_RabbitMq::PushSchedule();
|
Application_Model_RabbitMq::PushSchedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSwitchStatusAction(){
|
public function getBootstrapInfoAction(){
|
||||||
$live_dj = Application_Model_Preference::GetSourceSwitchStatus('live_dj');
|
$live_dj = Application_Model_Preference::GetSourceSwitchStatus('live_dj');
|
||||||
$master_dj = Application_Model_Preference::GetSourceSwitchStatus('master_dj');
|
$master_dj = Application_Model_Preference::GetSourceSwitchStatus('master_dj');
|
||||||
$scheduled_play = Application_Model_Preference::GetSourceSwitchStatus('scheduled_play');
|
$scheduled_play = Application_Model_Preference::GetSourceSwitchStatus('scheduled_play');
|
||||||
|
|
||||||
$res = array("live_dj"=>$live_dj, "master_dj"=>$master_dj, "scheduled_play"=>$scheduled_play);
|
$res = array("live_dj"=>$live_dj, "master_dj"=>$master_dj, "scheduled_play"=>$scheduled_play);
|
||||||
$this->view->status = $res;
|
$this->view->switch_status = $res;
|
||||||
|
$this->view->station_name = Application_Model_Preference::GetStationName();
|
||||||
|
$this->view->stream_label = Application_Model_Preference::GetStreamLabelFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is used but Liquidsoap to check authentication of live streams*/
|
/* This is used but Liquidsoap to check authentication of live streams*/
|
||||||
|
|
|
@ -154,10 +154,6 @@ class Application_Model_StreamSetting {
|
||||||
} else if ($key == "output_sound_device_type") {
|
} else if ($key == "output_sound_device_type") {
|
||||||
$sql = "UPDATE cc_stream_setting SET value='$d' WHERE keyname='$key'";
|
$sql = "UPDATE cc_stream_setting SET value='$d' WHERE keyname='$key'";
|
||||||
$CC_DBC->query($sql);
|
$CC_DBC->query($sql);
|
||||||
} else if ($key == "streamFormat"){
|
|
||||||
// this goes into cc_pref table
|
|
||||||
Logging::log("Insert stream label format $d");
|
|
||||||
Application_Model_Preference::SetStreamLabelFormat($d);
|
|
||||||
} else if (is_array($d)) {
|
} else if (is_array($d)) {
|
||||||
$temp = explode('_', $key);
|
$temp = explode('_', $key);
|
||||||
$prefix = $temp[0];
|
$prefix = $temp[0];
|
||||||
|
|
|
@ -107,5 +107,5 @@ check_live_stream_auth = 'check-live-stream-auth/format/json/api_key/%%api_key%%
|
||||||
#URL to update source status
|
#URL to update source status
|
||||||
update_source_status = 'update-source-status/format/json/api_key/%%api_key%%/sourcename/%%sourcename%%/status/%%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)
|
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
|
logger = self.logger
|
||||||
try:
|
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"])
|
url = url.replace("%%api_key%%", self.config["api_key"])
|
||||||
|
|
||||||
req = urllib2.Request(url)
|
req = urllib2.Request(url)
|
||||||
response = urllib2.urlopen(req).read()
|
response = urllib2.urlopen(req).read()
|
||||||
response = json.loads(response)
|
response = json.loads(response)
|
||||||
logger.info("Switch status retrieved %s", response)
|
logger.info("Bootstrap info retrieved %s", response)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
import traceback
|
import traceback
|
||||||
top = traceback.format_exc()
|
top = traceback.format_exc()
|
||||||
|
|
|
@ -139,16 +139,19 @@ class PypoFetch(Thread):
|
||||||
self.logger.error(str(e))
|
self.logger.error(str(e))
|
||||||
finally:
|
finally:
|
||||||
self.telnet_lock.release()
|
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):
|
def set_bootstrap_variables(self):
|
||||||
self.logger.debug('Checking current switch status with Airtime')
|
self.logger.debug('Getting information needed on bootstrap from Airtime')
|
||||||
switch_status = self.api_client.get_switch_status()
|
info = self.api_client.get_bootstrap_info()
|
||||||
self.logger.debug('switch_status:%s',switch_status)
|
self.logger.debug('info:%s',info)
|
||||||
for k, v in switch_status['status'].iteritems():
|
for k, v in info['switch_status'].iteritems():
|
||||||
self.switch_source(k, v)
|
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):
|
def regenerateLiquidsoapConf(self, setting_p):
|
||||||
existing = {}
|
existing = {}
|
||||||
|
@ -509,7 +512,7 @@ class PypoFetch(Thread):
|
||||||
if success:
|
if success:
|
||||||
self.logger.info("Bootstrap schedule received: %s", self.schedule_data)
|
self.logger.info("Bootstrap schedule received: %s", self.schedule_data)
|
||||||
self.process_schedule(self.schedule_data)
|
self.process_schedule(self.schedule_data)
|
||||||
self.check_switch_status()
|
self.set_bootstrap_variables()
|
||||||
|
|
||||||
loops = 1
|
loops = 1
|
||||||
while True:
|
while True:
|
||||||
|
|
Loading…
Reference in New Issue