Skip to content
Snippets Groups Projects
Commit 453ec5f9 authored by Gottfried Gaisbauer's avatar Gottfried Gaisbauer
Browse files

reorganised some import, better logging handling now

parent 9fe9fc7f
No related branches found
No related tags found
2 merge requests!2Origin/aura into master,!1development branch to master branch
......@@ -7,10 +7,10 @@ from modules.scheduling.scheduler import AuraScheduler
from modules.communication.liquidsoap.communicator import LiquidSoapCommunicator
from modules.communication.redis.adapter import ServerRedisAdapter
from modules.web.routes import Routes
from libraries.base.common import AuraCommon
from libraries.base.config import AuraConfig
from libraries.base.logger import AuraLogger
class Aura(AuraCommon):
class Aura(AuraConfig, AuraLogger):
server = None
messenger = None
controller = None
......
......@@ -9,10 +9,10 @@ from argparse import ArgumentParser
# own libs
from modules.cli_tool.padavan import Padavan
from libraries.exceptions.auraexceptions import PlaylistException
from libraries.base.common import AuraCommon
from libraries.base.config import AuraConfig
class Guru(AuraCommon):
class Guru(AuraConfig):
parser = None
args = None
......
"""
Common aura functions
"""
import logging
from modules.base.config import ConfigReader
class AuraCommon:
"""
AuraCommon handles logger, reads and stores config
"""
logger = None
config = None
def __init__(self, logger=True):
self.read_config()
# create logger just once
if logger:
self.create_logger("AuraEngine")
def read_config(self):
"""
reads aura.ini
:return:
"""
self.config = ConfigReader()
self.config.load_config()
def create_logger(self, name):
"""
Creates the logger instance for AuraEngine
:param name: LoggerName
:return:
"""
lvl = self.config.get("loglevel")
# create logger
self.logger = logging.getLogger(name)
self.logger.setLevel(lvl)
# create file handler for logger
file_handler = logging.FileHandler(self.config.get("logdir") + "/engine.log")
file_handler.setLevel(lvl)
# create stream handler for logger
stream_handler = logging.StreamHandler()
stream_handler.setLevel(lvl)
# set format of log
datepart = "%(asctime)s:%(name)s:%(levelname)s"
message = " - %(message)s - "
filepart = "[%(filename)s:%(lineno)s-%(funcName)s()]"
formatter = logging.Formatter(datepart + message + filepart)
file_handler.setFormatter(formatter)
stream_handler.setFormatter(formatter)
# add handlers to the logger
self.logger.addHandler(file_handler)
self.logger.addHandler(stream_handler)
"""
Common aura functions
"""
from modules.base.config import ConfigReader
class AuraConfig:
"""
AuraCommon handles logger, reads and stores config
"""
config = None
def __init__(self):
self.read_config()
def read_config(self):
"""
reads aura.ini
:return:
"""
self.config = ConfigReader()
self.config.load_config()
......@@ -3,14 +3,14 @@ import simplejson
from modules.communication.liquidsoap.communicator import LiquidSoapCommunicator
from libraries.database.broadcasts import ScheduleEntry
from libraries.base.common import AuraCommon
from libraries.base.config import AuraConfig
from libraries.exceptions.auraexceptions import LQConnectionError
class ConnectionTester(AuraCommon):
class ConnectionTester(AuraConfig):
def __init__(self):
super(ConnectionTester, self).__init__(logger=False)
super(ConnectionTester, self).__init__()
def get_connection_status(self):
status = dict()
......
......@@ -20,11 +20,10 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger):
config = None
redisdb = None
channel = ""
# auracontroller = None
redisclient = None
scheduler = None
liquidsoapcommunicator = None
redisclient = None
connection_tester = None
liquidsoapcommunicator = None
def __init__(self):
threading.Thread.__init__(self)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment