[pacman-dev] rankmirrors (default vs -f)
It seems that the default rankmirrors output without opts is to show times. rankmirrors -f is the much more common output that people would want imo, where you actually get a formatted /etc/pacman.d file. So I'd suggest one of two things: 1. Have rankmirrors without opts output formatted mirrors and add a rankmirrors -t to show times, or 2. Combine the two such that you get formatted output and (commented out) times. a. the times could be appended at the bottom b. times could be appended to each line (if pacman can handle this? i haven't checked). So, option 2a would be: Server = ftp://mirror.cs.vt.edu/pub/ArchLinux/current/os/i686 Server = ftp://ftp.archlinux.org/current/os/i686 # Servers sorted by time: #1.59783601761 : http://www2.cddc.vt.edu/linux/distributions/archlinux/community/os/i686 #2.19922399521 : ftp://ftp.archlinux.org/community/os/i686 And 2b would be: Server = ftp://mirror.cs.vt.edu/pub/ArchLinux/current/os/i686 # 1.59783601761 sec Server = ftp://ftp.archlinux.org/current/os/i686 # 2.19922399521 sec I personally like 2b best. And finally, I don't think we need to go to the hundred billionths decimal place for seconds ;-) Scott
Alright, here is a patch for option 1 (seeing how option 2b is not possible with pacman). This removes the -f opt, adds the -t opt, and formats output times to 2 decimal points. Scott --- /usr/bin/rankmirrors 2007-03-04 10:35:29.000000000 -0700 +++ rankmirrors 2007-03-04 13:58:10.000000000 -0700 @@ -29,9 +29,9 @@ "speed. Pacman mirror files are located in /etc/pacman.d/. It " \ "can also rank one mirror if the URL is provided." parser = OptionParser(usage = usage, description = description) - parser.add_option("-f", "--formatted", action = "store_true", - dest = "formatted", default = False, - help = "output in mirror file format") + parser.add_option("-t", "--times", action = "store_true", + dest = "times", default = False, + help = "output only response times for mirrors") parser.add_option("-n", type = "int", dest = "num", default = 0, help = "number of servers to output, 0 for all") parser.add_option("-u", "--url", action = "store_true", dest = "url", @@ -88,25 +88,25 @@ fl = open(args[0], 'r') serverToTime = {} - if options.formatted: + if options.times: + print 'Querying servers, this may take some time...' + else: print "# Server list generated by rankmirrors on", print datetime.date.today() - else: - print 'Querying servers, this may take some time...' for ln in fl.readlines(): splitted = ln.split('=') if splitted[0].strip() != 'Server': - if options.formatted: + if not options.times: print ln, continue serverUrl = splitted[1].strip() if serverUrl[-1] == '\n': serverUrl = serverUrl[0:-1] - if options.verbose and options.formatted: + if options.verbose and not options.times: print '#',serverUrl,'...', elif options.verbose: print serverUrl,'...', - elif not options.formatted: + elif options.times: print ' * ', sys.stdout.flush() serverToTime[serverUrl] = timeCmd(getFuncToTime(serverUrl)) @@ -118,13 +118,16 @@ numToShow = int(options.num) if numToShow == 0: numToShow = len(items) if len(items) > 0: - if options.formatted: + if options.times: + print + print ' Servers sorted by time (seconds):' for i in items[0:numToShow]: - print 'Server =', i[0] + try: + print "%.2f" % i[1], ':', i[0] + except: + print i[1], ':', i[0] else: - print - print ' Servers sorted by time:' for i in items[0:numToShow]: - print i[1], ':', i[0] + print 'Server =', i[0] # vim: set ts=4 sw=4 et:
participants (1)
-
Scott Horowitz