From f4b3f8293572793c284635f82a7f2c84fda50421 Mon Sep 17 00:00:00 2001 From: Andreas Poehlmann Date: Thu, 22 Feb 2024 00:20:07 +0100 Subject: [PATCH] paquo get_quath: better error --- paquo/__main__.py | 17 ++++++++++------- paquo/_utils.py | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/paquo/__main__.py b/paquo/__main__.py index 1fbafb2..d453361 100644 --- a/paquo/__main__.py +++ b/paquo/__main__.py @@ -335,13 +335,16 @@ def _download_cb(it, name): finally: print("") - file = download_qupath( - args.version, - path=args.download_path, - callback=_download_cb, - system=system, - ssl_verify=not args.no_ssl_verify - ) + try: + file = download_qupath( + args.version, + path=args.download_path, + callback=_download_cb, + system=system, + ssl_verify=not args.no_ssl_verify + ) + except Exception: + raise SystemExit(1) print("# extracting:", file) app = extract_qupath(file, args.install_path, system=system) print("# available at:", app) diff --git a/paquo/_utils.py b/paquo/_utils.py index ca9085d..e3ebb8a 100644 --- a/paquo/_utils.py +++ b/paquo/_utils.py @@ -159,11 +159,11 @@ def download_qupath( _ctx.verify_mode = ssl.CERT_NONE try: - print("# requesting:", url) with open(out_fn, mode="wb") as tmp, urlopen(url, context=_ctx) as f: # nosec B310 for chunk in callback(iter(lambda: f.read(chunk_size), b""), name=url): tmp.write(chunk) except Exception: + print("# error requesting:", url, file=sys.stderr) try: os.unlink(out_fn) except OSError: