Skip to content
Snippets Groups Projects
Commit 513d87cd authored by David Trattnig's avatar David Trattnig
Browse files

chore(version): new version handling. #110

parent fc6696e1
No related branches found
No related tags found
No related merge requests found
......@@ -65,6 +65,14 @@ class AuraConfig:
self.set("config_dir", os.path.dirname(ini_path))
print(f"Using configuration at: {ini_path}")
def init_version(self, version: dict):
"""
Read and set the component version from VERSION file in project root.
"""
self.set("version_control", version.get("control"))
self.set("version_core", version.get("core"))
self.set("version_liquidsoap", version.get("liquidsoap"))
@staticmethod
def config():
"""
......
......@@ -23,11 +23,11 @@ The Engine.
import json
import logging
import os
import time
from contextlib import suppress
from threading import Thread
import aura_engine.meta as meta
from aura_engine.base.api import LiquidsoapUtil as LU
from aura_engine.base.config import AuraConfig
from aura_engine.base.exceptions import (
......@@ -109,7 +109,8 @@ class Engine:
self.player = Player(self.connector, self.event_dispatcher)
self.event_dispatcher.on_boot()
self.logger.info(EngineSplash.splash_screen("Engine Core", meta.__version__))
self.logger.info(EngineSplash.splash_screen(self.config))
self.event_dispatcher.on_ready()
#
......@@ -177,18 +178,30 @@ class Engine:
res = self.connector.send_lqc_command("engine", "update_config", json_config)
return res
def version(self) -> dict:
def init_version(self) -> dict:
"""
Get the version of Liquidsoap.
Get the versions of Engine components and store in configuration.
Returns:
dict: Dictionary with `engine-core` and `liquidsoap` version
dict: {
"control": Engine Control version
"core": Engine Core version
"liquidsoap": Liquidsoap version
}
"""
ctrl_version = None
with open(os.path.join("", "VERSION")) as version_file:
ctrl_version = version_file.read().strip()
# FIXME Should be in one call
core_version = self.connector.send_lqc_command("engine", "version")
liq_version = self.connector.send_lqc_command("version", "")
return {"engine-core": core_version, "liquidsoap": liq_version}
liq_version = liq_version.split(" ")[1]
self.config.set("version_control", ctrl_version)
self.config.set("version_core", core_version)
self.config.set("version_liquidsoap", liq_version)
def uptime(self):
"""
......@@ -280,7 +293,7 @@ class Player:
`entry.state`.
Args:
entries ([Entry]): An array holding filesystem entries
entry (Entry): An array holding filesystem entries
"""
entry.status = EntryPlayState.LOADING
......@@ -721,19 +734,19 @@ class EngineSplash:
"""Print the splash and version information on boot."""
@staticmethod
def splash_screen(component, version):
def splash_screen(config):
"""
Print the engine logo and version info.
"""
return """\n
version = config.get("version_control")
core_version = config.get("version_core")
liq_version = config.get("version_liquidsoap")
return f"""\n
█████╗ ██╗ ██╗██████╗ █████╗ ███████╗███╗ ██╗ ██████╗ ██╗███╗ ██╗███████╗
██╔══██╗██║ ██║██╔══██╗██╔══██╗ ██╔════╝████╗ ██║██╔════╝ ██║████╗ ██║██╔════╝
███████║██║ ██║██████╔╝███████║ █████╗ ██╔██╗ ██║██║ ███╗██║██╔██╗ ██║█████╗
██╔══██║██║ ██║██╔══██╗██╔══██║ ██╔══╝ ██║╚██╗██║██║ ██║██║██║╚██╗██║██╔══╝
██║ ██║╚██████╔╝██║ ██║██║ ██║ ███████╗██║ ╚████║╚██████╔╝██║██║ ╚████║███████╗
╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝╚═╝ ╚═══╝╚══════╝
%s v%s - Ready to play!
\n""" % (
component,
version,
)
control v{version}, core v{core_version}, liquidsoap v{liq_version} - Ready to play!
\n"""
# Meta
__author__ = "David Trattnig and Gottfried Gaisbauer"
__copyright__ = "Copyright 2017-2020, Aura Engine Team"
__credits__ = ["Michael Liebler"]
__license__ = "GNU Affero General Public License (AGPL) Version 3"
__version__ = "0.9.9"
__version_info__ = (0, 9, 9)
__maintainer__ = "David Trattnig"
__email__ = "david.trattnig@subsquare.at"
__status__ = "Development"
......@@ -38,7 +38,6 @@ from socket import AF_INET, SO_BROADCAST, SOCK_DGRAM, SOL_SOCKET, socket
import requests
import aura_engine.meta as meta
from aura_engine.base.config import AuraConfig
from aura_engine.base.utils import SimpleUtil as SU
......@@ -235,10 +234,15 @@ class AuraMonitor:
"""
Request the current status of all components.
"""
self.status["engine"]["version"] = meta.__version__
self.engine.init_version()
ctrl_version = self.config.get("version_control")
core_version = self.config.get("version_core")
liq_version = self.config.get("version_liquidsoap")
self.status["engine"]["version"] = ctrl_version
self.engine.player.connector.enable_transaction()
self.status["lqs"]["version"] = self.engine.version()
self.status["lqs"]["version"] = {"core": core_version, "liquidsoap": liq_version}
self.status["lqs"]["outputs"] = self.engine.player.mixer.mixer_outputs()
self.status["lqs"]["mixer"] = self.engine.player.mixer.mixer_status()
self.engine.player.connector.disable_transaction()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment