Browse Source

added tabs, started working on file writing

master
wargus 5 months ago
parent
commit
2828a8f187
2 changed files with 135 additions and 3 deletions
  1. 124
    0
      .gitignore
  2. 11
    3
      src/improved-speedtest/improved-speedtest.py

+ 124
- 0
.gitignore View File

@@ -0,0 +1,124 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

+ 11
- 3
src/improved-speedtest/improved-speedtest.py View File

@@ -1,7 +1,9 @@
#!/usr/bin/env python3
import argparse, subprocess,json

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,type=bool,help="Enable logging to file, will dump to log in local directory")
args = parser.parse_args()

encoding='latin1'
@@ -12,17 +14,23 @@ p = subprocess.run([cmd,""],shell=True,stdin=subprocess.PIPE, stdout=subprocess.
serverlist=str.split(str(p.stdout,encoding),sep="\n")
serverlist.pop()

#print(serverlist)
#print(cmd)
print("Testing "+str(len(serverlist))+" Servers in "+str(args.location))

NoOfServers=0
for i in serverlist:
NoOfServers+=1

speedtest = "speedtest --json --server "+i
p = subprocess.run([speedtest,""],shell=True,stdin=subprocess.PIPE, stdout=subprocess.PIPE,stderr=subprocess.PIPE)
completevalues = json.loads(str(p.stdout,encoding))
if NoOfServers==1:
print("Testing From ISP: "+str(completevalues['client']['isp'])+", IP: "+str(completevalues['client']['ip']))
f= open()

download = round(float(completevalues['download']) / 1000.0/1000.0, 2)
ping = completevalues['ping']
upload = round(float(completevalues['upload']) / 1000.0/1000.0, 2)
output = str(completevalues['server']['sponsor']) +": D: " +str(download)+"MBps U: "+str(upload)+"MBps Ping: "+str(ping)+"ms"
output = "Testing Server "+str(NoOfServers)+": "+str(completevalues['server']['sponsor']) +":\t D: " +str(download)+"MBps\t U: "+str(upload)+"MBps\t Ping: "+str(ping)+"ms"
print(output)

Loading…
Cancel
Save