[Collab-qa-commits] r916 - in udd/src: . udd
neronus-guest at alioth.debian.org
neronus-guest at alioth.debian.org
Sat Jul 12 17:32:40 UTC 2008
Author: neronus-guest
Date: 2008-07-12 17:32:38 +0000 (Sat, 12 Jul 2008)
New Revision: 916
Added:
udd/src/udd/testing_migrations_gatherer.py
Modified:
udd/src/db_manager.py
udd/src/setup-db.sql
udd/src/test.yaml
udd/src/udd-update.py
Log:
Added table and script for testing migrations
Modified: udd/src/db_manager.py
===================================================================
--- udd/src/db_manager.py 2008-07-12 10:05:13 UTC (rev 915)
+++ udd/src/db_manager.py 2008-07-12 17:32:38 UTC (rev 916)
@@ -6,7 +6,7 @@
"""This scripts sets up and deletes the tables of the database"""
-TABLES = ('sources', 'packages', 'popcon')
+TABLES = ('sources', 'packages', 'popcon', 'migrations')
VIEWS = ('popcon_average', 'popcon_max')
def print_help():
Modified: udd/src/setup-db.sql
===================================================================
--- udd/src/setup-db.sql 2008-07-12 10:05:13 UTC (rev 915)
+++ udd/src/setup-db.sql 2008-07-12 17:32:38 UTC (rev 916)
@@ -17,6 +17,10 @@
text, X_Vcs_Svn text,
UNIQUE (package, version, distribution, release, component));
+CREATE TABLE migrations
+ (package text, in_testing date, testing_version text, in_unstable date, unstable_version text, sync date, sync_version text, first_seen date,
+ UNIQUE (package));
+
CREATE TABLE popcon
(Name text, vote int, olde int, recent int, nofiles int, distribution text, UNIQUE (Name, distribution));
Modified: udd/src/test.yaml
===================================================================
--- udd/src/test.yaml 2008-07-12 10:05:13 UTC (rev 915)
+++ udd/src/test.yaml 2008-07-12 17:32:38 UTC (rev 916)
@@ -1,5 +1,5 @@
general:
- dbname: udd-test
+ dbname: udd
types:
sources: module udd.sources_gatherer
packages: module udd.packages_gatherer
@@ -7,6 +7,7 @@
delete: exec python db_manager.py
src-pkg: module udd.src_and_pkg_gatherer
popcon: module udd.popcon_gatherer
+ testing-migrations: module udd.testing_migrations_gatherer
#src-pkg: python sources_gatherer.py
debug: 1
@@ -124,4 +125,7 @@
update-command: wget -O /tmp/ubuntu-popcon-results.txt.gz http://popcon.ubuntu.com/all-popcon-results.txt.gz
distribution: ubuntu
-
+testing-migrations:
+ type: testing-migrations
+ path: /tmp/migrations
+ update-command: echo "test"; wget -O /tmp/migrations 'http://qa.debian.org/~lucas/testing-status.raw'
Added: udd/src/udd/testing_migrations_gatherer.py
===================================================================
--- udd/src/udd/testing_migrations_gatherer.py (rev 0)
+++ udd/src/udd/testing_migrations_gatherer.py 2008-07-12 17:32:38 UTC (rev 916)
@@ -0,0 +1,55 @@
+# Last-Modified: <Sat Jul 12 17:31:22 2008>
+
+from gatherer import gatherer
+from aux import ConfigException, quote
+from time import strptime
+
+ZERO_DATE = '0000-01-01'
+
+def get_gatherer(config, connection):
+ return testing_migrations_gatherer(config, connection)
+
+
+class testing_migrations_gatherer(gatherer):
+ def __init__(self, connection, config):
+ gatherer.__init__(self, connection, config)
+
+ def run(self, source):
+ if not source in self.config:
+ raise ConfigException('Source %s was not specified' % source)
+
+ src_cfg = self.config[source]
+
+ if not 'path' in src_cfg:
+ raise ConfigException('path not specified for source %s' % source)
+
+ c = self.connection.cursor()
+
+ c.execute("PREPARE mig_insert AS INSERT INTO migrations VALUES ($1, $2, $3, $4, $5, $6, $7, $8)")
+
+ f = open(src_cfg['path'])
+ for line in f.readlines():
+ (package, in_testing, testing_version, in_unstable, unstable_version, sync, sync_version, first_seen) = line.split()
+ for field in ('in_testing', 'in_unstable', 'sync', 'first_seen'):
+ is_null = False
+ exec "is_null = %s == ZERO_DATE" % field
+ if is_null:
+ exec "%s = 'NULL'" % field
+ #else:
+ #exec field + " = strptime('%Y-%m-%d', " + field + ")"
+ else:
+ exec "%s = quote(%s)" % (field, field)
+
+ for field in ('package', 'testing_version', 'unstable_version', 'sync_version'):
+ is_null = False
+ exec "is_null = %s == '-'" % field
+ if is_null:
+ exec "%s = 'NULL'" % field
+ else:
+ exec "%s = quote(%s)" % (field, field)
+
+ c.execute("EXECUTE mig_insert(%s, %s, %s, %s, %s, %s, %s, %s)" \
+ % (package, in_testing, testing_version, in_unstable, unstable_version, sync, sync_version, first_seen))
+
+ c.execute("DEALLOCATE mig_insert")
+
Modified: udd/src/udd-update.py
===================================================================
--- udd/src/udd-update.py 2008-07-12 10:05:13 UTC (rev 915)
+++ udd/src/udd-update.py 2008-07-12 17:32:38 UTC (rev 916)
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Last-Modified: <Sun Jun 29 11:03:13 2008>
+# Last-Modified: <Sat Jul 12 16:44:23 2008>
"""
This script executes the update statements for selected sources
@@ -21,7 +21,7 @@
for src in sys.argv[2:]:
if not src in config:
- raise aux.ConfigException("%s is not specified in %s" % (src, sys.argv[1]))
+ raise udd.aux.ConfigException("%s is not specified in %s" % (src, sys.argv[1]))
for src in sys.argv[2:]:
src_cfg = config[src]
More information about the Collab-qa-commits
mailing list