2020-12-16 13:41:32 +01:00
|
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
|
|
|
|
from searx import logger
|
|
|
|
from searx.search.processors.abstract import EngineProcessor
|
|
|
|
|
|
|
|
|
2021-04-13 15:21:53 +02:00
|
|
|
logger = logger.getChild('searx.search.processor.offline')
|
2020-12-16 13:41:32 +01:00
|
|
|
|
|
|
|
|
|
|
|
class OfflineProcessor(EngineProcessor):
|
|
|
|
|
|
|
|
engine_type = 'offline'
|
|
|
|
|
|
|
|
def _search_basic(self, query, params):
|
|
|
|
return self.engine.search(query, params)
|
|
|
|
|
|
|
|
def search(self, query, params, result_container, start_time, timeout_limit):
|
|
|
|
try:
|
|
|
|
search_results = self._search_basic(query, params)
|
2021-04-13 15:21:53 +02:00
|
|
|
self.extend_container(result_container, start_time, search_results)
|
2020-12-16 13:41:32 +01:00
|
|
|
except ValueError as e:
|
2021-04-13 15:21:53 +02:00
|
|
|
# do not record the error
|
2020-12-16 13:41:32 +01:00
|
|
|
logger.exception('engine {0} : invalid input : {1}'.format(self.engine_name, e))
|
|
|
|
except Exception as e:
|
2021-04-13 15:21:53 +02:00
|
|
|
self.handle_exception(result_container, 'unexpected crash', e)
|
2020-12-16 13:41:32 +01:00
|
|
|
logger.exception('engine {0} : exception : {1}'.format(self.engine_name, e))
|