Przeglądaj źródła

[enh] explicit engine init

Adam Tauber 8 lat temu
rodzic
commit
a605377c40
2 zmienionych plików z 8 dodań i 9 usunięć
  1. 6
    8
      searx/engines/__init__.py
  2. 2
    1
      searx/webapp.py

+ 6
- 8
searx/engines/__init__.py Wyświetl plik

32
 engines = {}
32
 engines = {}
33
 
33
 
34
 categories = {'general': []}
34
 categories = {'general': []}
35
-_initialized = False
36
 
35
 
37
 engine_shortcuts = {}
36
 engine_shortcuts = {}
38
 engine_default_args = {'paging': False,
37
 engine_default_args = {'paging': False,
202
     ]
201
     ]
203
 
202
 
204
 
203
 
205
-if 'engines' not in settings or not settings['engines']:
206
-    logger.error('No engines found. Edit your settings.yml')
207
-    exit(2)
208
-
209
-for engine_data in settings['engines']:
210
-    engine = load_engine(engine_data)
211
-    if engine is not None:
204
+def initialize_engines(engine_list):
205
+    global categories, engines
206
+    engines = {}
207
+    categories = {'general': []}
208
+    for engine_data in engine_list:
209
+        engine = load_engine(engine_data)
212
         engines[engine.name] = engine
210
         engines[engine.name] = engine

+ 2
- 1
searx/webapp.py Wyświetl plik

53
 from flask.json import jsonify
53
 from flask.json import jsonify
54
 from searx import settings, searx_dir, searx_debug
54
 from searx import settings, searx_dir, searx_debug
55
 from searx.engines import (
55
 from searx.engines import (
56
-    categories, engines, get_engines_stats, engine_shortcuts
56
+    categories, engines, engine_shortcuts, get_engines_stats, initialize_engines
57
 )
57
 )
58
 from searx.utils import (
58
 from searx.utils import (
59
     UnicodeWriter, highlight_content, html_to_text, get_themes,
59
     UnicodeWriter, highlight_content, html_to_text, get_themes,
765
 
765
 
766
 
766
 
767
 def run():
767
 def run():
768
+    initialize_engines(settings['engines'])
768
     app.run(
769
     app.run(
769
         debug=searx_debug,
770
         debug=searx_debug,
770
         use_debugger=searx_debug,
771
         use_debugger=searx_debug,