Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some logging after download is finished. NFC #1413

Merged
merged 1 commit into from
Jun 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add some logging after download is finished. NFC
Also move some code outside of the `using` block.
sbc100 committed Jun 21, 2024
commit f8232905e6585092f7555919ad11765400d1eebd
36 changes: 20 additions & 16 deletions emsdk.py
Original file line number Diff line number Diff line change
@@ -682,20 +682,21 @@ def download_with_curl(url, file_name):

def download_with_urllib(url, file_name):
u = urlopen(url)
file_size = get_content_length(u)
if file_size > 0:
print("Downloading: %s from %s, %s Bytes" % (file_name, url, file_size))
else:
print("Downloading: %s from %s" % (file_name, url))

file_size_dl = 0
# Draw a progress bar 80 chars wide (in non-TTY mode)
progress_max = 80 - 4
progress_shown = 0
block_sz = 256 * 1024
if not TTY_OUTPUT:
print(' [', end='')

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))
else:
print("Downloading: %s from %s" % (file_name, url))

file_size_dl = 0
# Draw a progress bar 80 chars wide (in non-TTY mode)
progress_max = 80 - 4
progress_shown = 0
block_sz = 256 * 1024
if not TTY_OUTPUT:
print(' [', end='')
while True:
buffer = u.read(block_sz)
if not buffer:
@@ -713,9 +714,12 @@ def download_with_urllib(url, file_name):
print('-', end='')
sys.stdout.flush()
progress_shown += 1
if not TTY_OUTPUT:
print(']')
sys.stdout.flush()

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