CC-3437: Live Stream: Liquidsoap(Pypo) should preserve the last switch status
when it restarts. - Pypo contacts airtime on bootup and ask what the last switch status was
This commit is contained in:
parent
4eefc05366
commit
3c6aff093e
|
@ -107,3 +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%%'
|
||||
|
||||
|
|
|
@ -602,7 +602,7 @@ class AirTimeApiClient(ApiClientInterface):
|
|||
This function updates status of mounted file system information on airtime
|
||||
"""
|
||||
def update_file_system_mount(self, added_dir, removed_dir):
|
||||
logger = logging.getLogger()
|
||||
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["update_fs_mount"])
|
||||
|
||||
|
@ -629,7 +629,7 @@ class AirTimeApiClient(ApiClientInterface):
|
|||
and will call appropriate function on Airtime.
|
||||
"""
|
||||
def handle_watched_dir_missing(self, dir):
|
||||
logger = logging.getLogger()
|
||||
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["handle_watched_dir_missing"])
|
||||
|
||||
|
@ -644,4 +644,25 @@ class AirTimeApiClient(ApiClientInterface):
|
|||
top = traceback.format_exc()
|
||||
logger.error('Exception: %s', e)
|
||||
logger.error("traceback: %s", top)
|
||||
|
||||
|
||||
"""
|
||||
Retrive current switch status of streams sources
|
||||
"""
|
||||
def get_switch_status(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 = 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)
|
||||
except Exception, e:
|
||||
import traceback
|
||||
top = traceback.format_exc()
|
||||
logger.error('Exception: %s', e)
|
||||
logger.error("traceback: %s", top)
|
||||
return response
|
||||
|
|
@ -125,6 +125,16 @@ class PypoFetch(Thread):
|
|||
except Exception, e:
|
||||
self.logger.debug(e)
|
||||
self.logger.debug('Could not connect to liquidsoap')
|
||||
|
||||
"""
|
||||
This check current switch status from Airtime and update the status
|
||||
"""
|
||||
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():
|
||||
self.switch_source(k, v)
|
||||
|
||||
def stop_current_show(self):
|
||||
self.logger.debug('Notifying Liquidsoap to stop playback.')
|
||||
|
@ -249,8 +259,7 @@ class PypoFetch(Thread):
|
|||
"""
|
||||
updates the status of liquidsoap connection to the streaming server
|
||||
This fucntion updates the bootup time variable in liquidsoap script
|
||||
"""
|
||||
def update_liquidsoap_connection_status(self):
|
||||
"""
|
||||
tn = telnetlib.Telnet(LS_HOST, LS_PORT)
|
||||
# update the boot up time of liquidsoap. Since liquidsoap is not restarting,
|
||||
# we are manually adjusting the bootup time variable so the status msg will get
|
||||
|
@ -512,6 +521,7 @@ class PypoFetch(Thread):
|
|||
if success:
|
||||
self.logger.info("Bootstrap schedule received: %s", self.schedule_data)
|
||||
self.process_schedule(self.schedule_data, True)
|
||||
self.check_switch_status()
|
||||
|
||||
loops = 1
|
||||
while True:
|
||||
|
|
Loading…
Reference in New Issue