Add --no-download and --no-upload

Add --no-download and --no-upload. These flags allow the download
and/or upload tests to be skipped. These are useful when debugging
a problem that appears only with upload or download, and makes
a tcpdump more readable.

Signed-off-by: Alex Bligh <alex@alex.org.uk>
This commit is contained in:
Alex Bligh 2017-03-18 19:24:06 +01:00
parent 068d71597b
commit 4be797d5cd
1 changed files with 20 additions and 14 deletions

View File

@ -1226,6 +1226,10 @@ def parse_args():
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('--no-download', action='store_true', default=False,
help='Skip the download test')
parser.add_argument('--no-upload', action='store_true', default=False,
help='Skip the upload 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')
parser.add_argument('--debug', action='store_true', parser.add_argument('--debug', action='store_true',
@ -1381,6 +1385,7 @@ def shell():
printer('Hosted by %(sponsor)s (%(name)s) [%(d)0.2f km]: ' printer('Hosted by %(sponsor)s (%(name)s) [%(d)0.2f km]: '
'%(latency)s ms' % results.server, quiet) '%(latency)s ms' % results.server, quiet)
if not args.no_download:
printer('Testing download speed', quiet, printer('Testing download speed', quiet,
end=('', '\n')[bool(debug)]) end=('', '\n')[bool(debug)])
speedtest.download(callback=callback) speedtest.download(callback=callback)
@ -1389,6 +1394,7 @@ def shell():
args.units[0]), args.units[0]),
quiet) quiet)
if not args.no_upload:
printer('Testing upload speed', quiet, printer('Testing upload speed', quiet,
end=('', '\n')[bool(debug)]) end=('', '\n')[bool(debug)])
speedtest.upload(callback=callback) speedtest.upload(callback=callback)