-
Notifications
You must be signed in to change notification settings - Fork 12
/
wget.py
40 lines (30 loc) · 939 Bytes
/
wget.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import urllib.request
import sys
import json
import os
import yaml
f = open("config.yaml", "r+")
cfg = yaml.load(f)
GOOGLE_CLOUD_STORAGE_DIR = cfg['GOOGLE_CLOUD_STORAGE_DIR']
checkpoints = cfg['checkpoints']
chk = cfg['chk']
def download(chkpoint,filename):
url = os.path.join(GOOGLE_CLOUD_STORAGE_DIR , chkpoint , filename)
print(url)
urllib.request.urlretrieve(url, os.path.join('./waits/' , chkpoint , filename))
if __name__ == "__main__":
chkpoint = checkpoints[chk]
print(chkpoint)
save_dir = './waits/'+ chkpoint
print(save_dir)
if not os.path.exists(save_dir):
os.makedirs(save_dir)
download(chkpoint, 'manifest.json')
f = open(os.path.join(save_dir,'manifest.json'), 'r')
json_dict = json.load(f)
for x in json_dict:
filename = json_dict[x]['filename']
print(filename)
download(chkpoint,filename)