提交 5daf272d 编写于 作者: W wangxiao1021

fix download

上级 e825103c
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
from __future__ import print_function from __future__ import print_function
import os import os
import requests
import tarfile import tarfile
import shutil import shutil
try: try:
...@@ -67,8 +68,7 @@ def _download(item, scope, path, silent=False, convert=False): ...@@ -67,8 +68,7 @@ def _download(item, scope, path, silent=False, convert=False):
# copy to local # copy to local
def _chunk_read(response, url, chunk_size = 16 * 1024, report_hook = None): def _chunk_read(response, url, chunk_size = 16 * 1024, report_hook = None):
total_size = response.info().getheader('Content-Length').strip() total_size = int(requests.head(url).headers['Content-Length'])
total_size = int(total_size)
bytes_so_far = 0 bytes_so_far = 0
with open("%s" % filename, "wb") as f: with open("%s" % filename, "wb") as f:
while 1: while 1:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册