From 23611897ec2c7ff7f930ff6608eaa25d0fb27ca6 Mon Sep 17 00:00:00 2001 From: Dalf Date: Fri, 26 Jul 2019 09:04:00 +0200 Subject: [PATCH] [fix] make sure then engine name is lower case Minor fix: "%s engine initialized" display the right engine name --- searx/engines/__init__.py | 25 ++++++++++++++++--------- 1 file 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()