summaryrefslogtreecommitdiff
path: root/searx
diff options
context:
space:
mode:
authorDalf <alex@al-f.net>2020-08-28 12:12:32 +0200
committerDalf <alex@al-f.net>2020-08-28 12:12:32 +0200
commit4fb3ed2c6335b68f6b28ebc68d5d22f2fd621648 (patch)
treed21fa1ac26e0c3100f5ac02362f723aca0dd4223 /searx
parentec5adad851720be245a36018649011e7d0ec8e12 (diff)
downloadsearxng-4fb3ed2c6335b68f6b28ebc68d5d22f2fd621648.tar.gz
searxng-4fb3ed2c6335b68f6b28ebc68d5d22f2fd621648.zip
[enh] test: load each engine to check for syntax errors
Diffstat (limited to 'searx')
-rw-r--r--searx/engines/__init__.py13
-rwxr-xr-xsearx/webapp.py9
2 files changed, 10 insertions, 12 deletions
diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py
index 48c02e2e7..70b5ba166 100644
--- a/searx/engines/__init__.py
+++ b/searx/engines/__init__.py
@@ -72,11 +72,8 @@ def load_engine(engine_data):
engine_module = engine_data['engine']
- try:
- engine = load_module(engine_module + '.py', engine_dir)
- except:
- logger.exception('Cannot load engine "{}"'.format(engine_module))
- return None
+ # can raise an exception
+ engine = load_module(engine_module + '.py', engine_dir)
for param_name in engine_data:
if param_name == 'engine':
@@ -254,9 +251,11 @@ def load_engines(engine_list):
global engines
engines.clear()
for engine_data in engine_list:
- engine = load_engine(engine_data)
- if engine is not None:
+ try:
+ engine = load_engine(engine_data)
engines[engine.name] = engine
+ except:
+ logger.exception('Cannot load engine "{}"'.format(engine_data['engine']))
return engines
diff --git a/searx/webapp.py b/searx/webapp.py
index 4c0eceaaf..8a07d5ff1 100755
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -136,11 +136,6 @@ app.jinja_env.lstrip_blocks = True
app.jinja_env.add_extension('jinja2.ext.loopcontrols')
app.secret_key = settings['server']['secret_key']
-if not searx_debug \
- or os.environ.get("WERKZEUG_RUN_MAIN") == "true" \
- or os.environ.get('UWSGI_ORIGINAL_PROC_NAME') is not None:
- initialize_engines(settings['engines'])
-
babel = Babel(app)
rtl_locales = ['ar', 'arc', 'bcc', 'bqi', 'ckb', 'dv', 'fa', 'fa_IR', 'glk', 'he',
@@ -1051,6 +1046,10 @@ def page_not_found(e):
def run():
+ if not searx_debug \
+ or os.environ.get("WERKZEUG_RUN_MAIN") == "true" \
+ or os.environ.get('UWSGI_ORIGINAL_PROC_NAME') is not None:
+ initialize_engines(settings['engines'])
logger.debug('starting webserver on %s:%s', settings['server']['bind_address'], settings['server']['port'])
app.run(
debug=searx_debug,