Beispiel #1
0
codename = release[1][0].upper() + release[1][1:]
mirror_list = "http://mirrors.ubuntu.com/mirrors.txt"
try:
    archives = urlopen(mirror_list)
except IOError as err:
    print(("Could not connect to '%s'.\nCheck network connection\n"
           "%s" % (mirror_list, err)))
    sys.exit(1)

print("Got list of mirrors")
archives = archives.read().decode()
urls = findall(r'http://([\w|\.|\-]+)/', archives)
n = 0
avg_rtts = {}
for url in urls:
    ping = RoundTrip(url)
    print("Connecting to %s" % url)
    avg = ping.avgRTT()
    if avg:
        avg_rtts.update({url:avg})
        n += 1
        
print("Tested %d mirrors" % n)
if hardware == 'x86_64':
    hardware = 'amd64'
else:
    hardware = 'i386'

top_num = 5
ranks = sorted(avg_rtts, key=avg_rtts.__getitem__)
info = []
Beispiel #2
0
codename = release[1][0].upper() + release[1][1:]
mirror_list = "http://mirrors.ubuntu.com/mirrors.txt"
try:
    archives = urlopen(mirror_list)
except IOError as err:
    print(("Could not connect to '%s'.\n" "%s" % (mirror_list, err)))
    exit(1)

print("Got list of mirrors")
archives = archives.read().decode()
urls = findall(r'http://([\w|\.|\-]+)/', archives)
n = 0
avg_rtts = {}
for url in urls:
    ping = RoundTrip(url)
    print("Connecting to %s" % url)
    avg = ping.avgRTT()
    if avg:
        avg_rtts.update({url: avg})
        n += 1

print("Tested %d mirrors" % n)
if hardware == 'x86_64':
    hardware = 'amd64'
else:
    hardware = 'i386'

top_num = 5
ranks = sorted(avg_rtts, key=avg_rtts.__getitem__)
info = []
Beispiel #3
0
        percent = int((float(processed) / total) * 100)
        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"
Beispiel #4
0
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"