chore(playout): remove unused code (#2058)
This commit is contained in:
parent
f8de1ec865
commit
bddbdf716c
|
@ -39,9 +39,6 @@ class Global:
|
||||||
def selfcheck(self):
|
def selfcheck(self):
|
||||||
return self.legacy_client.is_server_compatible()
|
return self.legacy_client.is_server_compatible()
|
||||||
|
|
||||||
def test_api(self):
|
|
||||||
self.legacy_client.test()
|
|
||||||
|
|
||||||
|
|
||||||
def keyboardInterruptHandler(signum, frame):
|
def keyboardInterruptHandler(signum, frame):
|
||||||
logger.info("\nKeyboard Interrupt\n")
|
logger.info("\nKeyboard Interrupt\n")
|
||||||
|
|
|
@ -53,17 +53,6 @@ class TelnetLiquidsoap:
|
||||||
def __connect(self):
|
def __connect(self):
|
||||||
return telnetlib.Telnet(self.ls_host, self.ls_port)
|
return telnetlib.Telnet(self.ls_host, self.ls_port)
|
||||||
|
|
||||||
def __is_empty(self, queue_id):
|
|
||||||
return True
|
|
||||||
connection = self.__connect()
|
|
||||||
msg = "%s.queue\nexit\n" % queue_id
|
|
||||||
connection.write(msg.encode("utf-8"))
|
|
||||||
output = connection.read_all().decode("utf-8").splitlines()
|
|
||||||
if len(output) == 3:
|
|
||||||
return len(output[0]) == 0
|
|
||||||
else:
|
|
||||||
raise Exception("Unexpected list length returned: %s" % output)
|
|
||||||
|
|
||||||
@ls_timeout
|
@ls_timeout
|
||||||
def queue_clear_all(self):
|
def queue_clear_all(self):
|
||||||
try:
|
try:
|
||||||
|
@ -100,9 +89,6 @@ class TelnetLiquidsoap:
|
||||||
try:
|
try:
|
||||||
self.telnet_lock.acquire()
|
self.telnet_lock.acquire()
|
||||||
|
|
||||||
if not self.__is_empty(queue_id):
|
|
||||||
raise QueueNotEmptyException()
|
|
||||||
|
|
||||||
connection = self.__connect()
|
connection = self.__connect()
|
||||||
annotation = create_liquidsoap_annotation(media_item)
|
annotation = create_liquidsoap_annotation(media_item)
|
||||||
msg = f"{queue_id}.push {annotation}\n"
|
msg = f"{queue_id}.push {annotation}\n"
|
||||||
|
@ -283,43 +269,3 @@ class TelnetLiquidsoap:
|
||||||
command += "stop\n"
|
command += "stop\n"
|
||||||
|
|
||||||
self.telnet_send([command])
|
self.telnet_send([command])
|
||||||
|
|
||||||
|
|
||||||
class DummyTelnetLiquidsoap:
|
|
||||||
def __init__(self, telnet_lock):
|
|
||||||
self.telnet_lock = telnet_lock
|
|
||||||
self.liquidsoap_mock_queues = {}
|
|
||||||
|
|
||||||
for index in range(4):
|
|
||||||
self.liquidsoap_mock_queues["s" + str(index)] = []
|
|
||||||
|
|
||||||
@ls_timeout
|
|
||||||
def queue_push(self, queue_id, media_item):
|
|
||||||
try:
|
|
||||||
self.telnet_lock.acquire()
|
|
||||||
|
|
||||||
logger.info(f"Pushing {media_item} to queue {queue_id}")
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
print(f"Time now: {datetime.utcnow():s}")
|
|
||||||
|
|
||||||
annotation = create_liquidsoap_annotation(media_item)
|
|
||||||
self.liquidsoap_mock_queues[queue_id].append(annotation)
|
|
||||||
finally:
|
|
||||||
self.telnet_lock.release()
|
|
||||||
|
|
||||||
@ls_timeout
|
|
||||||
def queue_remove(self, queue_id):
|
|
||||||
try:
|
|
||||||
self.telnet_lock.acquire()
|
|
||||||
|
|
||||||
logger.info("Purging queue %s" % queue_id)
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
print(f"Time now: {datetime.utcnow():s}")
|
|
||||||
finally:
|
|
||||||
self.telnet_lock.release()
|
|
||||||
|
|
||||||
|
|
||||||
class QueueNotEmptyException(Exception):
|
|
||||||
pass
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import math
|
import math
|
||||||
import telnetlib
|
|
||||||
import time
|
import time
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from queue import Queue
|
from queue import Queue
|
||||||
|
@ -8,7 +7,6 @@ from threading import Thread
|
||||||
from loguru import logger
|
from loguru import logger
|
||||||
|
|
||||||
from ..config import PUSH_INTERVAL, Config
|
from ..config import PUSH_INTERVAL, Config
|
||||||
from ..timeout import ls_timeout
|
|
||||||
from .queue import PypoLiqQueue
|
from .queue import PypoLiqQueue
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,36 +93,6 @@ class PypoPush(Thread):
|
||||||
|
|
||||||
return present, future
|
return present, future
|
||||||
|
|
||||||
@ls_timeout
|
|
||||||
def stop_web_stream_all(self):
|
|
||||||
try:
|
|
||||||
self.telnet_lock.acquire()
|
|
||||||
tn = telnetlib.Telnet(
|
|
||||||
self.config.playout.liquidsoap_host,
|
|
||||||
self.config.playout.liquidsoap_port,
|
|
||||||
)
|
|
||||||
|
|
||||||
# msg = 'dynamic_source.read_stop_all xxx\n'
|
|
||||||
msg = "http.stop\n"
|
|
||||||
logger.debug(msg)
|
|
||||||
tn.write(msg)
|
|
||||||
|
|
||||||
msg = "dynamic_source.output_stop\n"
|
|
||||||
logger.debug(msg)
|
|
||||||
tn.write(msg)
|
|
||||||
|
|
||||||
msg = "dynamic_source.id -1\n"
|
|
||||||
logger.debug(msg)
|
|
||||||
tn.write(msg)
|
|
||||||
|
|
||||||
tn.write("exit\n")
|
|
||||||
logger.debug(tn.read_all())
|
|
||||||
|
|
||||||
except Exception as exception:
|
|
||||||
logger.exception(exception)
|
|
||||||
finally:
|
|
||||||
self.telnet_lock.release()
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -1,93 +0,0 @@
|
||||||
import signal
|
|
||||||
import sys
|
|
||||||
from datetime import datetime, timedelta
|
|
||||||
from queue import Queue
|
|
||||||
from threading import Lock
|
|
||||||
|
|
||||||
from libretime_shared.logging import TRACE, setup_logger
|
|
||||||
from loguru import logger
|
|
||||||
|
|
||||||
from .player.liquidsoap_gateway import TelnetLiquidsoap
|
|
||||||
from .player.queue import PypoLiqQueue
|
|
||||||
|
|
||||||
|
|
||||||
def keyboardInterruptHandler(signum, frame):
|
|
||||||
logger.info("\nKeyboard Interrupt\n")
|
|
||||||
sys.exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
signal.signal(signal.SIGINT, keyboardInterruptHandler)
|
|
||||||
|
|
||||||
# configure logging
|
|
||||||
setup_logger(TRACE)
|
|
||||||
|
|
||||||
telnet_lock = Lock()
|
|
||||||
pypoPush_q = Queue()
|
|
||||||
|
|
||||||
|
|
||||||
pypoLiq_q = Queue()
|
|
||||||
liq_queue_tracker = {
|
|
||||||
"s0": None,
|
|
||||||
"s1": None,
|
|
||||||
"s2": None,
|
|
||||||
"s3": None,
|
|
||||||
}
|
|
||||||
|
|
||||||
# dummy_telnet_liquidsoap = DummyTelnetLiquidsoap(telnet_lock)
|
|
||||||
dummy_telnet_liquidsoap = TelnetLiquidsoap(
|
|
||||||
telnet_lock,
|
|
||||||
"localhost",
|
|
||||||
1234,
|
|
||||||
liq_queue_tracker,
|
|
||||||
)
|
|
||||||
|
|
||||||
plq = PypoLiqQueue(pypoLiq_q, dummy_telnet_liquidsoap)
|
|
||||||
plq.daemon = True
|
|
||||||
plq.start()
|
|
||||||
|
|
||||||
|
|
||||||
print(f"Time now: {datetime.utcnow():s}")
|
|
||||||
|
|
||||||
media_schedule = {}
|
|
||||||
|
|
||||||
start_dt = datetime.utcnow() + timedelta(seconds=1)
|
|
||||||
end_dt = datetime.utcnow() + timedelta(seconds=6)
|
|
||||||
|
|
||||||
media_schedule[start_dt] = {
|
|
||||||
"id": 5,
|
|
||||||
"type": "file",
|
|
||||||
"row_id": 9,
|
|
||||||
"uri": "",
|
|
||||||
"dst": "/home/martin/Music/ipod/Hot Chocolate - You Sexy Thing.mp3",
|
|
||||||
"fade_in": 0,
|
|
||||||
"fade_out": 0,
|
|
||||||
"cue_in": 0,
|
|
||||||
"cue_out": 300,
|
|
||||||
"start": start_dt,
|
|
||||||
"end": end_dt,
|
|
||||||
"show_name": "Untitled",
|
|
||||||
"replay_gain": 0,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
start_dt = datetime.utcnow() + timedelta(seconds=2)
|
|
||||||
end_dt = datetime.utcnow() + timedelta(seconds=6)
|
|
||||||
|
|
||||||
media_schedule[start_dt] = {
|
|
||||||
"id": 5,
|
|
||||||
"type": "file",
|
|
||||||
"row_id": 9,
|
|
||||||
"uri": "",
|
|
||||||
"dst": "/home/martin/Music/ipod/Good Charlotte - bloody valentine.mp3",
|
|
||||||
"fade_in": 0,
|
|
||||||
"fade_out": 0,
|
|
||||||
"cue_in": 0,
|
|
||||||
"cue_out": 300,
|
|
||||||
"start": start_dt,
|
|
||||||
"end": end_dt,
|
|
||||||
"show_name": "Untitled",
|
|
||||||
"replay_gain": 0,
|
|
||||||
}
|
|
||||||
pypoLiq_q.put(media_schedule)
|
|
||||||
|
|
||||||
plq.join()
|
|
Loading…
Reference in New Issue