aboutsummaryrefslogtreecommitdiffstats
path: root/host/utils/uhd_images_downloader.py.in
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2018-03-01 16:50:45 -0800
committerMartin Braun <martin.braun@ettus.com>2018-03-01 16:59:55 -0800
commit2e9cab9cfaff356427f77156350d2657216576bf (patch)
tree52c24a08ab610f0737d41a6ced2fa590f08c49bb /host/utils/uhd_images_downloader.py.in
parentd7d2523a24e80a323429308bdb73f117f8f8b6c8 (diff)
downloaduhd-2e9cab9cfaff356427f77156350d2657216576bf.tar.gz
uhd-2e9cab9cfaff356427f77156350d2657216576bf.tar.bz2
uhd-2e9cab9cfaff356427f77156350d2657216576bf.zip
utils: Skip progress bars for non-tty outputs
Diffstat (limited to 'host/utils/uhd_images_downloader.py.in')
-rw-r--r--host/utils/uhd_images_downloader.py.in6
1 files changed, 5 insertions, 1 deletions
diff --git a/host/utils/uhd_images_downloader.py.in b/host/utils/uhd_images_downloader.py.in
index 607e933ec..4c896c18c 100644
--- a/host/utils/uhd_images_downloader.py.in
+++ b/host/utils/uhd_images_downloader.py.in
@@ -198,9 +198,13 @@ def download(images_url, filename, buffer_size=_DEFAULT_BUFFER_SIZE, print_progr
raise RuntimeError("URL does not exist: {}".format(images_url))
filesize = float(resp.headers['content-length'])
filesize_dl = 0
+ base_filename = os.path.basename(filename)
+ if print_progress and not sys.stdout.isatty():
+ print_progress = False
+ log("INFO", "Downloading {}, total size: {} kB".format(
+ base_filename, filesize/1000))
with open(filename, "wb") as temp_file:
sha256_sum = hashlib.sha256()
- base_filename = os.path.basename(filename)
for buff in resp.iter_content(chunk_size=buffer_size):
if buff:
temp_file.write(buff)