Author: neronus-guest
Date: 2008-08-09 17:52:27 +0000 (Sat, 09 Aug 2008)
New Revision: 1038

Modified:
   udd/src/udd/packages_gatherer.py
   udd/src/udd/popcon_gatherer.py
   udd/src/udd/sources_gatherer.py
Log:
Fixed bugs regarding configuration checking and db api 2 quoting


Modified: udd/src/udd/packages_gatherer.py
===================================================================
--- udd/src/udd/packages_gatherer.py    2008-08-09 16:32:42 UTC (rev 1037)
+++ udd/src/udd/packages_gatherer.py    2008-08-09 17:52:27 UTC (rev 1038)
@@ -1,5 +1,5 @@
 # /usr/bin/env python
-# Last-Modified: <Sat 09 Aug 2008 18:30:18 CEST>
+# Last-Modified: <Sat Aug  9 17:28:45 2008>
 # This file is a part of the Ultimate Debian Database project
 
 import debian_bundle.deb822
@@ -129,7 +129,8 @@
     src_cfg = self.config[source]
 
     for k in ['directory', 'archs', 'release', 'components', 'distribution', 
'packages-table']:
-      raise ConfigException(k + ' not sepcified for source ' + source)
+      if not k in src_cfg:
+       raise ConfigException(k + ' not sepcified for source ' + source)
 
     aux.debug = self.config['general']['debug']
     table = src_cfg['packages-table']

Modified: udd/src/udd/popcon_gatherer.py
===================================================================
--- udd/src/udd/popcon_gatherer.py      2008-08-09 16:32:42 UTC (rev 1037)
+++ udd/src/udd/popcon_gatherer.py      2008-08-09 17:52:27 UTC (rev 1038)
@@ -25,9 +25,9 @@
       raise
 
     for k in ['path', 'table', 'packages-table']:
-      raise ConfigException(k + ' not specified in ' + source)
+      if k not in my_config:
+       raise aux.ConfigException(k + ' not specified in ' + source)
 
-
     table = my_config['table']
     table_src = table + "_src"
     table_src_average = table + "_src_average"
@@ -46,19 +46,26 @@
     ascii_match = re.compile("^[A-Za-z0-9-.+_]+$")
 
     linenr = 0
+    d = {}
     for line in popcon:
       linenr += 1
       name, data = line.split(None, 1)
       if name == "Submissions:":
-       cur.execute("INSERT INTO %s (package, vote) VALUES ('_submissions', 
%s)" % (table, data))
+       d['data'] = int(data)
+       cur.execute("INSERT INTO " + table + " (package, vote) VALUES 
('_submissions', %(data)s)", d)
+       continue
       try:
        (name, vote, old, recent, nofiles) = data.split()
+       d['name'] = name
+       for k in ['vote', 'old', 'recent', 'nofiles']:
+         exec '%s = int(%s)' % (k,k)
+         exec 'd["%s"] = %s' % (k,k)
+       d['insts'] = vote + old + recent + nofiles
        if ascii_match.match(name) == None:
          print "Skipping line %d of file %s as it contains illegal characters: 
%s" % (linenr, my_config['path'], line)
          continue
-       query = "EXECUTE pop_insert('%s', %s, %s, %s, %s, %s)" %\
-           (name, int(vote) + int(old) + int(recent) + int(nofiles), vote, 
old, recent, nofiles)
-       cur.execute(query)
+       query = "EXECUTE pop_insert(%(name)s, %(insts)s, %(vote)s, %(old)s, 
%(recent)s, %(nofiles)s)"
+       cur.execute(query, d)
       except ValueError:
        continue
 
@@ -77,7 +84,7 @@
       GROUP BY packages.source;
       """ % my_config)
     for line in cur.fetchall():
-      cur.execute("EXECUTE pop_insert ('%s', %s, %s, %s, %s, %s)" % line)
+      cur.execute("EXECUTE pop_insert (%s, %s, %s, %s, %s, %s)", line)
     cur.execute("DEALLOCATE pop_insert");
     cur.execute("PREPARE pop_insert AS INSERT INTO %s VALUES ($1, $2, $3, $4, 
$5, $6)" % table_src_average)
     cur.execute("""
@@ -91,7 +98,7 @@
       GROUP BY packages.source;
       """ % my_config)
     for line in cur.fetchall():
-      cur.execute("EXECUTE pop_insert ('%s', %s, %s, %s, %s, %s)" % line)
+      cur.execute("EXECUTE pop_insert (%s, %s, %s, %s, %s, %s)", line)
     cur.execute("DEALLOCATE pop_insert");
 
 if __name__ == '__main__':

Modified: udd/src/udd/sources_gatherer.py
===================================================================
--- udd/src/udd/sources_gatherer.py     2008-08-09 16:32:42 UTC (rev 1037)
+++ udd/src/udd/sources_gatherer.py     2008-08-09 17:52:27 UTC (rev 1038)
@@ -1,5 +1,5 @@
 #/usr/bin/env python
-# Last-Modified: <Sat 09 Aug 2008 18:31:11 CEST>
+# Last-Modified: <Sat Aug  9 17:28:33 2008>
 # This file is a part of the Ultimate Debian Database project
 
 import debian_bundle.deb822
@@ -102,7 +102,8 @@
     src_cfg = self.config[source]
 
     for k in ['directory', 'components', 'distribution', 'release', 
'sources-table']:
-      raise ConfigException(k + ' not specified for source ' + source)
+      if not k in src_cfg:
+       raise ConfigException(k + ' not specified for source ' + source)
     
     table = src_cfg['sources-table']
        


_______________________________________________
Collab-qa-commits mailing list
[email protected]
http://lists.alioth.debian.org/mailman/listinfo/collab-qa-commits

Reply via email to