-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspeed-test.py
24 lines (20 loc) · 935 Bytes
/
speed-test.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
#!/usr/bin/python
import speedtest
from colors import Colors
test = speedtest.Speedtest()
try:
print(Colors.OKBLUE + "Loading Server list ....")
test.get_servers()
print(Colors.OKBLUE + "Choosing best Sever ....")
best = test.get_best_server()
print(Colors.OKGREEN + f"Found: {best['host']} located in {best['country']}")
print(Colors.OKBLUE + "Performing Download Test ...")
download_result = test.download()
print(Colors.OKBLUE + "Performing Upload Test ...")
upload_result = test.upload()
ping_result = test.results.ping
print(Colors.OKGREEN + f"DOWNLOAD SPEED : {download_result / 1024 / 1024:.2f} Mbits/Second")
print(Colors.OKGREEN + f"UPLOAD SPEED : {upload_result / 1024 / 1024:.2f} Mbits/Second")
print(Colors.OKGREEN + f"Ping : {ping_result:.2f} ms")
except ConnectionError:
print(Colors.WARNING + "Unable to connect to speed test server check your and try again")