Always encode server info
This commit is contained in:
parent
51d0d88b96
commit
1e44e9e2f1
|
@ -633,16 +633,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
|
print_('\n'.join(serverList).encode('utf-8', 'ignore'))
|
||||||
# from parsing the XML, but older versions have some issues.
|
|
||||||
# This block should detect whether we need to encode or not
|
|
||||||
try:
|
|
||||||
unicode()
|
|
||||||
print_('\n'.join(serverList).encode('utf-8', 'ignore'))
|
|
||||||
except NameError:
|
|
||||||
print_('\n'.join(serverList))
|
|
||||||
except IOError:
|
|
||||||
pass
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
else:
|
else:
|
||||||
servers = closestServers(config['client'])
|
servers = closestServers(config['client'])
|
||||||
|
@ -710,16 +701,8 @@ def speedtest():
|
||||||
best = getBestServer(servers)
|
best = getBestServer(servers)
|
||||||
|
|
||||||
if not args.simple:
|
if not args.simple:
|
||||||
# Python 2.7 and newer seem to be ok with the resultant encoding
|
print_(('Hosted by %(sponsor)s (%(name)s) [%(d)0.2f km]: '
|
||||||
# from parsing the XML, but older versions have some issues.
|
'%(latency)s ms' % best).encode('utf-8', 'ignore'))
|
||||||
# This block should detect whether we need to encode or not
|
|
||||||
try:
|
|
||||||
unicode()
|
|
||||||
print_(('Hosted by %(sponsor)s (%(name)s) [%(d)0.2f km]: '
|
|
||||||
'%(latency)s ms' % best).encode('utf-8', 'ignore'))
|
|
||||||
except NameError:
|
|
||||||
print_('Hosted by %(sponsor)s (%(name)s) [%(d)0.2f km]: '
|
|
||||||
'%(latency)s ms' % best)
|
|
||||||
else:
|
else:
|
||||||
print_('Ping: %(latency)s ms' % best)
|
print_('Ping: %(latency)s ms' % best)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue