mirror of
https://github.com/searxng/searxng.git
synced 2025-07-24 21:59:22 +02:00
[format.python] initial formatting of the python code
This patch was generated by black [1]:: make format.python [1] https://github.com/psf/black Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
parent
fcdc2c2cd2
commit
3d96a9839a
184 changed files with 2800 additions and 2836 deletions
|
@ -12,11 +12,19 @@ from searx.engines import engines
|
|||
from .models import HistogramStorage, CounterStorage
|
||||
from .error_recorder import count_error, count_exception, errors_per_engines
|
||||
|
||||
__all__ = ["initialize",
|
||||
"get_engines_stats", "get_engine_errors",
|
||||
"histogram", "histogram_observe", "histogram_observe_time",
|
||||
"counter", "counter_inc", "counter_add",
|
||||
"count_error", "count_exception"]
|
||||
__all__ = [
|
||||
"initialize",
|
||||
"get_engines_stats",
|
||||
"get_engine_errors",
|
||||
"histogram",
|
||||
"histogram_observe",
|
||||
"histogram_observe_time",
|
||||
"counter",
|
||||
"counter_inc",
|
||||
"counter_add",
|
||||
"count_error",
|
||||
"count_exception",
|
||||
]
|
||||
|
||||
|
||||
ENDPOINTS = {'search'}
|
||||
|
@ -72,7 +80,7 @@ def initialize(engine_names=None):
|
|||
|
||||
# max_timeout = max of all the engine.timeout
|
||||
max_timeout = 2
|
||||
for engine_name in (engine_names or engines):
|
||||
for engine_name in engine_names or engines:
|
||||
if engine_name in engines:
|
||||
max_timeout = max(max_timeout, engines[engine_name].timeout)
|
||||
|
||||
|
@ -81,7 +89,7 @@ def initialize(engine_names=None):
|
|||
histogram_size = int(1.5 * max_timeout / histogram_width)
|
||||
|
||||
# engines
|
||||
for engine_name in (engine_names or engines):
|
||||
for engine_name in engine_names or engines:
|
||||
# search count
|
||||
counter_storage.configure('engine', engine_name, 'search', 'count', 'sent')
|
||||
counter_storage.configure('engine', engine_name, 'search', 'count', 'successful')
|
||||
|
@ -112,17 +120,19 @@ def get_engine_errors(engline_name_list):
|
|||
r = []
|
||||
for context, count in sorted_context_count_list:
|
||||
percentage = round(20 * count / sent_search_count) * 5
|
||||
r.append({
|
||||
'filename': context.filename,
|
||||
'function': context.function,
|
||||
'line_no': context.line_no,
|
||||
'code': context.code,
|
||||
'exception_classname': context.exception_classname,
|
||||
'log_message': context.log_message,
|
||||
'log_parameters': context.log_parameters,
|
||||
'secondary': context.secondary,
|
||||
'percentage': percentage,
|
||||
})
|
||||
r.append(
|
||||
{
|
||||
'filename': context.filename,
|
||||
'function': context.function,
|
||||
'line_no': context.line_no,
|
||||
'code': context.code,
|
||||
'exception_classname': context.exception_classname,
|
||||
'log_message': context.log_message,
|
||||
'log_parameters': context.log_parameters,
|
||||
'secondary': context.secondary,
|
||||
'percentage': percentage,
|
||||
}
|
||||
)
|
||||
result[engine_name] = sorted(r, reverse=True, key=lambda d: d['percentage'])
|
||||
return result
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue