mirror of
https://github.com/moparisthebest/pacman
synced 2025-01-11 05:48:09 -05:00
rankmirrors : add support for the $repo var in url.
To keep working correctly with url like : ftp://ftp.archlinux.org/$repo/os/i686 rankmirrors will now replace $repo by core. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
708488f6fe
commit
3955858a2d
@ -22,6 +22,7 @@
|
|||||||
#
|
#
|
||||||
import os, sys, datetime, time, socket, urllib2
|
import os, sys, datetime, time, socket, urllib2
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
|
from string import Template
|
||||||
|
|
||||||
def createOptParser():
|
def createOptParser():
|
||||||
usage = "usage: %prog [options] MIRRORFILE | URL"
|
usage = "usage: %prog [options] MIRRORFILE | URL"
|
||||||
@ -149,12 +150,15 @@ if __name__ == "__main__":
|
|||||||
print ' * ',
|
print ' * ',
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
# if the $repo var is used in the url, replace it by core
|
||||||
|
tempUrl = Template(serverUrl).safe_substitute(repo='core')
|
||||||
|
|
||||||
# add *.db.tar.gz to server name. the repo name is parsed
|
# 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 mirror url; it is the third (or fourth) dir
|
||||||
# from the end, where the url is http://foo/bar/REPO/os/arch
|
# from the end, where the url is http://foo/bar/REPO/os/arch
|
||||||
try:
|
try:
|
||||||
splitted2 = serverUrl.split('/')
|
splitted2 = tempUrl.split('/')
|
||||||
if serverUrl[-1] != '/':
|
if tempUrl[-1] != '/':
|
||||||
repoName = splitted2[-3]
|
repoName = splitted2[-3]
|
||||||
dbFileName = '/' + repoName + '.db.tar.gz'
|
dbFileName = '/' + repoName + '.db.tar.gz'
|
||||||
else:
|
else:
|
||||||
@ -164,7 +168,7 @@ if __name__ == "__main__":
|
|||||||
dbFileName = ''
|
dbFileName = ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
serverToTime[serverUrl] = timeCmd(getFuncToTime(serverUrl + dbFileName))
|
serverToTime[serverUrl] = timeCmd(getFuncToTime(tempUrl + dbFileName))
|
||||||
if options.verbose:
|
if options.verbose:
|
||||||
try:
|
try:
|
||||||
print "%.2f" % serverToTime[serverUrl]
|
print "%.2f" % serverToTime[serverUrl]
|
||||||
|
Loading…
Reference in New Issue
Block a user