Remove unneeded var, clear servers on get_servers and break if we were successful collecting servers

This commit is contained in:
Matt Martz 2016-05-16 11:34:38 -05:00
parent e14f7ed108
commit 050da542b3
1 changed files with 3 additions and 2 deletions

View File

@ -755,6 +755,7 @@ class Speedtest(object):
"""Retrieve a the list of speedtest.net servers, optionally filtered """Retrieve a the list of speedtest.net servers, optionally filtered
to servers matching those specified in the ``servers`` argument to servers matching those specified in the ``servers`` argument
""" """
self.servers.clear()
for i, s in enumerate(servers): for i, s in enumerate(servers):
try: try:
@ -834,6 +835,8 @@ class Speedtest(object):
del serversxml del serversxml
del elements del elements
break
except ServersRetrievalError: except ServersRetrievalError:
continue continue
@ -1239,14 +1242,12 @@ def shell():
print_('Cannot retrieve speedtest server list') print_('Cannot retrieve speedtest server list')
sys.exit(1) sys.exit(1)
server_list = []
for _, servers in sorted(speedtest.servers.items()): for _, servers in sorted(speedtest.servers.items()):
for server in servers: for server in servers:
line = ('%(id)5s) %(sponsor)s (%(name)s, %(country)s) ' line = ('%(id)5s) %(sponsor)s (%(name)s, %(country)s) '
'[%(d)0.2f km]' % server) '[%(d)0.2f km]' % server)
try: try:
print_(line) print_(line)
server_list.append(line)
except IOError: except IOError:
e = sys.exc_info()[1] e = sys.exc_info()[1]
if e.errno != errno.EPIPE: if e.errno != errno.EPIPE: