aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2024-06-02 13:44:43 +0200
committerGuilhem Moulin <guilhem@fripost.org>2024-06-02 13:54:51 +0200
commitf1089608519d4a22cf2d8efd215c5a40eb2f4465 (patch)
treee720fc0bb1de6bb949e93e39b0ec9d560b64482d
parent527cc0372edc6cecdd4c211e5629d7a0a7d3d892 (diff)
webmap-download: Add --quiet flag to always skip progress bars.
-rwxr-xr-xwebmap-download8
1 files changed, 5 insertions, 3 deletions
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