From 44db367db8273e2ee770d4e2489b3c2c90b49726 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Thu, 9 Jun 2022 17:39:35 -0700 Subject: [PATCH] Hide get.py download percent when not interactive When get.py is run in a script the percent-update printouts shown while downloading the toolchain end up as 100s to 1000s of lines in log files. When stdout is not a terminal, avoid printing these percentages and shrink logfiles significantly. Errors/etc. are still reported as normal. --- tools/get.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/get.py b/tools/get.py index cb1cfb95cb9..bec2b51cb1b 100755 --- a/tools/get.py +++ b/tools/get.py @@ -53,10 +53,11 @@ def mkdir_p(path): raise def report_progress(count, blockSize, totalSize): - percent = int(count*blockSize*100/totalSize) - percent = min(100, percent) - sys.stdout.write("\r%d%%" % percent) - sys.stdout.flush() + if sys.stdout.isatty(): + percent = int(count*blockSize*100/totalSize) + percent = min(100, percent) + sys.stdout.write("\r%d%%" % percent) + sys.stdout.flush() def unpack(filename, destination): dirname = ''