diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2018-10-11 06:54:38 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-11 06:54:38 -0400 |
commit | 597f7c1cc653840c4f6fc353b2bebd4fc6ba5268 (patch) | |
tree | 28c3aa80ca83107175f78d6f0099a52334a0a1fe /python | |
parent | ae0a5a8eada818652be8b65d1d1220a434981e65 (diff) | |
parent | e49fc3994ca30f65231b7a58226e859771d3e155 (diff) | |
download | servo-597f7c1cc653840c4f6fc353b2bebd4fc6ba5268.tar.gz servo-597f7c1cc653840c4f6fc353b2bebd4fc6ba5268.zip |
Auto merge of #21905 - servo:log-spam, r=jdm
Reduce log spam for large downloads made from mach
Printing the same line again is a no-op in an actual terminal, but Taskcluster’s log viewer shows each such line separately.
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/21905)
<!-- Reviewable:end -->
Diffstat (limited to 'python')
-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) |