From d7f21484eebc54c57729b27e5bd19b8dafd7d15a Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Mon, 2 Nov 2020 15:55:19 +0100 Subject: [PATCH 1/2] [mod] pylint: add extension-pkg-whitelist=lxml.etree --- .pylintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index 3b4adb2c..eb6d500b 100644 --- a/.pylintrc +++ b/.pylintrc @@ -12,7 +12,7 @@ # A comma-separated list of package or module names from where C extensions may # be loaded. Extensions are loading into the active Python interpreter and may # run arbitrary code -extension-pkg-whitelist= +extension-pkg-whitelist=lxml.etree # Add files or directories to the blacklist. They should be base names, not # paths. From 58d72f26925d56e22330c54be03c3dcbee0c4135 Mon Sep 17 00:00:00 2001 From: Alexandre Flament Date: Tue, 3 Nov 2020 11:35:53 +0100 Subject: [PATCH 2/2] [mod] pylint: minor code change to allow pylint globally This commit is only a step, it doesn't fix all the issues reported by pylint --- searx/engines/qwant.py | 2 +- searx/engines/xpath.py | 1 + searx/webapp.py | 15 ++++++--------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/searx/engines/qwant.py b/searx/engines/qwant.py index 98460604..c909ce11 100644 --- a/searx/engines/qwant.py +++ b/searx/engines/qwant.py @@ -17,7 +17,7 @@ from searx.utils import html_to_text, match_language # engine dependent config -categories = None +categories = [] paging = True language_support = True supported_languages_url = 'https://qwant.com/region' diff --git a/searx/engines/xpath.py b/searx/engines/xpath.py index 81c2747f..a569d916 100644 --- a/searx/engines/xpath.py +++ b/searx/engines/xpath.py @@ -7,6 +7,7 @@ url_xpath = None content_xpath = None title_xpath = None thumbnail_xpath = False +categories = [] paging = False suggestion_xpath = '' results_xpath = '' diff --git a/searx/webapp.py b/searx/webapp.py index 609669b8..168829db 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -44,7 +44,7 @@ from urllib.parse import urlencode, urlparse, urljoin, urlsplit from pygments import highlight from pygments.lexers import get_lexer_by_name -from pygments.formatters import HtmlFormatter +from pygments.formatters import HtmlFormatter # pylint: disable=no-name-in-module from werkzeug.middleware.proxy_fix import ProxyFix from flask import ( @@ -111,7 +111,7 @@ app = Flask( app.jinja_env.trim_blocks = True app.jinja_env.lstrip_blocks = True -app.jinja_env.add_extension('jinja2.ext.loopcontrols') +app.jinja_env.add_extension('jinja2.ext.loopcontrols') # pylint: disable=no-member app.secret_key = settings['server']['secret_key'] # see https://flask.palletsprojects.com/en/1.1.x/cli/ @@ -565,15 +565,12 @@ def index(): result_container = search.search() + except SearxParameterException as e: + logger.exception('search error: SearxParameterException') + return index_error(output_format, e.message), 400 except Exception as e: - # log exception logger.exception('search error') - - # is it an invalid input parameter or something else ? - if (issubclass(e.__class__, SearxParameterException)): - return index_error(output_format, e.message), 400 - else: - return index_error(output_format, gettext('search error')), 500 + return index_error(output_format, gettext('search error')), 500 # results results = result_container.get_ordered_results()