Commit 711f09ac authored by David Trattnig's avatar David Trattnig
Browse files

Updated terms. #44

parent dc8f8a95
......@@ -52,7 +52,7 @@ class AuraEngine:
"""
AuraEngine does the following:
1. Initialize the soundsystem and scheduler
1. Initialize the engine and scheduler
2. Initialize Redis
3. Start Liquidsoap in a separate thread which connects to the engine
......@@ -62,7 +62,7 @@ class AuraEngine:
server = None
messenger = None
controller = None
soundsystem = None
engine = None
scheduler = None
lqs = None
lqs_startup = None
......@@ -74,18 +74,18 @@ class AuraEngine:
Initializes Engine Core.
"""
self.config = config
AuraLogger(self.config)
self.logger = logging.getLogger("AuraEngine")
def startup(self, lqs_startup):
"""
Starts Engine Core.
"""
AuraLogger(self.config)
self.logger = logging.getLogger("AuraEngine")
"""
from modules.scheduling.scheduler import AuraScheduler
from modules.core.engine import SoundSystem
from modules.core.engine import Engine
from modules.cli.redis.adapter import ServerRedisAdapter
# If Liquidsoap should be started automatically
......@@ -96,13 +96,13 @@ class AuraEngine:
AuraScheduler(self.config, None, None)
# Create scheduler and Liquidsoap communicator
self.soundsystem = SoundSystem(self.config)
self.scheduler = AuraScheduler(self.config, self.soundsystem, self.on_initialized)
self.engine = Engine(self.config)
self.scheduler = AuraScheduler(self.config, self.engine, self.on_initialized)
# Create the Redis adapter
self.messenger = ServerRedisAdapter(self.config)
self.messenger.scheduler = self.scheduler
self.messenger.soundsystem = self.soundsystem
self.messenger.engine = self.engine
# And finally wait for redis message / start listener thread
self.messenger.start()
......@@ -168,6 +168,9 @@ class AuraEngine:
self.lqs.terminate()
self.logger.info("Terminated Liquidsoap")
if self.engine:
self.engine.terminate()
if self.messenger:
self.messenger.terminate()
......@@ -182,7 +185,6 @@ class AuraEngine:
if __name__ == "__main__":
engine = AuraEngine()
start_lqs = True
lqs_cmd = False
......
......@@ -45,7 +45,7 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
scheduler = None
redisclient = None
# connection_tester = None
soundsystem = None
engine = None
socket = None
# ------------------------------------------------------------------------------------------ #
......@@ -147,7 +147,7 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
self.terminate()
elif item["data"] == "init_player":
self.execute(RedisChannel.IP_REPLY.value, self.soundsystem.init_player)
self.execute(RedisChannel.IP_REPLY.value, self.engine.init_player)
elif item["data"] == "get_act_programme":
self.execute(RedisChannel.GAP_REPLY.value, self.scheduler.get_act_programme_as_string)
......@@ -155,8 +155,8 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
elif item["data"] == "get_status":
def get_status_string():
status = "No monitoring plugin available!"
if "monitor" in self.soundsystem.plugins:
status = self.soundsystem.plugins["monitor"].get_status()
if "monitor" in self.engine.plugins:
status = self.engine.plugins["monitor"].get_status()
return json.dumps(status)
self.execute(RedisChannel.GS_REPLY.value, get_status_string)
......@@ -179,7 +179,7 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
elif item["data"].find("on_play") >= 0:
source = item["data"].split("on_play ")[1]
self.execute(RedisChannel.TS_REPLY.value, self.scheduler.soundsystem.on_play, source)
self.execute(RedisChannel.TS_REPLY.value, self.scheduler.engine.player.on_play, source)
elif item["data"] == "recreate_db":
self.execute(RedisChannel.RDB_REPLY.value, self.scheduler.recreate_database)
......
......@@ -60,7 +60,7 @@ class AuraMonitor:
"""
logger = None
soundsystem = None
engine = None
mailer = None
status = None
already_invalid = None
......@@ -73,17 +73,17 @@ class AuraMonitor:
heartbeat_running = None
def __init__(self, config, soundsystem):
def __init__(self, config, engine):
"""
Initialize Monitoring
"""
self.logger = logging.getLogger("AuraEngine")
self.config = config
self.soundsystem = soundsystem
self.engine = engine
self.mailer = AuraMailer(self.config)
self.status = dict()
self.status["engine"] = dict()
self.status["soundsystem"] = dict()
self.status["lqs"] = dict()
self.status["redis"] = dict()
self.status["api"] = dict()
self.status["api"]["steering"] = dict()
......@@ -92,7 +92,7 @@ class AuraMonitor:
self.already_invalid = False
# Register as an engine plugin
self.soundsystem.plugins["monitor"] = self
self.engine.plugins["monitor"] = self
# Heartbeat settings
self.heartbeat_running = False
......@@ -169,8 +169,8 @@ class AuraMonitor:
self.update_status()
try:
if self.status["soundsystem"]["active"] \
and self.status["soundsystem"]["mixer"]["in_filesystem_0"] \
if self.status["lqs"]["active"] \
and self.status["lqs"]["mixer"]["in_filesystem_0"] \
and self.status["redis"]["active"] \
and self.status["audio_source"]["exists"]:
......@@ -218,13 +218,13 @@ class AuraMonitor:
"""
self.status["engine"]["version"] = meta.__version__
self.soundsystem.enable_transaction(self.soundsystem.client)
self.status["soundsystem"]["version"] = self.soundsystem.version()
self.status["soundsystem"]["uptime"] = self.soundsystem.uptime()
self.status["soundsystem"]["io"] = self.get_io_state()
self.status["soundsystem"]["mixer"] = self.soundsystem.mixer_status()
#self.status["soundsystem"]["recorder"] = self.soundsystem.get_recorder_status()
self.soundsystem.disable_transaction(self.soundsystem.client)
self.engine.player.connector.enable_transaction()
self.status["lqs"]["version"] = self.engine.version()
self.status["lqs"]["uptime"] = self.engine.uptime()
self.status["lqs"]["io"] = self.get_io_state()
self.status["lqs"]["mixer"] = self.engine.player.mixer.mixer_status()
self.status["lqs"]["mixer_fallback"] = self.engine.player.mixer_fallback.mixer_status()
self.engine.player.connector.disable_transaction()
self.status["api"]["steering"]["url"] = self.config.get("api_steering_status")
self.status["api"]["steering"]["available"] = self.validate_url_connection(self.config.get("api_steering_status"))
......@@ -243,9 +243,9 @@ class AuraMonitor:
"""
Refreshes the vital status info which are required for the engine to survive.
"""
self.soundsystem.enable_transaction(self.soundsystem.client)
self.status["soundsystem"]["active"] = self.soundsystem.is_active()
self.soundsystem.disable_transaction(self.soundsystem.client)
self.engine.player.connector.enable_transaction()
self.status["lqs"]["active"] = self.engine.is_active()
self.engine.player.connector.disable_transaction()
self.status["redis"]["active"] = self.validate_redis_connection()
self.status["audio_source"] = self.validate_directory(self.config.get("audio_source_folder"))
......@@ -274,7 +274,7 @@ class AuraMonitor:
"OK - Engine turned back into some HEALTHY STATE!", \
"Things seem fine again at '%s':\n\n%s" % (self.engine_id, status))
# Route call of event via event dispatcher to provide ability for additional hooks
self.soundsystem.event_dispatcher.on_resurrect(status)
self.engine.event_dispatcher.on_resurrect(status)
else:
# Engine turned into invalid state
if not self.already_invalid:
......@@ -285,7 +285,7 @@ class AuraMonitor:
"ERROR - Engine turned into some INVALID STATE!", \
"There's an issue with Aura Engine '%s':\n\n%s" % (self.engine_id, status))
# Route call of event via event dispatcher to provide ability for additional hooks
self.soundsystem.event_dispatcher.on_sick(status)
self.engine.event_dispatcher.on_sick(status)
threading.Timer(self.config.get("heartbeat_frequency"), self.heartbeat).start()
......@@ -294,14 +294,14 @@ class AuraMonitor:
"""
Retrieves all input and outputs provided by the engine.
"""
ios = self.soundsystem.engine_state()
ios = self.engine.engine_state()
try:
ios = ios.replace('"connected":', '"connected": ""')
ios = json.loads(ios, strict=False)
return ios
except Exception as e:
self.logger.warn("Got invalid JSON from soundsystem - " + str(e))
self.logger.warn("Got invalid JSON from Liquidsoap - " + str(e))
return MonitorResponseCode.INVALID_STATE.value
......
......@@ -22,7 +22,7 @@
import urllib
import json
from modules.core.engine import SoundSystem
from modules.core.engine import Engine
from modules.base.config import AuraConfig
......@@ -57,7 +57,7 @@ class ConnectionTester(AuraConfig):
# ------------------------------------------------------------------------------------------ #
def test_lqs_conn(self):
try:
lsc = SoundSystem(self.config)
lsc = Engine(self.config)
lsc.mixer_status()
return True
......@@ -67,7 +67,7 @@ class ConnectionTester(AuraConfig):
# ------------------------------------------------------------------------------------------ #
def test_lqsr_conn(self):
try:
lsc = SoundSystem(self.config)
lsc = Engine(self.config)
lsc.get_recorder_status()
return True
......
......@@ -27,7 +27,7 @@ import logging
import sqlalchemy
import decimal
from modules.core.engine import SoundSystem
from modules.core.engine import Engine
from modules.base.config import AuraConfig
from modules.base.models import Schedule, ScheduleEntry
from modules.scheduling.scheduler import AuraScheduler, AuraCalendarService
......@@ -53,11 +53,11 @@ def select_current_programme():
config = AuraConfig()
config.read_config()
soundsystem = SoundSystem(config.config)
engine = Engine(config.config)
sched = AuraScheduler(config.config)
soundsystem.scheduler = sched
sched.soundsystem = soundsystem
engine.scheduler = sched
sched.engine = engine
programme = sched.load_programme_from_db()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment