Add some logging after download is finished. NFC (#1413)
Also move some code outside of the `using` block.
This commit is contained in:
6
emsdk.py
6
emsdk.py
@@ -682,7 +682,6 @@ def download_with_curl(url, file_name):
|
||||
|
||||
def download_with_urllib(url, file_name):
|
||||
u = urlopen(url)
|
||||
with open(file_name, 'wb') as f:
|
||||
file_size = get_content_length(u)
|
||||
if file_size > 0:
|
||||
print("Downloading: %s from %s, %s Bytes" % (file_name, url, file_size))
|
||||
@@ -696,6 +695,8 @@ def download_with_urllib(url, file_name):
|
||||
block_sz = 256 * 1024
|
||||
if not TTY_OUTPUT:
|
||||
print(' [', end='')
|
||||
|
||||
with open(file_name, 'wb') as f:
|
||||
while True:
|
||||
buffer = u.read(block_sz)
|
||||
if not buffer:
|
||||
@@ -713,10 +714,13 @@ def download_with_urllib(url, file_name):
|
||||
print('-', end='')
|
||||
sys.stdout.flush()
|
||||
progress_shown += 1
|
||||
|
||||
if not TTY_OUTPUT:
|
||||
print(']')
|
||||
sys.stdout.flush()
|
||||
|
||||
debug_print('finished downloading (%d bytes)' % file_size_dl)
|
||||
|
||||
|
||||
# On success, returns the filename on the disk pointing to the destination file that was produced
|
||||
# On failure, returns None.
|
||||
|
||||
Reference in New Issue
Block a user