From bf4f7c56a49a243a3f9e3ed32cea313e8456bafc Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Tue, 12 Mar 2024 15:59:42 +0300 Subject: Build up correct path to default settings The assumption has been that the application will be started in the root of the repository, and uses that to source the default settings. It is, however, possible that the application is started in a totally different working directory, which leads to an error during startup. This commit sources the default settings relative to a know file, in this case the module __init__.py file for qc_app module. --- qc_app/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'qc_app') diff --git a/qc_app/__init__.py b/qc_app/__init__.py index b40ec46..e44f471 100644 --- a/qc_app/__init__.py +++ b/qc_app/__init__.py @@ -1,6 +1,7 @@ """The Quality-Control Web Application entry point""" import os +from pathlib import Path from flask import Flask @@ -20,7 +21,8 @@ def override_settings_with_envvars( def create_app(): """The application factory""" app = Flask(__name__) - app.config.from_pyfile(os.path.join(os.getcwd(), "etc/default_config.py")) + app.config.from_pyfile(os.path.join( + Path(__file__).parent.parent, "etc/default_config.py")) if "QCAPP_CONF" in os.environ: app.config.from_envvar("QCAPP_CONF") # Override defaults with instance path -- cgit v1.2.3