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
72da41e4fc
commit
b04887ae1a
|
@ -568,6 +568,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:
|
||||||
|
@ -576,6 +577,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:
|
||||||
|
@ -600,7 +602,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:
|
||||||
|
@ -624,9 +626,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(errors="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:
|
||||||
|
@ -636,7 +638,7 @@ def speedtest():
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
data = f.read().strip()
|
data = f.read().decode(errors="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