diff --git a/swh/web/config.py b/swh/web/config.py index a82c65ef..3ee711d6 100644 --- a/swh/web/config.py +++ b/swh/web/config.py @@ -1,50 +1,50 @@ # Copyright (C) 2017 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information from swh.core import config from swh.storage import get_storage DEFAULT_CONFIG = { 'storage': ('dict', { 'cls': 'remote', 'args': { 'url': 'http://127.0.0.1:5002/', }, }), 'log_dir': ('string', '/tmp/swh/log'), - 'debug': ('bool', True), + 'debug': ('bool', False), 'host': ('string', '127.0.0.1'), 'port': ('int', 8000), 'secret_key': ('string', 'development key'), 'limiters': ('dict', { 'swh_api': { 'limiter_rate': '60/min', 'exempted_networks': ['127.0.0.0/8'] } }) } swhweb_config = None -def get_config(config_file=None): +def get_config(config_file='webapp'): """Read the configuration file `config_file`, update the app with parameters (secret_key, conf) and return the parsed configuration as a dict. If no configuration file is provided, return a default configuration.""" global swhweb_config - if not swhweb_config or config_file: - swhweb_config = config.read(config_file, DEFAULT_CONFIG) + if not swhweb_config: + swhweb_config = config.load_named_config(config_file, DEFAULT_CONFIG) config.prepare_folders(swhweb_config, 'log_dir') swhweb_config['storage'] = get_storage(**swhweb_config['storage']) return swhweb_config def storage(): """Return the current application's SWH storage. """ return get_config()['storage'] diff --git a/swh/web/manage.py b/swh/web/manage.py index 166d3ed4..5450cc49 100644 --- a/swh/web/manage.py +++ b/swh/web/manage.py @@ -1,39 +1,36 @@ #!/usr/bin/env python # Copyright (C) 2017 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information import os import sys from swh.web import config -# Default configuration file -DEFAULT_CONF_FILE = '~/.config/swh/webapp.yml' - if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "swh.web.settings") try: from django.core.management.commands.runserver import ( Command as runserver ) from django.core.management import execute_from_command_line except ImportError: # The above import may fail for some other reason. Ensure that the # issue is really that Django is missing to avoid masking other # exceptions on Python 2. try: import django # noqa except ImportError: raise ImportError( "Couldn't import Django. Are you sure it's installed and " "available on your PYTHONPATH environment variable? Did you " "forget to activate a virtual environment?" ) raise - swh_web_config = config.get_config(DEFAULT_CONF_FILE) + swh_web_config = config.get_config() runserver.default_port = swh_web_config['port'] runserver.default_addr = swh_web_config['host'] execute_from_command_line(sys.argv)