diff options
Diffstat (limited to 'searx/engines/command.py')
| -rw-r--r-- | searx/engines/command.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/searx/engines/command.py b/searx/engines/command.py index 176388e3a..29950ae4e 100644 --- a/searx/engines/command.py +++ b/searx/engines/command.py @@ -81,6 +81,7 @@ from subprocess import Popen, PIPE from threading import Thread from searx import logger +from searx.result_types import EngineResults engine_type = 'offline' @@ -93,7 +94,6 @@ query_enum = [] environment_variables = {} working_dir = realpath('.') result_separator = '\n' -result_template = 'key-value.html' timeout = 4.0 _command_logger = logger.getChild('command') @@ -126,17 +126,17 @@ def init(engine_settings): environment_variables = engine_settings['environment_variables'] -def search(query, params): +def search(query, params) -> EngineResults: + res = EngineResults() cmd = _get_command_to_run(query) if not cmd: - return [] + return res - results = [] - reader_thread = Thread(target=_get_results_from_process, args=(results, cmd, params['pageno'])) + reader_thread = Thread(target=_get_results_from_process, args=(res, cmd, params['pageno'])) reader_thread.start() reader_thread.join(timeout=timeout) - return results + return res def _get_command_to_run(query): @@ -153,7 +153,7 @@ def _get_command_to_run(query): return cmd -def _get_results_from_process(results, cmd, pageno): +def _get_results_from_process(res: EngineResults, cmd, pageno): leftover = '' count = 0 start, end = __get_results_limits(pageno) @@ -173,12 +173,11 @@ def _get_results_from_process(results, cmd, pageno): continue if start <= count and count <= end: # pylint: disable=chained-comparison - result['template'] = result_template - results.append(result) + res.add(res.types.KeyValue(kvmap=result)) count += 1 if end < count: - return results + return res line = process.stdout.readline() |