Skip to content
Snippets Groups Projects
Commit c3c6d281 authored by Vermaat's avatar Vermaat
Browse files

Configuration by environment variable is optional

parent 757ec7e4
No related branches found
No related tags found
No related merge requests found
...@@ -42,7 +42,7 @@ The impatient can run Mutalyzer without a database server and more such ...@@ -42,7 +42,7 @@ The impatient can run Mutalyzer without a database server and more such
nonsense with the following steps:: nonsense with the following steps::
$ pip install -r requirements.txt $ pip install -r requirements.txt
$ MUTALYZER_SETTINGS=/dev/null python -m mutalyzer.entrypoints.website $ python -m mutalyzer.entrypoints.website
This starts the website frontend on the reported port using an in-memory This starts the website frontend on the reported port using an in-memory
SQLite database. SQLite database.
......
...@@ -16,6 +16,8 @@ from __future__ import unicode_literals ...@@ -16,6 +16,8 @@ from __future__ import unicode_literals
import collections import collections
import os import os
import warnings
import flask.config import flask.config
...@@ -65,10 +67,15 @@ class LazySettings(util.LazyObject): ...@@ -65,10 +67,15 @@ class LazySettings(util.LazyObject):
self._wrapped = Settings() self._wrapped = Settings()
self._wrapped.from_object('mutalyzer.config.default_settings') self._wrapped.from_object('mutalyzer.config.default_settings')
if from_environment: if from_environment:
# Todo: We crash if the environment variable is not set. Perhaps if ENVIRONMENT_VARIABLE in os.environ:
# it is more user-friendly if we fall back on ./settings.py or self._wrapped.from_envvar(ENVIRONMENT_VARIABLE)
# ~/mutalyzer_settings.py or something if it exists. else:
self._wrapped.from_envvar(ENVIRONMENT_VARIABLE) warnings.warn('The environment variable \'%s\' is not set '
'and as such default configuration settings '
'are used. Set this variable and make it point '
'to a configuration file to customize '
'configuration.' % ENVIRONMENT_VARIABLE,
RuntimeWarning)
def configure(self, settings): def configure(self, settings):
""" """
......
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