check-mirrors check-mirrors.py,1.6,1.7
Seth Vidal (skvidal)
fedora-extras-commits at redhat.com
Tue Jul 11 20:17:26 UTC 2006
Author: skvidal
Update of /cvs/fedora/check-mirrors
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv17458
Modified Files:
check-mirrors.py
Log Message:
clean up old country-specific files when we make lists
Index: check-mirrors.py
===================================================================
RCS file: /cvs/fedora/check-mirrors/check-mirrors.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- check-mirrors.py 11 Jul 2006 15:57:41 -0000 1.6
+++ check-mirrors.py 11 Jul 2006 20:17:23 -0000 1.7
@@ -25,12 +25,8 @@
# - have it accept an option which specifies a section in the config file
# to operate on - rather than doing all of them.
-#FIXME
-# when writing out the new country-specific files - if a country no longer
-# has any valid mirrors then that country-specific file will still exist
-# something needs to happen clean up the old/invalid country files
-debug = True
+debug = False
__revision__ = '$Id$'
CONFIG = '/etc/check-mirrors.conf'
@@ -46,6 +42,7 @@
import ConfigParser
import socket
import urlparse
+import glob
from urlgrabber.grabber import URLGrabber
from urlgrabber.grabber import URLGrabError
@@ -345,7 +342,10 @@
m = MirrorContainer(url, ug, s.archlist, gi)
if m:
mirrors.append(m)
-
+ new_file_list = []
+ filematch = '%s/%s*' % (s.outputpath, s.mirrorid)
+ old_file_list = glob.glob(filematch)
+
# print them out per-arch and per-country
for arch in s.archlist:
glob_urls = []
@@ -361,18 +361,27 @@
country_specific[m.country].append(m.url)
- glob = '%s/%s-global-%s.txt' % (s.outputpath, s.mirrorid, arch)
- glob_fo = open(glob, 'w')
+ global_file = '%s/%s-global-%s.txt' % (s.outputpath, s.mirrorid, arch)
+ glob_fo = open(global_file, 'w')
for url in glob_urls:
glob_fo.write('%s\n' % url)
glob_fo.close()
-
+ new_file_list.append(global_file)
+
for code in country_specific.keys():
- country = '%s/%s-%s-%s.txt' % (s.outputpath, s.mirrorid, code, arch)
- country_fo = open(country, 'w')
+ country_file = '%s/%s-%s-%s.txt' % (s.outputpath, s.mirrorid, code, arch)
+ country_fo = open(country_file, 'w')
for url in country_specific[code]:
country_fo.write('%s\n' % url)
country_fo.close()
+ new_file_list.append(country_file)
+
+ # clean up
+ for fn in old_file_list:
+ if not fn in new_file_list:
+ if debug: print "removing old file %s" % fn
+ os.unlink(fn)
+
More information about the fedora-extras-commits
mailing list