summaryrefslogtreecommitdiff
path: root/searx/engines
diff options
context:
space:
mode:
authorDalf <alex@al-f.net>2019-07-26 09:04:00 +0200
committerDalf <alex@al-f.net>2019-07-27 08:52:30 +0200
commit23611897ec2c7ff7f930ff6608eaa25d0fb27ca6 (patch)
tree39c064a41c76f2ebabea2bdbd3799cc0cf7bbeee /searx/engines
parent8645ef717ea57dd037d538d37f026a5e6cf0cae0 (diff)
downloadsearxng-23611897ec2c7ff7f930ff6608eaa25d0fb27ca6.tar.gz
searxng-23611897ec2c7ff7f930ff6608eaa25d0fb27ca6.zip
[fix] make sure then engine name is lower case
Minor fix: "%s engine initialized" display the right engine name
Diffstat (limited to 'searx/engines')
-rw-r--r--searx/engines/__init__.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py
index f32b57202..a10b1ccd9 100644
--- a/searx/engines/__init__.py
+++ b/searx/engines/__init__.py
@@ -57,11 +57,16 @@ engine_default_args = {'paging': False,
def load_engine(engine_data):
-
- if '_' in engine_data['name']:
- logger.error('Engine name conains underscore: "{}"'.format(engine_data['name']))
+ engine_name = engine_data['name']
+ if '_' in engine_name:
+ logger.error('Engine name contains underscore: "{}"'.format(engine_name))
sys.exit(1)
+ if engine_name.lower() != engine_name:
+ logger.warn('Engine name is not lowercase: "{}", converting to lowercase'.format(engine_name))
+ engine_name = engine_name.lower()
+ engine_data['name'] = engine_name
+
engine_module = engine_data['engine']
try:
@@ -248,12 +253,14 @@ def load_engines(engine_list):
def initialize_engines(engine_list):
load_engines(engine_list)
+
+ def engine_init(engine_name, init_fn):
+ init_fn()
+ logger.debug('%s engine: Initialized', engine_name)
+
for engine_name, engine in engines.items():
if hasattr(engine, 'init'):
init_fn = getattr(engine, 'init')
-
- def engine_init():
- init_fn()
- logger.debug('%s engine initialized', engine_name)
- logger.debug('Starting background initialization of %s engine', engine_name)
- threading.Thread(target=engine_init).start()
+ if init_fn:
+ logger.debug('%s engine: Starting background initialization', engine_name)
+ threading.Thread(target=engine_init, args=(engine_name, init_fn)).start()