Skip to content
This repository was archived by the owner on Jul 18, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
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
17 changes: 15 additions & 2 deletions ptp/components/utils/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import shutil
import zipfile
import time
import urllib
import requests
from pathlib import Path


Expand Down Expand Up @@ -181,7 +181,20 @@ def download(folder, filename, url):

# Download.
file_result = os.path.join(os.path.expanduser(folder), filename)
urllib.request.urlretrieve(url, os.path.expanduser(file_result), reporthook)

with open(os.path.expanduser(file_result), "wb") as f:
global start_time
start_time = time.time()
r = requests.get(url)
content_length = int(r.headers.get('content-length', None))
count = 0

for chunk in r.iter_content(chunk_size=1024):
if chunk:
f.write(chunk)
count += 1
reporthook(count, 1024, content_length)

#self.logger.info('Downloading {}'.format(url))

def reporthook(count, block_size, total_size):
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@
#'torchtext',
'torchvision',
'torch',
'PyYAML'
'PyYAML',
'requests'
],

# List additional groups of dependencies here (e.g. development
Expand Down