Skip to content

Commit 0480112

Browse files
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.
1 parent 99520f6 commit 0480112

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Diff for: tools/get.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ def mkdir_p(path):
5353
raise
5454

5555
def report_progress(count, blockSize, totalSize):
56-
percent = int(count*blockSize*100/totalSize)
57-
percent = min(100, percent)
58-
sys.stdout.write("\r%d%%" % percent)
59-
sys.stdout.flush()
56+
if sys.stdout.isatty():
57+
percent = int(count*blockSize*100/totalSize)
58+
percent = min(100, percent)
59+
sys.stdout.write("\r%d%%" % percent)
60+
sys.stdout.flush()
6061

6162
def unpack(filename, destination):
6263
dirname = ''

0 commit comments

Comments
 (0)