From c3d2d209cb5fc20e524c8facf4c1a72243873198 Mon Sep 17 00:00:00 2001 From: Ryan Routsong Date: Mon, 5 Feb 2024 14:30:04 -0500 Subject: [PATCH] fix: don't error if progressbar is not installed --- scripts/cache.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/cache.py b/scripts/cache.py index 2ccdf53..435fde2 100644 --- a/scripts/cache.py +++ b/scripts/cache.py @@ -7,7 +7,6 @@ import subprocess import json import urllib.request -import progressbar from argparse import ArgumentTypeError from pathlib import Path from urllib.parse import urlparse @@ -81,7 +80,14 @@ def handle_download(output_dir, resource, protocol, url): if protocol in ('http', 'https', 'ftp'): info_download(f"Getting web resource {resource}...") fnurl = Path(urlparse(url).path).stem - urllib.request.urlretrieve(uri, filename=Path(output_dir, fnurl), reporthook=DownloadProgressBar()) + try: + import progressbar + urllib.request.urlretrieve(uri, filename=Path(output_dir, fnurl), reporthook=DownloadProgressBar()) + except ModuleNotFoundError: + print('Downloading resources....') + urllib.request.urlretrieve(uri, filename=Path(output_dir, fnurl)) + print('....done.') + elif protocol in ('docker'): info_download(f"Getting docker resource {resource}...") docker_tag = url.split('/')[-1]