distance, upload and download options
Now user can limit output from --list parameter using --distance parameter (parameter can be used without --list parameter) Added support for testing only download or upload
This commit is contained in:
parent
7b09d8759f
commit
10d666daac
49
README.rst
49
README.rst
|
@ -74,30 +74,35 @@ Usage
|
||||||
::
|
::
|
||||||
|
|
||||||
$ speedtest-cli -h
|
$ speedtest-cli -h
|
||||||
usage: speedtest-cli [-h] [--bytes] [--share] [--simple] [--list]
|
usage: speedtest_cli.py [-h] [--bytes] [--share] [--simple] [--list]
|
||||||
[--server SERVER] [--mini MINI] [--source SOURCE]
|
[--distance DISTANCE] [--download] [--upload]
|
||||||
[--timeout TIMEOUT] [--secure] [--version]
|
[--server SERVER] [--mini MINI] [--source SOURCE]
|
||||||
|
[--timeout TIMEOUT] [--secure] [--version]
|
||||||
|
|
||||||
Command line interface for testing internet bandwidth using speedtest.net.
|
Command line interface for testing internet bandwidth using speedtest.net.
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
https://github.com/sivel/speedtest-cli
|
https://github.com/sivel/speedtest-cli
|
||||||
|
|
||||||
optional arguments:
|
optional arguments:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
--bytes Display values in bytes instead of bits. Does not affect
|
--bytes Display values in bytes instead of bits. Does not
|
||||||
the image generated by --share
|
affect the image generated by --share
|
||||||
--share Generate and provide a URL to the speedtest.net share
|
--share Generate and provide a URL to the speedtest.net share
|
||||||
results image
|
results image
|
||||||
--simple Suppress verbose output, only show basic information
|
--simple Suppress verbose output, only show basic information
|
||||||
--list Display a list of speedtest.net servers sorted by
|
--list Display a list of speedtest.net servers sorted by
|
||||||
distance
|
distance
|
||||||
--server SERVER Specify a server ID to test against
|
--distance DISTANCE Limit distance speedtest.net servers, list only closer
|
||||||
--mini MINI URL of the Speedtest Mini server
|
servers than specified
|
||||||
--source SOURCE Source IP address to bind to
|
--download Test only download
|
||||||
--timeout TIMEOUT HTTP timeout in seconds. Default 10
|
--upload Test only upload
|
||||||
--secure Use HTTPS instead of HTTP when communicating with
|
--server SERVER Specify a server ID to test against
|
||||||
speedtest.net operated servers
|
--mini MINI URL of the Speedtest Mini server
|
||||||
--version Show the version number and exit
|
--source SOURCE Source IP address to bind to
|
||||||
|
--timeout TIMEOUT HTTP timeout in seconds. Default 10
|
||||||
|
--secure Use HTTPS instead of HTTP when communicating with
|
||||||
|
speedtest.net operated servers
|
||||||
|
--version Show the version number and exit
|
||||||
|
|
||||||
Inconsistency
|
Inconsistency
|
||||||
-------------
|
-------------
|
||||||
|
|
|
@ -582,6 +582,13 @@ def speedtest():
|
||||||
parser.add_argument('--list', action='store_true',
|
parser.add_argument('--list', action='store_true',
|
||||||
help='Display a list of speedtest.net servers '
|
help='Display a list of speedtest.net servers '
|
||||||
'sorted by distance')
|
'sorted by distance')
|
||||||
|
parser.add_argument('--distance',
|
||||||
|
help='Limit distance speedtest.net servers, '
|
||||||
|
'list only closer servers than specified')
|
||||||
|
parser.add_argument('--download', action='store_true',
|
||||||
|
help='Test only download')
|
||||||
|
parser.add_argument('--upload', action='store_true',
|
||||||
|
help='Test only upload')
|
||||||
parser.add_argument('--server', help='Specify a server ID to test against')
|
parser.add_argument('--server', help='Specify a server ID to test against')
|
||||||
parser.add_argument('--mini', help='URL of the Speedtest Mini server')
|
parser.add_argument('--mini', help='URL of the Speedtest Mini server')
|
||||||
parser.add_argument('--source', help='Source IP address to bind to')
|
parser.add_argument('--source', help='Source IP address to bind to')
|
||||||
|
@ -627,11 +634,13 @@ def speedtest():
|
||||||
|
|
||||||
if not args.simple:
|
if not args.simple:
|
||||||
print_('Retrieving speedtest.net server list...')
|
print_('Retrieving speedtest.net server list...')
|
||||||
if args.list or args.server:
|
if args.list or args.server or args.distance:
|
||||||
servers = closestServers(config['client'], True)
|
servers = closestServers(config['client'], True)
|
||||||
if args.list:
|
if args.list or args.distance:
|
||||||
serverList = []
|
serverList = []
|
||||||
for server in servers:
|
for server in servers:
|
||||||
|
if args.distance and server['d'] > int(args.distance):
|
||||||
|
break
|
||||||
line = ('%(id)4s) %(sponsor)s (%(name)s, %(country)s) '
|
line = ('%(id)4s) %(sponsor)s (%(name)s, %(country)s) '
|
||||||
'[%(d)0.2f km]' % server)
|
'[%(d)0.2f km]' % server)
|
||||||
serverList.append(line)
|
serverList.append(line)
|
||||||
|
@ -708,36 +717,47 @@ def speedtest():
|
||||||
else:
|
else:
|
||||||
print_('Ping: %(latency)s ms' % best)
|
print_('Ping: %(latency)s ms' % best)
|
||||||
|
|
||||||
sizes = [350, 500, 750, 1000, 1500, 2000, 2500, 3000, 3500, 4000]
|
if not args.upload or args.download:
|
||||||
urls = []
|
sizes = [350, 500, 750, 1000, 1500, 2000, 2500, 3000, 3500, 4000]
|
||||||
for size in sizes:
|
urls = []
|
||||||
for i in range(0, 4):
|
for size in sizes:
|
||||||
urls.append('%s/random%sx%s.jpg' %
|
for i in range(0, 4):
|
||||||
(os.path.dirname(best['url']), size, size))
|
urls.append('%s/random%sx%s.jpg' %
|
||||||
if not args.simple:
|
(os.path.dirname(best['url']), size, size))
|
||||||
print_('Testing download speed', end='')
|
if not args.simple:
|
||||||
dlspeed = downloadSpeed(urls, args.simple)
|
print_('Testing download speed', end='')
|
||||||
if not args.simple:
|
dlspeed = downloadSpeed(urls, args.simple)
|
||||||
print_()
|
|
||||||
print_('Download: %0.2f M%s/s' %
|
|
||||||
((dlspeed / 1000 / 1000) * args.units[1], args.units[0]))
|
|
||||||
|
|
||||||
sizesizes = [int(.25 * 1000 * 1000), int(.5 * 1000 * 1000)]
|
if not args.simple:
|
||||||
sizes = []
|
print_()
|
||||||
for size in sizesizes:
|
print_('Download: %0.2f M%s/s' %
|
||||||
for i in range(0, 25):
|
((dlspeed / 1000 / 1000) * args.units[1], args.units[0]))
|
||||||
sizes.append(size)
|
else:
|
||||||
if not args.simple:
|
dlspeed = 0
|
||||||
print_('Testing upload speed', end='')
|
|
||||||
ulspeed = uploadSpeed(best['url'], sizes, args.simple)
|
if not args.download or args.upload:
|
||||||
if not args.simple:
|
sizesizes = [int(.25 * 1000 * 1000), int(.5 * 1000 * 1000)]
|
||||||
print_()
|
sizes = []
|
||||||
print_('Upload: %0.2f M%s/s' %
|
for size in sizesizes:
|
||||||
((ulspeed / 1000 / 1000) * args.units[1], args.units[0]))
|
for i in range(0, 25):
|
||||||
|
sizes.append(size)
|
||||||
|
if not args.simple:
|
||||||
|
print_('Testing upload speed', end='')
|
||||||
|
ulspeed = uploadSpeed(best['url'], sizes, args.simple)
|
||||||
|
|
||||||
|
if not args.simple:
|
||||||
|
print_()
|
||||||
|
print_('Upload: %0.2f M%s/s' %
|
||||||
|
((ulspeed / 1000 / 1000) * args.units[1], args.units[0]))
|
||||||
|
else:
|
||||||
|
ulspeed = 0
|
||||||
|
|
||||||
if args.share and args.mini:
|
if args.share and args.mini:
|
||||||
print_('Cannot generate a speedtest.net share results image while '
|
print_('Cannot generate a speedtest.net share results image while '
|
||||||
'testing against a Speedtest Mini server')
|
'testing against a Speedtest Mini server')
|
||||||
|
elif args.share and (args.upload != args.download):
|
||||||
|
print_('Cannot generate a speedtest.net share results image while '
|
||||||
|
'testing only download or upload')
|
||||||
elif args.share:
|
elif args.share:
|
||||||
dlspeedk = int(round((dlspeed / 1000) * 8, 0))
|
dlspeedk = int(round((dlspeed / 1000) * 8, 0))
|
||||||
ping = int(round(best['latency'], 0))
|
ping = int(round(best['latency'], 0))
|
||||||
|
|
Loading…
Reference in New Issue