refactor(playout): move liq io to liq_client

This commit is contained in:
jo 2022-08-17 16:00:12 +02:00 committed by Kyle Robbertze
parent fd2381624a
commit a9cd1fb3df
2 changed files with 15 additions and 9 deletions

View File

@ -59,6 +59,11 @@ class LiquidsoapClient:
raise LiquidsoapClientError("could not get liquidsoap version") raise LiquidsoapClientError("could not get liquidsoap version")
def outputs_connection_status(self):
with self.conn:
self.conn.write("streams.connection_status")
return self.conn.read().splitlines()[0]
def queues_remove(self, *queues: int) -> None: def queues_remove(self, *queues: int) -> None:
with self.conn: with self.conn:
for queue_id in queues: for queue_id in queues:
@ -125,6 +130,10 @@ class LiquidsoapClient:
if input_fade_transition is not None: if input_fade_transition is not None:
self._set_var("default_dj_fade", input_fade_transition) self._set_var("default_dj_fade", input_fade_transition)
def boot_timestamp_update(self, timestamp: float):
with self.conn:
self._set_var("bootup_time", str(timestamp))
def restart(self): def restart(self):
logger.warning("restarting Liquidsoap") logger.warning("restarting Liquidsoap")

View File

@ -175,16 +175,13 @@ class PypoFetch(Thread):
""" """
try: try:
with self.liq_client.conn: # update the boot up time of Liquidsoap. Since Liquidsoap is not restarting,
# 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
# we are manually adjusting the bootup time variable so the status msg will get # updated.
# updated. current_time = time.time()
current_time = time.time() self.liq_client.boot_timestamp_update(current_time)
self.liq_client.conn.write(f"vars.bootup_time {str(current_time)}")
self.liq_client.conn.read()
self.liq_client.conn.write("streams.connection_status") stream_info = self.liq_client.outputs_connection_status()
stream_info = self.liq_client.conn.read().splitlines()[0]
except (ConnectionError, TimeoutError) as exception: except (ConnectionError, TimeoutError) as exception:
logger.exception(exception) logger.exception(exception)