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

Update download_lt.py #79

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 3 additions & 5 deletions download_lt.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import subprocess
import sys
import os
import requests

from contextlib import closing
from distutils.spawn import find_executable
Expand Down Expand Up @@ -128,7 +129,7 @@ def download_lt(update=False):
return

with closing(TemporaryFile()) as t:
with closing(urlopen(url)) as u:
with closing(requests.get(url,stream=True)) as u:
content_len = int(u.headers['Content-Length'])

sys.stdout.write(
Expand All @@ -139,10 +140,7 @@ def download_lt(update=False):

chunk_len = content_len // 100
data_len = 0
while True:
data = u.read(chunk_len)
if not data:
break
for data in u.iter_content(chunk_len):
data_len += len(data)
t.write(data)
sys.stdout.write(
Expand Down