diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2018-10-10 23:59:10 +0200 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2018-10-11 00:07:36 +0200 |
commit | e49fc3994ca30f65231b7a58226e859771d3e155 (patch) | |
tree | 1511a3d913dcf4da0a9df4034a3cc15ae227ccf1 /python/servo/util.py | |
parent | 3b153af49c8635e01b3a8eed86b5a1f901d58353 (diff) | |
download | servo-e49fc3994ca30f65231b7a58226e859771d3e155.tar.gz servo-e49fc3994ca30f65231b7a58226e859771d3e155.zip |
Reduce log spam for large downloads made from mach
Printing the same line again is a no-op on an actual terminal, but Taskcluster’s log viewer shows each such line separately.
Diffstat (limited to 'python/servo/util.py')
-rw-r--r-- | python/servo/util.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/python/servo/util.py b/python/servo/util.py index c093978e631..8359ad90b28 100644 --- a/python/servo/util.py +++ b/python/servo/util.py @@ -18,6 +18,7 @@ from socket import error as socket_error import stat import StringIO import sys +import time import zipfile import urllib2 @@ -102,8 +103,10 @@ def download(desc, src, writer, start_byte=0): fsize = int(resp.info().getheader('Content-Length').strip()) + start_byte recved = start_byte - chunk_size = 8192 + chunk_size = 64 * 1024 + previous_progress_line = None + previous_progress_line_time = 0 while True: chunk = resp.read(chunk_size) if not chunk: @@ -112,7 +115,13 @@ def download(desc, src, writer, start_byte=0): if not dumb: if fsize is not None: pct = recved * 100.0 / fsize - print("\rDownloading %s: %5.1f%%" % (desc, pct), end="") + progress_line = "\rDownloading %s: %5.1f%%" % (desc, pct) + now = time.time() + duration = now - previous_progress_line_time + if progress_line != previous_progress_line and duration > .1: + print(progress_line, end="") + previous_progress_line = progress_line + previous_progress_line_time = now sys.stdout.flush() writer.write(chunk) |