From 54fecccbfba045e0925793c5542503d6864e2b77 Mon Sep 17 00:00:00 2001 From: Soxoj <31013580+soxoj@users.noreply.github.com> Date: Sun, 24 Nov 2024 04:21:24 +0100 Subject: [PATCH] Show detailed error statistics for `-v` (#1879) --- maigret/maigret.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/maigret/maigret.py b/maigret/maigret.py index 18844dd..4cd9d22 100755 --- a/maigret/maigret.py +++ b/maigret/maigret.py @@ -44,7 +44,7 @@ from .settings import Settings from .permutator import Permute -def notify_about_errors(search_results: QueryResultWrapper, query_notify): +def notify_about_errors(search_results: QueryResultWrapper, query_notify, show_statistics=False): errs = errors.extract_and_group(search_results) was_errs_displayed = False for e in errs: @@ -58,12 +58,17 @@ def notify_about_errors(search_results: QueryResultWrapper, query_notify): query_notify.warning(text, '!') was_errs_displayed = True + if show_statistics: + query_notify.warning(f'Verbose error statistics:') + for e in errs: + text = f'{e["err"]}: {round(e["perc"],2)}%' + query_notify.warning(text, '!') + if was_errs_displayed: query_notify.warning( 'You can see detailed site check errors with a flag `--print-errors`' ) - def extract_ids_from_page(url, logger, timeout=5) -> dict: results = {} # url, headers @@ -670,7 +675,7 @@ async def main(): check_domains=args.with_domains, ) - notify_about_errors(results, query_notify) + notify_about_errors(results, query_notify, show_statistics=args.verbose) if args.reports_sorting == "data": results = sort_report_by_data_points(results)