add log option
This commit is contained in:
parent
f1647f2c9e
commit
c72da6c0b9
|
@ -30,6 +30,8 @@ import re
|
||||||
import signal
|
import signal
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
|
from importlib import import_module
|
||||||
|
|
||||||
# Used for bound_interface
|
# Used for bound_interface
|
||||||
socket_socket = socket.socket
|
socket_socket = socket.socket
|
||||||
|
|
||||||
|
@ -469,7 +471,12 @@ 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('--resultlog', action='store',
|
||||||
|
help='Module name to use for result logging',
|
||||||
|
default=None, metavar='path.to.module')
|
||||||
|
|
||||||
options = parser.parse_args()
|
options = parser.parse_args()
|
||||||
|
|
||||||
if isinstance(options, tuple):
|
if isinstance(options, tuple):
|
||||||
args = options[0]
|
args = options[0]
|
||||||
else:
|
else:
|
||||||
|
@ -571,6 +578,7 @@ def speedtest():
|
||||||
best = getBestServer(servers)
|
best = getBestServer(servers)
|
||||||
except:
|
except:
|
||||||
best = servers[0]
|
best = servers[0]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if not args.simple:
|
if not args.simple:
|
||||||
print_('Selecting best server based on ping...')
|
print_('Selecting best server based on ping...')
|
||||||
|
@ -662,6 +670,18 @@ def speedtest():
|
||||||
print_('Share results: http://www.speedtest.net/result/%s.png' %
|
print_('Share results: http://www.speedtest.net/result/%s.png' %
|
||||||
resultid[0])
|
resultid[0])
|
||||||
|
|
||||||
|
if args.resultlog:
|
||||||
|
logmodule = None
|
||||||
|
try:
|
||||||
|
logmodule = import_module(args.resultlog)
|
||||||
|
except ImportError:
|
||||||
|
print_('Load log module (%s) failed.' % args.resultlog),
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
result = {'dlspeed': dlspeed, 'ulspeed': ulspeed}
|
||||||
|
log = logmodule.logger(config, best, result)
|
||||||
|
log.logresult()
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue