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