Allow skipping download or upload tests. Fixes #377
This commit is contained in:
parent
d712f947d9
commit
3feb38d9d4
13
README.rst
13
README.rst
|
@ -74,10 +74,11 @@ Usage
|
||||||
::
|
::
|
||||||
|
|
||||||
$ speedtest-cli -h
|
$ speedtest-cli -h
|
||||||
usage: speedtest-cli [-h] [--bytes] [--share] [--simple] [--csv]
|
usage: speedtest-cli [-h] [--no-download] [--no-upload] [--bytes] [--share]
|
||||||
[--csv-delimiter CSV_DELIMITER] [--csv-header] [--json]
|
[--simple] [--csv] [--csv-delimiter CSV_DELIMITER]
|
||||||
[--list] [--server SERVER] [--mini MINI] [--source SOURCE]
|
[--csv-header] [--json] [--list] [--server SERVER]
|
||||||
[--timeout TIMEOUT] [--secure] [--version]
|
[--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.
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
|
@ -85,11 +86,13 @@ Usage
|
||||||
|
|
||||||
optional arguments:
|
optional arguments:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
|
--no-download Do not perform download test
|
||||||
|
--no-upload Do not perform upload test
|
||||||
--bytes Display values in bytes instead of bits. Does not
|
--bytes Display values in bytes instead of bits. Does not
|
||||||
affect the image generated by --share, nor output from
|
affect the image generated by --share, nor output from
|
||||||
--json or --csv
|
--json or --csv
|
||||||
--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, not displayed with --csv
|
||||||
--simple Suppress verbose output, only show basic information
|
--simple Suppress verbose output, only show basic information
|
||||||
--csv Suppress verbose output, only show basic information
|
--csv Suppress verbose output, only show basic information
|
||||||
in CSV format. Speeds listed in bit/s and not affected
|
in CSV format. Speeds listed in bit/s and not affected
|
||||||
|
|
46
speedtest.py
46
speedtest.py
|
@ -1192,6 +1192,12 @@ def parse_args():
|
||||||
parser.add_argument = parser.add_option
|
parser.add_argument = parser.add_option
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
parser.add_argument('--no-download', dest='download', default=True,
|
||||||
|
action='store_const', const=False,
|
||||||
|
help='Do not perform download test')
|
||||||
|
parser.add_argument('--no-upload', dest='upload', default=True,
|
||||||
|
action='store_const', const=False,
|
||||||
|
help='Do not perform upload test')
|
||||||
parser.add_argument('--bytes', dest='units', action='store_const',
|
parser.add_argument('--bytes', dest='units', action='store_const',
|
||||||
const=('byte', 8), default=('bit', 1),
|
const=('byte', 8), default=('bit', 1),
|
||||||
help='Display values in bytes instead of bits. Does '
|
help='Display values in bytes instead of bits. Does '
|
||||||
|
@ -1288,11 +1294,15 @@ def shell():
|
||||||
if args.version:
|
if args.version:
|
||||||
version()
|
version()
|
||||||
|
|
||||||
|
if not args.download and not args.upload:
|
||||||
|
raise SpeedtestCLIError('Cannot supply both --no-download and '
|
||||||
|
'--no-upload')
|
||||||
|
|
||||||
if args.csv_header:
|
if args.csv_header:
|
||||||
csv_header()
|
csv_header()
|
||||||
|
|
||||||
if len(args.csv_delimiter) != 1:
|
if len(args.csv_delimiter) != 1:
|
||||||
raise SystemExit('--csv-delimiter must be a single character')
|
raise SpeedtestCLIError('--csv-delimiter must be a single character')
|
||||||
|
|
||||||
validate_optional_args(args)
|
validate_optional_args(args)
|
||||||
|
|
||||||
|
@ -1388,21 +1398,27 @@ 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)
|
||||||
|
|
||||||
printer('Testing download speed', quiet,
|
if args.download:
|
||||||
end=('', '\n')[bool(debug)])
|
printer('Testing download speed', quiet,
|
||||||
speedtest.download(callback=callback)
|
end=('', '\n')[bool(debug)])
|
||||||
printer('Download: %0.2f M%s/s' %
|
speedtest.download(callback=callback)
|
||||||
((results.download / 1000.0 / 1000.0) / args.units[1],
|
printer('Download: %0.2f M%s/s' %
|
||||||
args.units[0]),
|
((results.download / 1000.0 / 1000.0) / args.units[1],
|
||||||
quiet)
|
args.units[0]),
|
||||||
|
quiet)
|
||||||
|
else:
|
||||||
|
printer('Skipping download test')
|
||||||
|
|
||||||
printer('Testing upload speed', quiet,
|
if args.upload:
|
||||||
end=('', '\n')[bool(debug)])
|
printer('Testing upload speed', quiet,
|
||||||
speedtest.upload(callback=callback)
|
end=('', '\n')[bool(debug)])
|
||||||
printer('Upload: %0.2f M%s/s' %
|
speedtest.upload(callback=callback)
|
||||||
((results.upload / 1000.0 / 1000.0) / args.units[1],
|
printer('Upload: %0.2f M%s/s' %
|
||||||
args.units[0]),
|
((results.upload / 1000.0 / 1000.0) / args.units[1],
|
||||||
quiet)
|
args.units[0]),
|
||||||
|
quiet)
|
||||||
|
else:
|
||||||
|
printer('Skipping upload test')
|
||||||
|
|
||||||
if args.simple:
|
if args.simple:
|
||||||
print_('Ping: %s ms\nDownload: %0.2f M%s/s\nUpload: %0.2f M%s/s' %
|
print_('Ping: %s ms\nDownload: %0.2f M%s/s\nUpload: %0.2f M%s/s' %
|
||||||
|
|
Loading…
Reference in New Issue