Skip to content
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