Some fixes for the --mini option.
* Don't fetch speedtest.net configs when using a custom mini server. It don't makes sense and slows down the whole thing. * Add a mising decode() in the variable data, and set both decodes() to ignore encoding errors.
This commit is contained in:
parent
ffd2c7f963
commit
178fe9e31e
|
@ -580,6 +580,7 @@ def speedtest():
|
|||
source = args.source
|
||||
socket.socket = bound_socket
|
||||
|
||||
if not args.mini:
|
||||
if not args.simple:
|
||||
print_('Retrieving speedtest.net configuration...')
|
||||
try:
|
||||
|
@ -588,6 +589,7 @@ def speedtest():
|
|||
print_('Cannot retrieve speedtest configuration')
|
||||
sys.exit(1)
|
||||
|
||||
if not args.mini:
|
||||
if not args.simple:
|
||||
print_('Retrieving speedtest.net server list...')
|
||||
if args.list or args.server:
|
||||
|
@ -598,7 +600,7 @@ def speedtest():
|
|||
line = ('%(id)4s) %(sponsor)s (%(name)s, %(country)s) '
|
||||
'[%(d)0.2f km]' % server)
|
||||
serverList.append(line)
|
||||
# Python 2.7 and newer seem to be ok with the resultant encoding
|
||||
# Python 2.7 or newer seem to be ok with the resultant encoding
|
||||
# from parsing the XML, but older versions have some issues.
|
||||
# This block should detect whether we need to encode or not
|
||||
try:
|
||||
|
@ -612,7 +614,7 @@ def speedtest():
|
|||
else:
|
||||
servers = closestServers(config['client'])
|
||||
|
||||
if not args.simple:
|
||||
if not args.simple and not args.mini:
|
||||
print_('Testing from %(isp)s (%(ip)s)...' % config['client'])
|
||||
|
||||
if args.server:
|
||||
|
@ -636,9 +638,9 @@ def speedtest():
|
|||
print_('Invalid Speedtest Mini URL')
|
||||
sys.exit(1)
|
||||
else:
|
||||
text = f.read()
|
||||
text = f.read().decode('utf-8', 'ignore')
|
||||
f.close()
|
||||
extension = re.findall('upload_extension: "([^"]+)"', text.decode())
|
||||
extension = re.findall('upload_extension: "([^"]+)"', text)
|
||||
if not extension:
|
||||
for ext in ['php', 'asp', 'aspx', 'jsp']:
|
||||
try:
|
||||
|
@ -648,7 +650,7 @@ def speedtest():
|
|||
except:
|
||||
pass
|
||||
else:
|
||||
data = f.read().strip()
|
||||
data = f.read().decode('utf-8', 'ignore').strip()
|
||||
if (f.code == 200 and
|
||||
len(data.splitlines()) == 1 and
|
||||
re.match('size=[0-9]', data)):
|
||||
|
|
Loading…
Reference in New Issue