logo

searx

Unnamed repository; edit this file 'description' to name the repository.
commit: a605377c40e5f9d5ce80a222df65b605dfcd3907
parent: 14f58bdaecb288ac65782b2025e765c514b1844e
Author: Adam Tauber <asciimoo@gmail.com>
Date:   Tue, 27 Dec 2016 17:25:19 +0100

[enh] explicit engine init

Diffstat:

searx/engines/__init__.py | 14++++++--------
searx/webapp.py | 3++-
2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py @@ -32,7 +32,6 @@ engine_dir = dirname(realpath(__file__)) engines = {} categories = {'general': []} -_initialized = False engine_shortcuts = {} engine_default_args = {'paging': False, @@ -202,11 +201,10 @@ def get_engines_stats(): ] -if 'engines' not in settings or not settings['engines']: - logger.error('No engines found. Edit your settings.yml') - exit(2) - -for engine_data in settings['engines']: - engine = load_engine(engine_data) - if engine is not None: +def initialize_engines(engine_list): + global categories, engines + engines = {} + categories = {'general': []} + for engine_data in engine_list: + engine = load_engine(engine_data) engines[engine.name] = engine diff --git a/searx/webapp.py b/searx/webapp.py @@ -53,7 +53,7 @@ from flask_babel import Babel, gettext, format_date, format_decimal from flask.json import jsonify from searx import settings, searx_dir, searx_debug from searx.engines import ( - categories, engines, get_engines_stats, engine_shortcuts + categories, engines, engine_shortcuts, get_engines_stats, initialize_engines ) from searx.utils import ( UnicodeWriter, highlight_content, html_to_text, get_themes, @@ -765,6 +765,7 @@ def page_not_found(e): def run(): + initialize_engines(settings['engines']) app.run( debug=searx_debug, use_debugger=searx_debug,