-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindependent-get_network.py
65 lines (59 loc) · 2.27 KB
/
independent-get_network.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
import sys, os, re, time, collections, ctypes
# simply enter the min_id and max_id in command line don't be afraid to put in break points,
# the code has sometimes been modified to get every 20th network and such
# also one user had trouble with wget on windows...... ask!
if __name__ == "__main__":
if len(sys.argv) < 2:
ctypes.windll.user32.MessageBoxW(0,
"Usage: independent-get_network.py minumum-newwork-id-number maximum-network-id-number",
"Missing Required Parameters", 1)
min_id = 53000
max_id = 54000
else:
min_id = int(sys.argv[1])
max_id = int(sys.argv[2])
# SERVER = "testserver.lczero.org"
SERVER = "ipv4.mooskagh.com:17346"
# add to util.py too
# TEST_SIZE = "20"
# TEST_STR = "test%%ib%s-" % (TEST_SIZE,)
# WEIGHT_PATTERN = "weights_" + TEST_STR + "%i.pb.gz"
NetworksHtm = "networks.htm"
NetworksDir = "F:\\leela\\nets\\"
last_downloaded = ""
field_count = 0
previous_value2 = ""
previous_value = ""
value = ""
os.system("wget http://%s/networks -O %s" % (SERVER, NetworksHtm))
line_lst = open(NetworksHtm).readlines()
existingNets = os.listdir(NetworksDir)
for line in line_lst:
m = re.match(r".*<td>(.*?)</td>", line)
if not m:
continue
field_count += 1
previous_value2 = previous_value
previous_value = value
value = m.group(1)
if value.find("get_network?sha") > 0:
field_count = 0
net_hash_flag = 1
current_net_id = previous_value2
net_id = int(current_net_id)
if net_id > max_id:
continue
if net_id < min_id:
continue
if net_id % 5 != 0:
continue
m = re.match(r'.*href="(.*?)"', line)
i = line_lst.index(line)
weights_target = "%i" % net_id
# there isn't a need to load if it already exists!
if os.path.isfile(NetworksDir + weights_target):
continue
cmd = "wget http://%s%s -O %s%s" % (SERVER, m.group(1), NetworksDir, weights_target)
print(cmd)
os.system(cmd)