From b1557b544368b416c158c13f12946859abbe00e0 Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Mon, 26 Apr 2021 11:12:02 +0200 Subject: [mod] processors: show identical error messages on /search and /stats --- searx/search/processors/online.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'searx/search/processors/online.py') diff --git a/searx/search/processors/online.py b/searx/search/processors/online.py index c39937023..57422c007 100644 --- a/searx/search/processors/online.py +++ b/searx/search/processors/online.py @@ -130,7 +130,7 @@ class OnlineProcessor(EngineProcessor): self.extend_container(result_container, start_time, search_results) except (httpx.TimeoutException, asyncio.TimeoutError) as e: # requests timeout (connect or read) - self.handle_exception(result_container, 'HTTP timeout', e, suspend=True, display_exception=False) + self.handle_exception(result_container, e, suspend=True) logger.error("engine {0} : HTTP requests timeout" "(search duration : {1} s, timeout: {2} s) : {3}" .format(self.engine_name, time() - start_time, @@ -138,23 +138,23 @@ class OnlineProcessor(EngineProcessor): e.__class__.__name__)) except (httpx.HTTPError, httpx.StreamError) as e: # other requests exception - self.handle_exception(result_container, 'HTTP error', e, suspend=True, display_exception=False) + self.handle_exception(result_container, e, suspend=True) logger.exception("engine {0} : requests exception" "(search duration : {1} s, timeout: {2} s) : {3}" .format(self.engine_name, time() - start_time, timeout_limit, e)) except SearxEngineCaptchaException as e: - self.handle_exception(result_container, 'CAPTCHA required', e, suspend=True, display_exception=False) + self.handle_exception(result_container, e, suspend=True) logger.exception('engine {0} : CAPTCHA'.format(self.engine_name)) except SearxEngineTooManyRequestsException as e: - self.handle_exception(result_container, 'too many requests', e, suspend=True, display_exception=False) + self.handle_exception(result_container, e, suspend=True) logger.exception('engine {0} : Too many requests'.format(self.engine_name)) except SearxEngineAccessDeniedException as e: - self.handle_exception(result_container, 'blocked', e, suspend=True, display_exception=False) + self.handle_exception(result_container, e, suspend=True) logger.exception('engine {0} : Searx is blocked'.format(self.engine_name)) except Exception as e: - self.handle_exception(result_container, 'unexpected crash', e, display_exception=False) + self.handle_exception(result_container, e) logger.exception('engine {0} : exception : {1}'.format(self.engine_name, e)) def get_default_tests(self): -- cgit v1.2.3 From 924f9afea37b6c545a03505a7ec291cf44654ca7 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 27 Apr 2021 15:13:39 +0200 Subject: [lint] pylint searx/search/processors files / BTW add some doc-strings Signed-off-by: Markus Heiser --- searx/search/processors/online.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'searx/search/processors/online.py') diff --git a/searx/search/processors/online.py b/searx/search/processors/online.py index 57422c007..93a9c6cbf 100644 --- a/searx/search/processors/online.py +++ b/searx/search/processors/online.py @@ -1,24 +1,29 @@ # SPDX-License-Identifier: AGPL-3.0-or-later +# lint: pylint + +"""Processores for engine-type: ``online`` + +""" from time import time import asyncio - import httpx import searx.network from searx import logger from searx.utils import gen_useragent -from searx.exceptions import (SearxEngineAccessDeniedException, SearxEngineCaptchaException, - SearxEngineTooManyRequestsException,) +from searx.exceptions import ( + SearxEngineAccessDeniedException, + SearxEngineCaptchaException, + SearxEngineTooManyRequestsException, +) from searx.metrics.error_recorder import count_error - -from searx.search.processors.abstract import EngineProcessor - +from .abstract import EngineProcessor logger = logger.getChild('searx.search.processor.online') - def default_request_params(): + """Default request parameters for ``online`` engines.""" return { 'method': 'GET', 'headers': {}, @@ -31,6 +36,7 @@ def default_request_params(): class OnlineProcessor(EngineProcessor): + """Processor class for ``online`` engines.""" engine_type = 'online' @@ -153,7 +159,7 @@ class OnlineProcessor(EngineProcessor): except SearxEngineAccessDeniedException as e: self.handle_exception(result_container, e, suspend=True) logger.exception('engine {0} : Searx is blocked'.format(self.engine_name)) - except Exception as e: + except Exception as e: # pylint: disable=broad-except self.handle_exception(result_container, e) logger.exception('engine {0} : exception : {1}'.format(self.engine_name, e)) -- cgit v1.2.3