check-mirrors check-mirrors.conf, 1.2, 1.3 check-mirrors.py, 1.4, 1.5 return-mirrorlist.conf, 1.1, 1.2
Seth Vidal (skvidal)
fedora-extras-commits at redhat.com
Tue Jul 11 14:39:50 UTC 2006
Author: skvidal
Update of /cvs/fedora/check-mirrors
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv30480
Modified Files:
check-mirrors.conf check-mirrors.py return-mirrorlist.conf
Log Message:
- check-mirrors can now use a url for the inputfile
- clean up outputs
Index: check-mirrors.conf
===================================================================
RCS file: /cvs/fedora/check-mirrors/check-mirrors.conf,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- check-mirrors.conf 10 Jul 2006 04:44:25 -0000 1.2
+++ check-mirrors.conf 11 Jul 2006 14:39:47 -0000 1.3
@@ -1,6 +1,14 @@
[core-5]
-inputfile = /tmp/samplelist
+inputfile = http://fedora.redhat.com/download/mirrors/fedora-core-5
outputpath = /tmp/mirrorlists
archlist = i386, x86_64, ppc
timeout = 10
canonical = http://redhat.download.fedoraproject.org/pub/fedora/linux/core/5/$ARCH/os/
+
+[extras-5]
+inputfile = http://fedora.redhat.com/download/mirrors/fedora-extras-5
+outputpath = /tmp/mirrorlists
+archlist = i386, x86_64, ppc
+timeout = 10
+canonical = http://redhat.download.fedoraproject.org/pub/fedora/linux/extras/5/$ARCH/
+
Index: check-mirrors.py
===================================================================
RCS file: /cvs/fedora/check-mirrors/check-mirrors.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- check-mirrors.py 10 Jul 2006 04:38:58 -0000 1.4
+++ check-mirrors.py 11 Jul 2006 14:39:47 -0000 1.5
@@ -26,11 +26,13 @@
# appending to the old ones
# - have it accept an option which specifies a section in the config file
# to operate on - rather than doing all of them.
-# - have it be able to use a remote mirrorlist as the inputfile
-# - make it handle commented and blank lines in inputfile properly.
debug = True
+__revision__ = '$Id$'
+CONFIG = '/etc/check-mirrors.conf'
+VERSION = '0.1'
+
import os
import sys
@@ -193,13 +195,15 @@
try:
fo = self.grabber.urlopen(finurl)
except URLGrabError, e:
- print 'error on %s' % finurl
+ if debug:
+ print 'error on %s' % finurl
continue
try:
p = RepoMD('fooid', fo)
except RepoMDError, e:
- print e
+ if debug:
+ print e
continue
else:
thisdata = p.repoData['primary']
@@ -231,20 +235,23 @@
self.canonical = None
self.mirrorlist = []
- def populate_mirrorlist(self):
+ def populate_mirrorlist(self, grabber_inst):
try:
- fo = open(self.inputfile, 'r')
+ fo = grabber_inst.urlopen(self.inputfile)
except IOError, e:
return
else:
- for url in fo.readlines():
- url = url.replace('\n','')
- self.mirrorlist.append(url)
-
+ content = fo.readlines()
+ for line in content:
+ if re.match('^\s*\#.*', line) or re.match('^\s*$', line):
+ continue
+ mirror = re.sub('\n$', '', line) # no more trailing \n's
+ self.mirrorlist.append(mirror)
+
fo.close()
def config(cfg):
-
+
sections = []
conf = ConfigParser.ConfigParser()
conf.read(cfg)
@@ -294,6 +301,9 @@
def main(cfg_file):
+ if not os.path.exists(cfg_file):
+ errorprint("config file %s does not exist" % cfg_file)
+ sys.exit(1)
sections = config(cfg_file)
mirrors = []
@@ -301,8 +311,9 @@
# grab the canonical mirrors info
for s in sections:
-
- s.populate_mirrorlist()
+
+ ug = URLGrabber(timeout=s.timeout)
+ s.populate_mirrorlist(ug)
if len(s.mirrorlist) < 1:
errorprint("no mirrors to look at for %s, something is broken, skipping" % s.mirrorid)
continue
@@ -312,7 +323,7 @@
continue
- ug = URLGrabber(timeout=s.timeout)
+
canon = MirrorContainer(s.canonical, ug, s.archlist, gi)
if len(canon.timestamps.keys()) < len(s.archlist):
# if we can't get info for all arches for the canonical mirror, exit
@@ -323,7 +334,7 @@
# debug only - just printing out info
for arch in s.archlist:
if canon.timestamps.has_key(arch):
- print ' %s: %s' % (arch, canon.timestamps[arch])
+ print '%s - %s: %s' % (s.mirrorid, arch, canon.timestamps[arch])
# get the info for all the mirrors
@@ -350,9 +361,9 @@
if __name__ == '__main__':
if len(sys.argv) < 2:
- conf_fn = '/etc/check-mirrors.conf'
+ conf_fn = CONFIG
else:
- conf_fn = 'sys.argv[1]'
+ conf_fn = sys.argv[1]
main(conf_fn)
Index: return-mirrorlist.conf
===================================================================
RCS file: /cvs/fedora/check-mirrors/return-mirrorlist.conf,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- return-mirrorlist.conf 10 Jul 2006 21:09:22 -0000 1.1
+++ return-mirrorlist.conf 11 Jul 2006 14:39:47 -0000 1.2
@@ -1,2 +1,3 @@
[core-5]
path=/tmp/foopath
+
More information about the fedora-extras-commits
mailing list