Commit dc40738a authored by David Trattnig's avatar David Trattnig
Browse files

Automatic config detection for production-envs.

parent 2ea1a22c
......@@ -42,12 +42,11 @@ from libraries.base.logger import AuraLogger
from libraries.base.config import AuraConfig
def get_config_file():
if len(sys.argv) >= 3 and "--config-file" in sys.argv:
idx = sys.argv.index("--config-file")
return sys.argv[idx + 1]
else:
return "%s/configuration/engine.ini" % Path(__file__).parent.absolute()
# def get_config_file():
# if len(sys.argv) >= 3 and "--config-file" in sys.argv:
# idx = sys.argv.index("--config-file")
# return sys.argv[idx + 1]
def get_database_uri():
db_name = config.get("db_name")
......@@ -64,7 +63,7 @@ def configure_flask():
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
config = AuraConfig(get_config_file())
config = AuraConfig()
app = Flask(__name__, template_folder=config.get("install_dir") + "/modules/web/templates")
configure_flask()
DB = SQLAlchemy(app)
......
......@@ -41,8 +41,8 @@ class Guru():
"""
Command Line Interface (CLI) for Aura Engine.
"""
config_path = "%s/configuration/engine.ini" % Path(__file__).parent.absolute()
config = AuraConfig(config_path)
# config_path = "%s/configuration/engine.ini" % Path(__file__).parent.absolute()
config = AuraConfig()
parser = None
args = None
......
......@@ -23,21 +23,43 @@
#
import os
import os.path
import sys
import logging
from pathlib import Path
from configparser import ConfigParser
class AuraConfig:
"""
AuraConfig Class
Holds the Aura Configuration as in the file `engine.ini`.
"""
ini_path = ""
logger = None
def __init__(self, ini_path): # = "/etc/aura/engine.ini"):
def __init__(self, ini_path="/etc/aura/engine.ini"):
"""
Initializes the configuration, defaults to `/etc/aura/engine.ini`.
If this file doesn't exist it uses `./configuration/engine.ini` from
the project directory.
Args:
ini_path(String): The path to the configuration file `engine.ini`
"""
config_file = Path(ini_path)
if not config_file.is_file():
ini_path = "%s/configuration/engine.ini" % Path(__file__).parent.parent.parent.absolute()
self.ini_path = ini_path
self.logger = logging.getLogger("AuraEngine")
self.load_config()
def set(self, key, value):
"""
Set a property
......
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