MCPcopy Create free account
hub / github.com/OUCMachineLearning/OUCML / download

Function download

GAN/datadownloader/download.py:18–43  ·  view source on GitHub ↗
(url, dirpath)

Source from the content-addressed store, hash-verified

16 help='name of dataset to download [celebA, lsun, mnist]')
17
18def download(url, dirpath):
19 filename = url.split('/')[-1]
20 filepath = os.path.join(dirpath, filename)
21 u = urllib.request.urlopen(url)
22 f = open(filepath, 'wb')
23 filesize = int(u.headers["Content-Length"])
24 print("Downloading: %s Bytes: %s" % (filename, filesize))
25
26 downloaded = 0
27 block_sz = 8192
28 status_width = 70
29 while True:
30 buf = u.read(block_sz)
31 if not buf:
32 print('')
33 break
34 else:
35 print('', end='\r')
36 downloaded += len(buf)
37 f.write(buf)
38 status = (("[%-" + str(status_width + 1) + "s] %3.2f%%") %
39 ('=' * int(float(downloaded) / filesize * status_width) + '>', downloaded * 100. / filesize))
40 print(status, end='')
41 sys.stdout.flush()
42 f.close()
43 return filepath
44
45def download_file_from_google_drive(id, destination):
46 URL = "https://docs.google.com/uc?export=download"

Callers

nothing calls this directly

Calls 1

closeMethod · 0.80

Tested by

no test coverage detected