if not status: message = "Testing %d mirror(s)" % total else: message = "Looking up status(es)" stdout.write("%s [%d/%d] %d%%" % (message, processed, total, percent)) stdout.flush() tested = 0 processed = 0 low_rtts = {} num_urls = len(urls) progressUpdate(0, num_urls) for url in urls: ping = RoundTrip(url) lowest = ping.minRTT() if lowest: low_rtts.update({url:lowest}) tested += 1 processed += 1 progressUpdate(processed, num_urls) print() if len(low_rtts) == 0: errorExit( ( "Cannot connect to any mirrors in %s\n." "Minimum latency of this machine may exceed" "2.5 seconds or\nthere may be other unknown"
def progressUpdate(processed, total, message): if total > 1: stdout.write('\r') percent = int((float(processed) / total) * 100) stdout.write("%s [%d/%d] %d%%" % (message, processed, total, percent)) stdout.flush() tested = 0 processed = 0 low_rtts = {} num_urls = len(urls) message = "Testing %d mirror(s)" % num_urls progressUpdate(0, num_urls, message) for url in urls: ping = RoundTrip(url) lowest = ping.minRTT() if lowest: low_rtts.update({url:lowest}) tested += 1 processed += 1 progressUpdate(processed, num_urls, message) print() if len(low_rtts) == 0: errorExit( ( "Cannot connect to any mirrors in %s\n." "Minimum latency of this machine may exceed" "2.5 seconds or\nthere may be other unknown"