From f1089608519d4a22cf2d8efd215c5a40eb2f4465 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Sun, 2 Jun 2024 13:44:43 +0200 Subject: webmap-download: Add --quiet flag to always skip progress bars. --- webmap-download | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'webmap-download') diff --git a/webmap-download b/webmap-download index c8c4178..997f5fe 100755 --- a/webmap-download +++ b/webmap-download @@ -140,6 +140,8 @@ if __name__ == '__main__': help=f'destination directory for downloaded files (default: {os.curdir})') parser.add_argument('--lockdir', default=None, 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('--exit-code', default=True, action=argparse.BooleanOptionalAction, help='whether to exit with status 1 in case of download failures') @@ -163,11 +165,11 @@ if __name__ == '__main__': sourcedef['layername'] = name sources.append(sourcedef) - if sys.stderr.isatty(): + if args.quiet or not sys.stderr.isatty(): + pbar = None + else: from tqdm import tqdm pbar = tqdm - else: - pbar = None # intentionally leave the dirfd open until the program terminates opendir_args = O_RDONLY|O_CLOEXEC|O_PATH|O_DIRECTORY -- cgit v1.2.3