Skip to content

Commit

Permalink
fix: don't error if progressbar is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
rroutsong committed Feb 5, 2024
1 parent 1183c31 commit c3d2d20
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions scripts/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit c3d2d20

Please sign in to comment.