summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorAaron Griffin <aaron@archlinux.org>2007-01-17 03:48:02 +0000
committerAaron Griffin <aaron@archlinux.org>2007-01-17 03:48:02 +0000
commit2e352141d793e00b6a5b4a6f1efabc2ef8142c0c (patch)
tree7580d07df1cfd57fcc4a4c92a26bdba6a00f8b1b /scripts
parent42f8b8b2d37f879b57ce56b078c82172a6fb996f (diff)
downloadpacman-2e352141d793e00b6a5b4a6f1efabc2ef8142c0c.tar.xz
James Rosten <seinfeld90@gmail.com>
* rankmirrors addition of single url testing
Diffstat (limited to 'scripts')
-rw-r--r--scripts/rankmirrors19
1 files changed, 16 insertions, 3 deletions
diff --git a/scripts/rankmirrors b/scripts/rankmirrors
index 41db9a62..4d48a1bb 100644
--- a/scripts/rankmirrors
+++ b/scripts/rankmirrors
@@ -20,17 +20,19 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
# USA.
#
-import sys, datetime, time, socket, urllib2
+import os, sys, datetime, time, socket, urllib2
from optparse import OptionParser
def createOptParser():
- usage = "usage: %prog [options] MIRRORFILE"
- description = "Ranks pacman mirrors by their connection and opening speed. Pacman mirror files are located in /etc/pacman.d/."
+ usage = "usage: %prog [options] MIRRORFILE | URL"
+ description = "Ranks pacman mirrors by their connection and opening 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("-n", dest="num", default=0,
help="number of servers to output, 0 for all")
+ parser.add_option("-u", "--url", action="store_true", dest="url",
+ default=False, help="test a specific url")
parser.add_option("-v", "--verbose", action="store_true", dest="verbose",
default=False, help="be verbose in output")
return parser
@@ -70,6 +72,17 @@ if __name__ == "__main__":
# allows connections to time out if they take too long
socket.setdefaulttimeout(10)
+ if options.url:
+ if options.verbose:
+ print 'Testing', args[0] + '...'
+ serverToTime = timeCmd(getFuncToTime(args[0]))
+ print args[0], ':', serverToTime
+ sys.exit(0)
+
+ if not os.path.isfile(args[0]):
+ print 'file', args[0], 'does not exist.'
+ sys.exit(1)
+
fl = open(args[0], 'r')
serverToTime = {}
if options.formatted: