Skip to content

Commit fdf30fe

Browse files
Hide get.py download percent when not interactive (#618)
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 7d5e7f5 commit fdf30fe

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

tests/common.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ function install_ide()
212212
cat rp2040/platform.local.txt
213213
echo -e "\n----\n"
214214
cd rp2040/tools
215-
python3 get.py -q
215+
python3 get.py
216216
if [ "$WINDOWS" = "1" ]; then
217217
# Because the symlinks don't work well under Win32, we need to add the path to this copy, not the original...
218218
relbin=$(realpath $PWD/../system/arm-none-eabi/bin)

tools/get.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
import zipfile
1616
import re
1717

18-
verbose = True
19-
2018
if sys.version_info[0] == 3:
2119
from urllib.request import urlretrieve
2220
else:
@@ -40,8 +38,7 @@ def mkdir_p(path):
4038
raise
4139

4240
def report_progress(count, blockSize, totalSize):
43-
global verbose
44-
if verbose:
41+
if sys.stdout.isatty():
4542
percent = int(count*blockSize*100/totalSize)
4643
percent = min(100, percent)
4744
sys.stdout.write("\r%d%%" % percent)
@@ -121,14 +118,6 @@ def identify_platform():
121118
return arduino_platform_names[sys_name][bits]
122119

123120
def main():
124-
global verbose
125-
# Support optional "-q" quiet mode simply
126-
if len(sys.argv) == 2:
127-
if sys.argv[1] == "-q":
128-
verbose = False
129-
# Remove a symlink generated in 2.6.3 which causes later issues since the tarball can't properly overwrite it
130-
if (os.path.exists('python3/python3')):
131-
os.unlink('python3/python3')
132121
print('Platform: {0}'.format(identify_platform()))
133122
tools_to_download = load_tools_list('../package/package_pico_index.template.json', identify_platform())
134123
mkdir_p(dist_dir)

0 commit comments

Comments
 (0)