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
|
source = args.source
|
||||||
socket.socket = bound_socket
|
socket.socket = bound_socket
|
||||||
|
|
||||||
|
if not args.mini:
|
||||||
if not args.simple:
|
if not args.simple:
|
||||||
print_('Retrieving speedtest.net configuration...')
|
print_('Retrieving speedtest.net configuration...')
|
||||||
try:
|
try:
|
||||||
@ -588,6 +589,7 @@ def speedtest():
|
|||||||
print_('Cannot retrieve speedtest configuration')
|
print_('Cannot retrieve speedtest configuration')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
if not args.mini:
|
||||||
if not args.simple:
|
if not args.simple:
|
||||||
print_('Retrieving speedtest.net server list...')
|
print_('Retrieving speedtest.net server list...')
|
||||||
if args.list or args.server:
|
if args.list or args.server:
|
||||||
@ -598,7 +600,7 @@ def speedtest():
|
|||||||
line = ('%(id)4s) %(sponsor)s (%(name)s, %(country)s) '
|
line = ('%(id)4s) %(sponsor)s (%(name)s, %(country)s) '
|
||||||
'[%(d)0.2f km]' % server)
|
'[%(d)0.2f km]' % server)
|
||||||
serverList.append(line)
|
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.
|
# from parsing the XML, but older versions have some issues.
|
||||||
# This block should detect whether we need to encode or not
|
# This block should detect whether we need to encode or not
|
||||||
try:
|
try:
|
||||||
@ -612,7 +614,7 @@ def speedtest():
|
|||||||
else:
|
else:
|
||||||
servers = closestServers(config['client'])
|
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'])
|
print_('Testing from %(isp)s (%(ip)s)...' % config['client'])
|
||||||
|
|
||||||
if args.server:
|
if args.server:
|
||||||
@ -636,9 +638,9 @@ def speedtest():
|
|||||||
print_('Invalid Speedtest Mini URL')
|
print_('Invalid Speedtest Mini URL')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
text = f.read()
|
text = f.read().decode('utf-8', 'ignore')
|
||||||
f.close()
|
f.close()
|
||||||
extension = re.findall('upload_extension: "([^"]+)"', text.decode())
|
extension = re.findall('upload_extension: "([^"]+)"', text)
|
||||||
if not extension:
|
if not extension:
|
||||||
for ext in ['php', 'asp', 'aspx', 'jsp']:
|
for ext in ['php', 'asp', 'aspx', 'jsp']:
|
||||||
try:
|
try:
|
||||||
@ -648,7 +650,7 @@ def speedtest():
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
data = f.read().strip()
|
data = f.read().decode('utf-8', 'ignore').strip()
|
||||||
if (f.code == 200 and
|
if (f.code == 200 and
|
||||||
len(data.splitlines()) == 1 and
|
len(data.splitlines()) == 1 and
|
||||||
re.match('size=[0-9]', data)):
|
re.match('size=[0-9]', data)):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user