Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03eb9c24 authored by Noémi Ványi's avatar Noémi Ványi
Browse files

Provide better error message if settings.yml cannot be loaded

Closes #3184
parent f231d79a
Loading
Loading
Loading
Loading
+11 −1
Original line number Diff line number Diff line
@@ -19,12 +19,22 @@ import logging
import searx.settings_loader
from os import environ
from os.path import realpath, dirname, join, abspath, isfile
from sys import exit

from searx.exceptions import SearxSettingsException

searx_dir = abspath(dirname(__file__))
engine_dir = dirname(realpath(__file__))
static_path = abspath(join(dirname(__file__), 'static'))

settings, settings_outgoing = {}, ''
try:
    settings, settings_load_message = searx.settings_loader.load_settings()
except SearxSettingsException as e:
    logger = logging.getLogger('searx')
    logger.error('Failed to load settings file: {}'.format(str(e)))
    exit(1)


if settings['ui']['static_path']:
    static_path = settings['ui']['static_path']
+9 −1
Original line number Diff line number Diff line
@@ -112,8 +112,16 @@ def is_use_default_settings(user_settings):
def load_settings(load_user_setttings=True):
    default_settings_path = get_default_settings_path()
    user_settings_path = get_user_settings_path()
    if user_settings_path is None or not load_user_setttings:

    # no user settings
    if user_settings_path is None or not load_user_setttings:
        if default_settings_path is None:
            raise SearxSettingsException(
                'missing default settings.yml file and there is no user configured file.\n'
                'Please create a configuration file and put it under the root of searx or in /etc/searx or'
                'configure the path in SEARX_SETTINGS_PATH.',
                None,
            )
        return (load_yaml(default_settings_path),
                'load the default settings from {}'.format(default_settings_path))