From 2e9cab9cfaff356427f77156350d2657216576bf Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Thu, 1 Mar 2018 16:50:45 -0800 Subject: utils: Skip progress bars for non-tty outputs --- host/utils/uhd_images_downloader.py.in | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'host/utils/uhd_images_downloader.py.in') 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) -- cgit v1.2.3