From eadfaaeed0b24cdf442369c1d70f30d681815084 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Thu, 2 Jul 2015 14:12:39 -0700 Subject: [PATCH] Fixing an issue you couldn't create a configuration because one did not yet exist. --- lemur/__init__.py | 5 ----- lemur/default.conf.py | 24 ++++++++++++++++++++++++ lemur/factory.py | 6 +++--- lemur/manage.py | 6 +++++- 4 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 lemur/default.conf.py diff --git a/lemur/__init__.py b/lemur/__init__.py index 388914bd..015ad459 100644 --- a/lemur/__init__.py +++ b/lemur/__init__.py @@ -62,8 +62,3 @@ def configure_hook(app): response.status_code = 403 return response - - - - - diff --git a/lemur/default.conf.py b/lemur/default.conf.py new file mode 100644 index 00000000..1ca0cc72 --- /dev/null +++ b/lemur/default.conf.py @@ -0,0 +1,24 @@ +# This is just Python which means you can inherit and tweak settings + +import os +_basedir = os.path.abspath(os.path.dirname(__file__)) + +ADMINS = frozenset(['']) + +THREADS_PER_PAGE = 8 + +############# +## General ## +############# + +# These will need to be set to `True` if you are developing locally +CORS = False +debug = False + +############# +## Logging ## +############# + +LOG_LEVEL = "DEBUG" +LOG_FILE = "lemur.log" + diff --git a/lemur/factory.py b/lemur/factory.py index 42afb32d..e0470ae2 100644 --- a/lemur/factory.py +++ b/lemur/factory.py @@ -88,11 +88,11 @@ def configure_app(app, config=None): except RuntimeError: if config and config != 'None': app.config.from_object(from_file(config)) - else: + elif os.path.isfile(os.path.expanduser("~/.lemur/lemur.conf.py")): app.config.from_object(from_file(os.path.expanduser("~/.lemur/lemur.conf.py"))) + else: + app.config.from_object(from_file(os.path.join(os.getcwd(), 'default.conf.py'))) - if not app.config.get('LEMUR_ENCRYPTION_KEY'): - raise NoEncryptionKeyFound def configure_extensions(app): diff --git a/lemur/manage.py b/lemur/manage.py index c87543da..2f4aee15 100755 --- a/lemur/manage.py +++ b/lemur/manage.py @@ -495,7 +495,7 @@ def create_config(config_path=None): sys.stdout.write("Created a new configuration file {0}\n".format(config_path)) -if __name__ == "__main__": +def main(): manager.add_command("start", LemurServer()) manager.add_command("runserver", Server(host='127.0.0.1')) manager.add_command("clean", Clean()) @@ -506,3 +506,7 @@ if __name__ == "__main__": manager.add_command('create_role', CreateRole()) manager.add_command("sync", Sync()) manager.run() + + +if __name__ == "__main__": + main()