[pacman-dev] CVS update of pacman-lib/scripts (rankmirrors)

Dan McGee dan at archlinux.org
Mon Apr 23 00:09:00 EDT 2007


    Date: Monday, April 23, 2007 @ 00:09:00
  Author: dan
    Path: /home/cvs-pacman/pacman-lib/scripts

Modified: rankmirrors (1.8 -> 1.9)

rankmirrors: download first 50KB of DB to get more reliable numbers
Scott Horowitz <stonecrest at gmail.com>


-------------+
 rankmirrors |   20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)


Index: pacman-lib/scripts/rankmirrors
diff -u pacman-lib/scripts/rankmirrors:1.8 pacman-lib/scripts/rankmirrors:1.9
--- pacman-lib/scripts/rankmirrors:1.8	Sun Mar 11 23:02:58 2007
+++ pacman-lib/scripts/rankmirrors	Mon Apr 23 00:09:00 2007
@@ -55,7 +55,8 @@
 
 def talkToServer(serverUrl):
     opener = urllib2.build_opener()
-    tmp = opener.open(serverUrl).read()
+    # retrieve first 50,000 bytes only
+    tmp = opener.open(serverUrl).read(50000)
 
 def getFuncToTime(serverUrl):
     return lambda : talkToServer(serverUrl)
@@ -139,8 +140,23 @@
         elif options.times:
             print ' * ',
         sys.stdout.flush()
+
+        # add *.db.tar.gz to server name. the repo name is parsed
+        # from the mirror url; it is the third (or fourth) dir
+        # from the end, where the url is http://foo/bar/REPO/os/arch
+        try:
+            splitted2 = serverUrl.split('/')
+            if serverUrl[-1] != '/':
+                repoName = splitted2[-3]
+                dbFileName = '/' + repoName + '.db.tar.gz'
+            else:
+                repoName = splitted2[-4]
+                dbFileName = repoName + '.db.tar.gz'
+        except:
+            dbFileName = ''
+
         try:
-            serverToTime[serverUrl] = timeCmd(getFuncToTime(serverUrl))
+            serverToTime[serverUrl] = timeCmd(getFuncToTime(serverUrl + dbFileName))
             if options.verbose:
                 try:
                     print "%.2f" % serverToTime[serverUrl]




More information about the pacman-dev mailing list