-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
65 lines (53 loc) · 1.37 KB
/
Copy pathtest.py
File metadata and controls
65 lines (53 loc) · 1.37 KB
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
# LIB IMPORTS
import speedtest
# PATH IMPORTS
from paths import MODE
from paths import PATH_BEST
from paths import PATH_TEST
from paths import PATH_FETCH
from paths import PATH_FOUND
from paths import PATH_DOWN
from paths import PATH_UPLD
# INSTANCE
TEST = speedtest.Speedtest()
# FETCHING SERVERS
def fetchServers():
f = open(PATH_FETCH, MODE)
print(f.read())
return TEST.get_servers()
# GETTING BEST SERVER
def getBestServer():
f = open(PATH_BEST, MODE)
print(f.read())
return TEST.get_best_server()
def displayBestServer():
DATA = getBestServer()
HOST = DATA['host']
CITY = DATA['name']
CNTY = DATA['country']
f = open(PATH_FOUND, MODE)
print(f'{f.read()}{HOST} at {CITY}, {CNTY}')
# PERFORMING TESTS
def perfSpeedTests():
f = open(PATH_TEST, MODE)
print(f.read())
def perfDownload():
f = open(PATH_DOWN, MODE)
print(f.read())
print(f'Download speed: {TEST.download() / 1024 / 1024:.2f} Mbit/s')
def perfUpload():
f = open(PATH_UPLD, MODE)
print(f.read())
print(f'Upload speed: {TEST.upload() / 1024 / 1024:.2f} Mbit/s')
def pingResults():
print(f'\nPing: {TEST.results.ping} ms')
# MAIN
def main():
fetchServers()
displayBestServer()
perfSpeedTests()
perfDownload()
perfUpload()
pingResults()
# RUN
# main()