-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
54 lines (47 loc) · 1.99 KB
/
main.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
import os
import csv
from init import initialize
from mirrors import all_mirrors
from test_mirror import test_mirror
def main():
initialize()
print('Start testing...')
results = {}
for mirror in all_mirrors:
if os.path.isfile('results/{}.txt'.format(mirror)):
print(f'Skipping {mirror}')
else:
print('Testing {}'.format(all_mirrors[mirror]['name']))
final_points, ping_result, tiny_files_speed_str, large_files_speed_str, richness_result = test_mirror(
mirror)
results[mirror] = {
'final_points': final_points,
'ping_result': '{:.3f}'.format(ping_result) if ping_result != 'Failed' else ping_result,
'tiny_files_speed_str': tiny_files_speed_str,
'large_files_speed_str': large_files_speed_str,
'richness_result': richness_result
}
with open('results/{}.txt'.format(mirror), 'w') as f:
f.write('Final points: {}\n'.format(final_points))
f.write('Ping result: {}\n'.format(ping_result))
f.write('Tiny files speed: {}\n'.format(tiny_files_speed_str))
f.write('Large files speed: {}\n'.format(large_files_speed_str))
f.write('Richness result: {}\n'.format(richness_result))
with open('results/results.csv', 'w') as f:
writer = csv.writer(f)
writer.writerow(['Repo', 'Final points', 'Ping result', 'Tiny files speed', 'Large files speed', 'Richness result'])
for mirror in results:
writer.writerow([
mirror,
results[mirror]['final_points'],
results[mirror]['ping_result'],
results[mirror]['tiny_files_speed_str'],
results[mirror]['large_files_speed_str'],
results[mirror]['richness_result']
])
print('Done!')
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
exit(1)