check-mirrors check-mirrors.py,1.21,1.22

Michael Patrick McGrath (mmcgrath) fedora-extras-commits at redhat.com
Wed Aug 2 16:12:43 UTC 2006


Author: mmcgrath

Update of /cvs/fedora/check-mirrors
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv23958

Modified Files:
	check-mirrors.py 
Log Message:
Added support for a global section for the db settings



Index: check-mirrors.py
===================================================================
RCS file: /cvs/fedora/check-mirrors/check-mirrors.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- check-mirrors.py	2 Aug 2006 14:50:55 -0000	1.21
+++ check-mirrors.py	2 Aug 2006 16:12:41 -0000	1.22
@@ -24,6 +24,7 @@
 # - have it accept an option which specifies a section in the config file
 #    to operate on - rather than doing all of them.
 # - remove deleted mirrors from the database
+# - pull mirrors from the database instead of fedora.redhat.com ?
 
 
 debug = True
@@ -168,42 +169,6 @@
             result = True
     return result
 
-#def update_db(repo, arch, country, url, failure, dbconn, dbcursor):
-#    updated = 0
-#    if not dbcursor:
-#        errorprint('sqlite database check failed')
-#
-#    if failure:
-#        query = "update mirrors set failures=(select failures from mirrors where url='%s')+1 where url='%s' and repo='%s' and arch='%s';" % (url, url, repo, arch)
-#    else:
-#    try:
-#        if debug:
-#            print "Executing: %s" % query
-#        dbcursor.execute(query)
-#        updated = dbcursor.rowcount
-#        dbconn.commit()
-#    except sqlite.Error, errmsg:
-#        errorprint('DBerr: %s ' % errmsg)
-#        errorprint(query)
-#    if not updated:
-#        try:
-#            if failure:
-#                lastgoodsql='0'
-#            else:
-#                lastgoodsql="DATETIME('now')"
-#            query = "insert into mirrors (repo, arch, country, url, failures, lastgood) VALUES ('%s', '%s', '%s', '%s', '%s', %s);" % (repo, arch, country, url, failure, lastgoodsql)
-#            if debug:
-#                print "Executing: %s" % query
-#            dbcursor.execute(query)
-#            updated = dbcursor.rowcount
-#            dbconn.commit()
-#        except sqlite.Error, errmsg:
-#            errorprint('DBErr: %s' % errmsg)
-#            errorprint(query)
-#            return None
-#    return updated
-
-
 class RepoData:
     """represents anything beneath a <data> tag"""
     def __init__(self, elem):
@@ -371,17 +336,31 @@
     sections = []
     conf = ConfigParser.ConfigParser()
     conf.read(cfg)
-
+    
     for section in conf.sections():
         item = MirrorListInfo()
+        broken = False
+
+
+        if section.lower() == 'global':
+            item.mirrorid = '%s' % section
+            if conf.has_option(section, 'db'):
+                item.db = conf.get(section, 'db')
+            else:
+                errorprint('missing db filename')
+                broken = True
+
+            if broken:
+                errorprint("Broooooooooooooken config, in section %s, bailing" % section)
+                sys.exit(1)
+            sections.append(item)
+            continue
 
         if conf.has_option(section, 'file_prefix'):
             item.mirrorid = conf.get(section, 'file_prefix')
         else:
             item.mirrorid = '%s' % section
 
-        broken = False
-
         if conf.has_option(section, 'inputfile'):
             item.inputfile = conf.get(section, 'inputfile')
         else:
@@ -400,12 +379,6 @@
             errorprint('missing canonical url')
             broken = True
 
-        if conf.has_option(section, 'db'):
-            item.db = conf.get(section, 'db')
-        else:
-            errorprint('missing db filename')
-            broken = True
-
         if broken:
             errorprint("Broooooooooooooken config, in section %s, bailing" % section)
             sys.exit(1)
@@ -426,7 +399,6 @@
 
     return sections
 
-
 def main(cfg_file):
     if not os.path.exists(cfg_file):
         errorprint("config file %s does not exist" % cfg_file)
@@ -439,14 +411,15 @@
     for s in sections:
         mirrors = []
 
+        if s.mirrorid == 'global':
+            DB = RepoDB(s.db)
+            continue
+
         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
-
-#        dbconn, dbcursor = check_and_make_db(s.db)
-        DB = RepoDB(s.db)
         
         if not check_and_make_dir(s.outputpath):
             errorprint('Error creating output path %s for %s' % (s.outputpath, s.mirrorid))




More information about the fedora-extras-commits mailing list