add display_error_messages option to engine settings

A new option is added to engines to hide error messages from users. It
is called `display_error_messages` and by default it is set to `True`.
If it is set to `False` error messages do not show up on the UI.

Keep in mind that engines are still suspended if needed regardless of
this setting.

Closes #1828
This commit is contained in:
Noémi Ványi 2020-03-29 13:14:06 +02:00
parent d38952c133
commit e3282748d0
5 changed files with 11 additions and 1 deletions

View file

@ -26,6 +26,8 @@ Safe search **SS**
Weigth **W** Weigth **W**
------------- ----------- --------------------------------- ------------- ----------- ---------------------------------
Disabled **D** Disabled **D**
------------- ----------- ---------------------------------
Show errors **DE**
============= =========== ================================= ============= =========== =================================
Configuration defaults (at built time): Configuration defaults (at built time):
@ -51,6 +53,7 @@ Configuration defaults (at built time):
- O - O
- W - W
- D - D
- DE
{% for name, mod in engines.items() %} {% for name, mod in engines.items() %}
@ -67,5 +70,6 @@ Configuration defaults (at built time):
- {{(mod.offline and "y") or ""}} - {{(mod.offline and "y") or ""}}
- {{mod.weight or 1 }} - {{mod.weight or 1 }}
- {{(mod.disabled and "y") or ""}} - {{(mod.disabled and "y") or ""}}
- {{(mod.display_error_messages and "y") or ""}}
{% endfor %} {% endfor %}

View file

@ -175,6 +175,9 @@ Engine settings
``weigth`` : default ``1`` ``weigth`` : default ``1``
Weighting of the results of this engine. Weighting of the results of this engine.
``display_error_messages`` : default ``True``
When an engine returns an error, the message is displayed on the user interface.
.. note:: .. note::
A few more options are possible, but they are pretty specific to some A few more options are possible, but they are pretty specific to some

View file

@ -57,6 +57,7 @@ engine string name of searx-engine
(filename without ``.py``) (filename without ``.py``)
shortcut string shortcut of search-engine shortcut string shortcut of search-engine
timeout string specific timeout for search-engine timeout string specific timeout for search-engine
display_error_messages boolean display error messages on the web UI
======================= =========== =========================================== ======================= =========== ===========================================

View file

@ -55,6 +55,7 @@ engine_default_args = {'paging': False,
'continuous_errors': 0, 'continuous_errors': 0,
'time_range_support': False, 'time_range_support': False,
'offline': False, 'offline': False,
'display_error_messages': True,
'tokens': []} 'tokens': []}

View file

@ -346,6 +346,7 @@ class ResultContainer(object):
return resultnum_sum / len(self._number_of_results) return resultnum_sum / len(self._number_of_results)
def add_unresponsive_engine(self, engine_name, error_type, error_message=None): def add_unresponsive_engine(self, engine_name, error_type, error_message=None):
if engines[engine_name].display_error_messages:
self.unresponsive_engines.add((engine_name, error_type, error_message)) self.unresponsive_engines.add((engine_name, error_type, error_message))
def add_timing(self, engine_name, engine_time, page_load_time): def add_timing(self, engine_name, engine_time, page_load_time):