From c5e2fced06705bd5d495deca79917ae055af6915 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Mon, 3 Jun 2024 17:07:14 +0200 Subject: webmap-download: Make --debug repeatable and skip HTTP debugging if it's passed only once. This makes --debug less verbose by default and is useful for modules that do lots of HTTP connections such as WMS probing. --- webmap-download | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/webmap-download b/webmap-download index 7720e79..583c5dd 100755 --- a/webmap-download +++ b/webmap-download @@ -142,16 +142,18 @@ if __name__ == '__main__': help='optional directory for lock files') parser.add_argument('--quiet', action='store_true', help='skip progress bars even when stderr is a TTY') - parser.add_argument('--debug', action='store_true', help=argparse.SUPPRESS) + parser.add_argument('--debug', action='count', default=0, + help=argparse.SUPPRESS) parser.add_argument('--exit-code', default=True, action=argparse.BooleanOptionalAction, help='whether to exit with status 1 in case of download failures') parser.add_argument('groupname', nargs='*', help='Group(s) to process') args = parser.parse_args() - if args.debug: + if args.debug > 0: + logging.getLogger().setLevel(logging.DEBUG) + if args.debug > 1: from http.client import HTTPConnection HTTPConnection.debuglevel = 1 - logging.getLogger().setLevel(logging.DEBUG) requests_log = logging.getLogger("urllib3") requests_log.setLevel(logging.DEBUG) requests_log.propagate = True -- cgit v1.2.3