Merge aed0cb57f2
into 7b09d8759f
This commit is contained in:
commit
7ed5eecae5
|
@ -18,7 +18,7 @@ env:
|
||||||
- TOXENV=py25
|
- TOXENV=py25
|
||||||
- TOXENV=py26
|
- TOXENV=py26
|
||||||
- TOXENV=py27
|
- TOXENV=py27
|
||||||
- TOXENV=py32
|
# - TOXENV=py32 # Testing suite reports python 3.2 not supported
|
||||||
- TOXENV=py33
|
- TOXENV=py33
|
||||||
- TOXENV=py34
|
- TOXENV=py34
|
||||||
- TOXENV=pypy
|
- TOXENV=pypy
|
||||||
|
|
|
@ -76,7 +76,7 @@ Usage
|
||||||
$ speedtest-cli -h
|
$ speedtest-cli -h
|
||||||
usage: speedtest-cli [-h] [--bytes] [--share] [--simple] [--list]
|
usage: speedtest-cli [-h] [--bytes] [--share] [--simple] [--list]
|
||||||
[--server SERVER] [--mini MINI] [--source SOURCE]
|
[--server SERVER] [--mini MINI] [--source SOURCE]
|
||||||
[--timeout TIMEOUT] [--secure] [--version]
|
[--timeout TIMEOUT] [--log LOGFILE] [--secure] [--version]
|
||||||
|
|
||||||
Command line interface for testing internet bandwidth using speedtest.net.
|
Command line interface for testing internet bandwidth using speedtest.net.
|
||||||
--------------------------------------------------------------------------
|
--------------------------------------------------------------------------
|
||||||
|
@ -95,6 +95,7 @@ Usage
|
||||||
--mini MINI URL of the Speedtest Mini server
|
--mini MINI URL of the Speedtest Mini server
|
||||||
--source SOURCE Source IP address to bind to
|
--source SOURCE Source IP address to bind to
|
||||||
--timeout TIMEOUT HTTP timeout in seconds. Default 10
|
--timeout TIMEOUT HTTP timeout in seconds. Default 10
|
||||||
|
--log LOGFILE Append a one line CSV entry to LOGFILE
|
||||||
--secure Use HTTPS instead of HTTP when communicating with
|
--secure Use HTTPS instead of HTTP when communicating with
|
||||||
speedtest.net operated servers
|
speedtest.net operated servers
|
||||||
--version Show the version number and exit
|
--version Show the version number and exit
|
||||||
|
|
|
@ -58,6 +58,11 @@ URL of the Speedtest Mini server
|
||||||
Source IP address to bind to
|
Source IP address to bind to
|
||||||
.RE
|
.RE
|
||||||
|
|
||||||
|
\fB\-\-log LOGFILE\fR
|
||||||
|
.RS
|
||||||
|
File to append a CSV log entry to
|
||||||
|
.RE
|
||||||
|
|
||||||
\fB\-\-version\fR
|
\fB\-\-version\fR
|
||||||
.RS
|
.RS
|
||||||
Show the version number and exit
|
Show the version number and exit
|
||||||
|
|
|
@ -24,6 +24,7 @@ import socket
|
||||||
import timeit
|
import timeit
|
||||||
import platform
|
import platform
|
||||||
import threading
|
import threading
|
||||||
|
import datetime
|
||||||
|
|
||||||
__version__ = '0.3.4'
|
__version__ = '0.3.4'
|
||||||
|
|
||||||
|
@ -593,6 +594,8 @@ def speedtest():
|
||||||
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('--log', help='Append results to log file')
|
||||||
|
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
if isinstance(options, tuple):
|
if isinstance(options, tuple):
|
||||||
args = options[0]
|
args = options[0]
|
||||||
|
@ -784,6 +787,33 @@ def speedtest():
|
||||||
print_('Share results: %s://www.speedtest.net/result/%s.png' %
|
print_('Share results: %s://www.speedtest.net/result/%s.png' %
|
||||||
(scheme, resultid[0]))
|
(scheme, resultid[0]))
|
||||||
|
|
||||||
|
if args.log:
|
||||||
|
log_output = ['{:%Y-%b-%d, %H:%M:%S}'.format(datetime.datetime.now()),
|
||||||
|
'%0.2f' % (dlspeed / 1000000 * 8),
|
||||||
|
'%0.2f' % (ulspeed / 1000000 * 8),
|
||||||
|
config['client']['isp'],
|
||||||
|
config['client']['ip'],
|
||||||
|
best['sponsor'],
|
||||||
|
best['name'],
|
||||||
|
'%(d)0.2f, %(latency)0.2f' % best]
|
||||||
|
|
||||||
|
if args.share:
|
||||||
|
log_output.append('%s://www.speedtest.net/result/%s.png' %
|
||||||
|
(scheme, resultid[0]))
|
||||||
|
|
||||||
|
fresh_file = not os.path.isfile(args.log)
|
||||||
|
|
||||||
|
try:
|
||||||
|
log_file = open(args.log, 'a')
|
||||||
|
if fresh_file:
|
||||||
|
log_file.write('Date, Time, Download (Mbps), Upload (Mbps), '
|
||||||
|
'Your ISP, Your IP, '
|
||||||
|
'Sponsor, Location, Distance (km), '
|
||||||
|
'Latency (ms), Sharing link\n')
|
||||||
|
log_file.write('%s\n' % ', '.join(log_output))
|
||||||
|
except:
|
||||||
|
print_('\nLog file update failed')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue