Browse Source

added silent moe

master
Warren Argus 5 months ago
parent
commit
c3b8d4d3ac
1 changed files with 10 additions and 8 deletions
  1. 10
    8
      src/improved-speedtest/improved-speedtest.py

+ 10
- 8
src/improved-speedtest/improved-speedtest.py View File

@@ -1,11 +1,11 @@
#!/usr/bin/env python3
import argparse, subprocess,json, datetime
import argparse, subprocess,json, datetime, os

parser = argparse.ArgumentParser(description="an improved speedtest")
parser.add_argument('location',type=str,help='the location you would like to test')
parser.add_argument('--logging',required=False,action="store_true",help="Enable logging to file, will dump to log in local directory")
parser.add_argument('--limit',type=int,required=False,help="limit the number of servers")
parser.add_argument('--silent',action='store_true',required=False,help="silence output")
args = parser.parse_args()

encoding='latin1'
@@ -27,8 +27,8 @@ if args.limit:
NoOfServers=len(serverlist)
NoOfServers=len(serverlist)
print("Testing "+str(len(serverlist))+" Servers in "+str(args.location))
if args.silent==False:
print("Testing "+str(len(serverlist))+" Servers in "+str(args.location))

datetime_object = datetime.datetime.now()
date = datetime_object.strftime("%Y%m%d-%H%M%S")
@@ -44,15 +44,17 @@ for i in serverlist:
completevalues = json.loads(str(p.stdout,encoding))
if ServerCount==1:
print("Testing From ISP: "+str(completevalues['client']['isp'])+", IP: "+str(completevalues['client']['ip']))
if args.silent==False:
print("Testing From ISP: "+str(completevalues['client']['isp'])+", IP: "+str(completevalues['client']['ip']))
download = round(float(completevalues['download']) / 1000.0/1000.0, 2)
ping = completevalues['ping']
upload = round(float(completevalues['upload']) / 1000.0/1000.0, 2)
output = "Server "+str(ServerCount)+": "+str(completevalues['server']['sponsor']) +":\t\t D: " +str(download)+"MBps\t U: "+str(upload)+"MBps\t Ping: "+str(ping)+"ms"
output = "Server "+str(ServerCount)+": "+str(completevalues['server']['sponsor']) +":\t D: " +str(download)+"MBps\t U: "+str(upload)+"MBps\t Ping: "+str(ping)+"ms"
if args.logging:
with open(filename,'a') as f:
f.write(output+"\n")

print(output)
if args.silent==False:
print(output)

Loading…
Cancel
Save