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

Remove more Flask dependencies.

parent 54e79ece
No related branches found
No related tags found
No related merge requests found
...@@ -27,25 +27,33 @@ import signal ...@@ -27,25 +27,33 @@ import signal
import logging import logging
import unittest import unittest
from pathlib import Path from flask import Flask
from flask import request, render_template, Flask, Response
from flask_sqlalchemy import SQLAlchemy from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.ext.declarative import declarative_base
from libraries.base.logger import AuraLogger from libraries.base.logger import AuraLogger
from libraries.base.config import AuraConfig from libraries.base.config import AuraConfig
# from modules.monitoring.diskspace_watcher import DiskSpaceWatcher # from modules.monitoring.diskspace_watcher import DiskSpaceWatcher
config = AuraConfig()
def configure_flask(): def configure_flask():
app.config["SQLALCHEMY_DATABASE_URI"] = config.get_database_uri() app.config["SQLALCHEMY_DATABASE_URI"] = config.get_database_uri()
app.config['BABEL_DEFAULT_LOCALE'] = 'de' app.config['BABEL_DEFAULT_LOCALE'] = 'de'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
config = AuraConfig()
# FIXME Instatiate SQLAlchemy without the need for Flask
app = Flask(__name__) app = Flask(__name__)
configure_flask() configure_flask()
DB = SQLAlchemy(app) DB = SQLAlchemy(app)
Base = declarative_base() Base = declarative_base()
class Aura: class Aura:
"""
Aura Class
The core of Aura Engine.
"""
logger = None logger = None
config = None config = None
server = None server = None
...@@ -53,13 +61,20 @@ class Aura: ...@@ -53,13 +61,20 @@ class Aura:
controller = None controller = None
scheduler = None scheduler = None
# ------------------------------------------------------------------------------------------ #
def __init__(self): def __init__(self):
"""
Initializes the Engine Core.
"""
self.config = config self.config = config
AuraLogger(self.config) AuraLogger(self.config)
self.logger = logging.getLogger("AuraEngine") self.logger = logging.getLogger("AuraEngine")
def startup(self): def startup(self):
"""
Starts the Engine Core.
"""
from modules.scheduling.scheduler import AuraScheduler from modules.scheduling.scheduler import AuraScheduler
from modules.communication.liquidsoap.communicator import LiquidSoapCommunicator from modules.communication.liquidsoap.communicator import LiquidSoapCommunicator
from modules.communication.redis.adapter import ServerRedisAdapter from modules.communication.redis.adapter import ServerRedisAdapter
...@@ -90,10 +105,12 @@ class Aura: ...@@ -90,10 +105,12 @@ class Aura:
# # ## ## ## ## ## # # #
# # ENTRY FUNCTION # # # START THE ENGINE
# # ## ## ## ## ## # # #
def main():
if __name__ == "__main__":
aura = Aura() aura = Aura()
if len(sys.argv) >= 2: if len(sys.argv) >= 2:
...@@ -103,12 +120,3 @@ def main(): ...@@ -103,12 +120,3 @@ def main():
aura.config.set("recreate_db", True) aura.config.set("recreate_db", True)
aura.startup() aura.startup()
# # ## ## ## ## ## ## # #
# # End ENTRY FUNCTION # #
# # ## ## ## ## ## ## # #
if __name__ == "__main__":
main()
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