mirror of
https://github.com/servo/servo.git
synced 2025-06-29 11:33:39 +01:00
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.
This commit is contained in:
parent
3b153af49c
commit
e49fc3994c
1 changed files with 11 additions and 2 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue