Added a --random option for test purposes

This commit is contained in:
Eduardo Minguez 2016-09-22 11:10:30 +02:00
parent 7b09d8759f
commit 0012233e94
1 changed files with 13 additions and 0 deletions

View File

@ -24,6 +24,7 @@ import socket
import timeit import timeit
import platform import platform
import threading import threading
import random
__version__ = '0.3.4' __version__ = '0.3.4'
@ -546,6 +547,12 @@ def version():
raise SystemExit(__version__) raise SystemExit(__version__)
def simplerandom():
print_('Ping: %0.2f ms' % random.uniform(0.0,10.0))
print_('Download: %0.2f Mbps' % random.uniform(1.0,100.0))
print_('Upload: %0.2f mbps' % random.uniform(1.0,100.0))
sys.exit(1)
def speedtest(): def speedtest():
"""Run the full speedtest.net test""" """Run the full speedtest.net test"""
@ -590,6 +597,8 @@ def speedtest():
parser.add_argument('--secure', action='store_true', parser.add_argument('--secure', action='store_true',
help='Use HTTPS instead of HTTP when communicating ' help='Use HTTPS instead of HTTP when communicating '
'with speedtest.net operated servers') 'with speedtest.net operated servers')
parser.add_argument('--simplerandom', action='store_true',
help='Output random data to test')
parser.add_argument('--version', action='store_true', parser.add_argument('--version', action='store_true',
help='Show the version number and exit') help='Show the version number and exit')
@ -600,6 +609,10 @@ def speedtest():
args = options args = options
del options del options
# Random
if args.simplerandom:
simplerandom()
# Print the version and exit # Print the version and exit
if args.version: if args.version:
version() version()