(url, temp_file)
| 160 | |
| 161 | |
| 162 | def http_get(url, temp_file): |
| 163 | req = requests.get(url, stream=True) |
| 164 | content_length = req.headers.get('Content-Length') |
| 165 | total = int(content_length) if content_length is not None else None |
| 166 | progress = tqdm(unit="B", total=total) |
| 167 | for chunk in req.iter_content(chunk_size=1024): |
| 168 | if chunk: # filter out keep-alive new chunks |
| 169 | progress.update(len(chunk)) |
| 170 | temp_file.write(chunk) |
| 171 | progress.close() |
| 172 | |
| 173 | |
| 174 | def get_from_cache(url, cache_dir=None): |