Hide get.py download percent when not interactive (#6852)

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.
This commit is contained in:
Earle F. Philhower, III 2022-06-12 15:46:17 -07:00 committed by GitHub
parent 99520f66f6
commit 0480112a15
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -53,10 +53,11 @@ def mkdir_p(path):
raise raise
def report_progress(count, blockSize, totalSize): def report_progress(count, blockSize, totalSize):
percent = int(count*blockSize*100/totalSize) if sys.stdout.isatty():
percent = min(100, percent) percent = int(count*blockSize*100/totalSize)
sys.stdout.write("\r%d%%" % percent) percent = min(100, percent)
sys.stdout.flush() sys.stdout.write("\r%d%%" % percent)
sys.stdout.flush()
def unpack(filename, destination): def unpack(filename, destination):
dirname = '' dirname = ''