From 33f462f28c8c6ab9507c614ccd9465c67ca84b2f Mon Sep 17 00:00:00 2001 From: Matt Jia Date: May 17 2017 04:05:41 +0000 Subject: drop /etc/waiverdb/settings.py from the RPM If /etc/waiverdb/settings.py is missing when starting waiverdb up in production mode, then a clear error message will be shown like this No such file or directory: '/etc/waiverdb/settings.py' --- diff --git a/waiverdb.spec b/waiverdb.spec index e89d041..9dd42a2 100644 --- a/waiverdb.spec +++ b/waiverdb.spec @@ -55,8 +55,6 @@ against test results. %install %py2_install -install -d %{buildroot}%{_sysconfdir}/waiverdb -install -p -m 0644 conf/settings.py.example %{buildroot}%{_sysconfdir}/waiverdb/settings.py install -d %{buildroot}%{_unitdir} install -m0644 \ systemd/%{name}.service \ @@ -72,7 +70,6 @@ py.test tests/ %doc README.md conf docs %{python2_sitelib}/%{name} %{python2_sitelib}/%{name}*.egg-info -%{_sysconfdir}/waiverdb %{_unitdir}/%{name}.service %{_unitdir}/%{name}.socket diff --git a/waiverdb/app.py b/waiverdb/app.py index d740b84..8cd26b7 100644 --- a/waiverdb/app.py +++ b/waiverdb/app.py @@ -21,7 +21,7 @@ from waiverdb.models import db from flask_oidc import OpenIDConnect -def load_default_config(app): +def load_config(app): # Load default config, then override that with a config file if os.getenv('DEV') == 'true': default_config_obj = 'waiverdb.config.DevelopmentConfig' @@ -34,8 +34,7 @@ def load_default_config(app): default_config_file = '/etc/waiverdb/settings.py' app.config.from_object(default_config_obj) config_file = os.environ.get('WAIVERDB_CONFIG', default_config_file) - if os.path.exists(config_file): - app.config.from_pyfile(config_file) + app.config.from_pyfile(config_file) # applicaiton factory http://flask.pocoo.org/docs/0.12/patterns/appfactories/ @@ -44,7 +43,7 @@ def create_app(config_obj=None): if config_obj: app.config.from_object(config_obj) else: - load_default_config(app) + load_config(app) if app.config['PRODUCTION'] and app.secret_key == 'replace-me-with-something-random': raise Warning("You need to change the app.secret_key value for production") if app.config['SHOW_DB_URI']: