[Collab-qa-commits] r903 - in udd/src: . udd

neronus-guest at alioth.debian.org neronus-guest at alioth.debian.org
Sun Jun 29 11:24:35 UTC 2008


Author: neronus-guest
Date: 2008-06-29 11:24:35 +0000 (Sun, 29 Jun 2008)
New Revision: 903

Added:
   udd/src/udd-update.py
Modified:
   udd/src/db_manager.py
   udd/src/setup-db.sql
   udd/src/test.yaml
   udd/src/udd/popcon_gatherer.py
Log:
Added possibility to update sources via configuration entry 'update-command', which
then is read from udd-update

Added ubuntu popcon data

modified popcon table to include distribtution


Modified: udd/src/db_manager.py
===================================================================
--- udd/src/db_manager.py	2008-06-29 10:56:23 UTC (rev 902)
+++ udd/src/db_manager.py	2008-06-29 11:24:35 UTC (rev 903)
@@ -1,13 +1,13 @@
 #!/usr/bin/python
 
-import aux
+import udd.aux
 import sys
 import os
 
 """This scripts sets up and deletes the tables of the database"""
 
 TABLES = ('sources', 'packages', 'popcon')
-VIEWS = ('popcon_average', 'popcon_sum')
+VIEWS = ('popcon_average', 'popcon_max')
 
 def print_help():
   print "Usage: %s <config> <delete|setup>" % sys.argv[0]
@@ -24,7 +24,7 @@
 
 def setup(conn, config):
   if 'script' not in config['setup']:
-    raise aux.ConfigException('Script not specified in setup')
+    raise udd.aux.ConfigException('Script not specified in setup')
 
   os.system("psql %s < %s" % (config['general']['dbname'],
                               config['setup']['script']))
@@ -37,8 +37,8 @@
   command = sys.argv[2]
   config_path = sys.argv[1]
 
-  config = aux.load_config(open(config_path).read())
-  conn = aux.open_connection(config)
+  config = udd.aux.load_config(open(config_path).read())
+  conn = udd.aux.open_connection(config)
 
   if command == 'setup':
     setup(conn, config)

Modified: udd/src/setup-db.sql
===================================================================
--- udd/src/setup-db.sql	2008-06-29 10:56:23 UTC (rev 902)
+++ udd/src/setup-db.sql	2008-06-29 11:24:35 UTC (rev 903)
@@ -18,7 +18,7 @@
     UNIQUE (package, version, distribution, release, component));
 
 CREATE TABLE popcon
-  (Name text, vote int, olde int, recent int, nofiles int, UNIQUE (Name));
+  (Name text, vote int, olde int, recent int, nofiles int, distribution text, UNIQUE (Name, distribution));
 
 CREATE VIEW popcon_average AS
   SELECT sources.package, avg(vote) AS vote, avg(olde) AS old, avg(recent) AS recent, avg(nofiles) as nofiles

Modified: udd/src/test.yaml
===================================================================
--- udd/src/test.yaml	2008-06-29 10:56:23 UTC (rev 902)
+++ udd/src/test.yaml	2008-06-29 11:24:35 UTC (rev 903)
@@ -93,6 +93,14 @@
     i386, i486, ia64, kfreebsd-amd64, kfreebsd-i386, m68k, mips,
     mipsel, powerpc, ppc64, s390, sparc, all, any]       
 
-popcon:
+debian-popcon:
   type: popcon
   path: /tmp/all-popcon-results.txt.gz
+  update-command: wget -O /tmp/all-popcon-results.txt.gz http://popcon.debian.org/all-popcon-results.txt.gz
+  distribution: debian
+  
+ubuntu-popcon:
+  type: popcon
+  path: /tmp/ubuntu-popcon-results.txt.gz
+  update-command: wget -O /tmp/ubuntu-popcon-results.txt.gz http://popcon.ubuntu.com/all-popcon-results.txt.gz
+  distribution: ubuntu

Modified: udd/src/udd/popcon_gatherer.py
===================================================================
--- udd/src/udd/popcon_gatherer.py	2008-06-29 10:56:23 UTC (rev 902)
+++ udd/src/udd/popcon_gatherer.py	2008-06-29 11:24:35 UTC (rev 903)
@@ -24,18 +24,23 @@
       raise
 
     if not 'path' in my_config:
-      raise aux.ConfigException, "path not configured for source " % source
+      raise aux.ConfigException, "path not configured for source " + source
 
+    if not 'distribution' in my_config:
+      raise aux.ConfigException, "distribution not configured for source " + source
+
     cur = self.cursor()
 
-    cur.execute("PREPARE pop_insert AS INSERT INTO popcon (name, vote, olde, recent, nofiles) VALUES ($1, $2, $3, $4, $5)")
+    cur.execute("PREPARE pop_insert AS INSERT INTO popcon (name, vote, olde, recent, nofiles, distribution) VALUES ($1, $2, $3, $4, $5, '%s')" % my_config['distribution'])
 
     popcon = gzip.open(my_config['path'])
 
+    cur.execute("DELETE FROM popcon WHERE distribution = '%s'" % my_config['distribution'])
+
     for line in popcon.readlines():
       name, data = line.split(None, 1)
       if name == "Submissions:":
-	cur.execute("INSERT INTO popcon (name, vote) VALUES ('_submissions', %s)" % (data))
+	cur.execute("INSERT INTO popcon (name, vote, distribution) VALUES ('_submissions', %s, '%s')" % (data, my_config['distribution']))
       try:
 	(name, vote, old, recent, nofiles) = data.split()
 	cur.execute("EXECUTE pop_insert('%s', %s, %s, %s, %s)" %\

Added: udd/src/udd-update.py
===================================================================
--- udd/src/udd-update.py	                        (rev 0)
+++ udd/src/udd-update.py	2008-06-29 11:24:35 UTC (rev 903)
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+# Last-Modified: <Sun Jun 29 11:03:13 2008>
+
+"""
+This script executes the update statements for selected sources
+"""
+
+import sys
+from os import system
+import udd.aux
+
+def print_help():
+  print 'Usage: ' + sys.argv[0] + " <configuration> <source1> [source2 source3 ...]"
+
+if __name__ == '__main__':
+  if len(sys.argv) < 3:
+    print_help()
+    sys.exit(1)
+
+  config = udd.aux.load_config(open(sys.argv[1]).read())
+
+  for src in sys.argv[2:]:
+    if not src in config:
+      raise aux.ConfigException("%s is not specified in %s" % (src, sys.argv[1]))
+
+  for src in sys.argv[2:]:
+    src_cfg = config[src]
+    if "update-command" in src_cfg:
+      system(src_cfg['update-command'])
+


Property changes on: udd/src/udd-update.py
___________________________________________________________________
Name: svn:executable
   + *




More information about the Collab-qa-commits mailing list