diff --git a/speedtest_cli.py b/speedtest_cli.py index 3b657cf..cce7443 100755 --- a/speedtest_cli.py +++ b/speedtest_cli.py @@ -616,6 +616,9 @@ class Speedtest(object): geographic distance """ + if not self.servers: + self.get_servers() + for d in sorted(self.servers.keys()): for s in self.servers[d]: self.closest.append(s) @@ -627,11 +630,16 @@ class Speedtest(object): return self.closest - def get_best_server(self, servers): + def get_best_server(self, servers=[]): """Perform a speedtest.net "ping" to determine which speedtest.net server has the lowest latency """ + if not servers: + if not self.closest: + servers = self.get_closest() + servers = self.closest + results = {} for server in servers: cum = []