summaryrefslogtreecommitdiff
path: root/searx/search/checker/__main__.py
diff options
context:
space:
mode:
Diffstat (limited to 'searx/search/checker/__main__.py')
-rw-r--r--searx/search/checker/__main__.py30
1 files changed, 23 insertions, 7 deletions
diff --git a/searx/search/checker/__main__.py b/searx/search/checker/__main__.py
index 2f808237a..37b7e6cda 100644
--- a/searx/search/checker/__main__.py
+++ b/searx/search/checker/__main__.py
@@ -1,9 +1,13 @@
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
import sys
import os
+import argparse
import searx.search
-import searx.search.processors
import searx.search.checker
+from searx.search import processors
+from searx.engines import engine_shortcuts
if sys.stdout.isatty() and os.environ.get('TERM') not in ['dumb', 'unknown']:
@@ -18,20 +22,24 @@ else:
BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = "", "", "", "", "", "", "", ""
-def iter_processor():
- if len(sys.argv) > 1:
- for name, processor in searx.search.processors.items():
- if name in sys.argv:
+def iter_processor(engine_name_list):
+ if len(engine_name_list) > 0:
+ for name in engine_name_list:
+ name = engine_shortcuts.get(name, name)
+ processor = processors.get(name)
+ if processor is not None:
yield name, processor
+ else:
+ print(BOLD_SEQ, 'Engine ', '%-30s' % name, RESET_SEQ, RED, ' Not found ', RESET_SEQ)
else:
for name, processor in searx.search.processors.items():
yield name, processor
-def main():
+def run(engine_name_list):
searx.search.initialize()
broken_urls = []
- for name, processor in iter_processor():
+ for name, processor in iter_processor(engine_name_list):
if sys.stdout.isatty():
print(BOLD_SEQ, 'Engine ', '%-30s' % name, RESET_SEQ, WHITE, ' Checking', RESET_SEQ)
checker = searx.search.checker.Checker(processor)
@@ -48,5 +56,13 @@ def main():
print('Error fetching', url)
+def main():
+ parser = argparse.ArgumentParser(description='Check searx engines.')
+ parser.add_argument('engine_name_list', metavar='engine name', type=str, nargs='*',
+ help='engines name or shortcut list. Empty for all engines.')
+ args = parser.parse_args()
+ run(args.engine_name_list)
+
+
if __name__ == '__main__':
main()