[Collab-qa-commits] r1106 - in udd/src: . schema udd
neronus-guest at alioth.debian.org
neronus-guest at alioth.debian.org
Sun Aug 17 12:24:24 UTC 2008
Author: neronus-guest
Date: 2008-08-17 12:24:24 +0000 (Sun, 17 Aug 2008)
New Revision: 1106
Modified:
udd/src/schema/bugs
udd/src/udd-dispatch.py
udd/src/udd/bugs_gatherer.pl
udd/src/udd/carnivore_gatherer.py
udd/src/udd/gatherer.py
udd/src/udd/packages_gatherer.py
udd/src/udd/popcon_gatherer.py
udd/src/udd/sources_gatherer.py
udd/src/udd/src_and_pkg_gatherer.py
udd/src/udd/upload_history_gatherer.py
Log:
Added command 'tables' which returns the tables used by the given source
Modified: udd/src/schema/bugs
===================================================================
--- udd/src/schema/bugs 2008-08-17 11:31:33 UTC (rev 1105)
+++ udd/src/schema/bugs 2008-08-17 12:24:24 UTC (rev 1106)
@@ -38,7 +38,7 @@
PRIMARY KEY(id, version));
CREATE TABLE %(archived-table)s_tags
- (id int REFERENCES %(archived-table)s, tag text, PRIMARY KEY (id, tag));
+ (id int, tag text, PRIMARY KEY (id, tag));
CREATE VIEW bugs_rt_affects_stable AS
SELECT id, package, source FROM %(table)s
@@ -77,7 +77,7 @@
OR source IN (SELECT DISTINCT package FROM %(sources-table)s WHERE release = 'lenny'));
CREATE TABLE %(usertags-table)s
- (email text, tag text, id int);
+ (email text, tag text, id int REFERENCES %(table)s);
GRANT SELECT ON %(table)s TO PUBLIC;
GRANT SELECT ON %(table)s_merged_with TO PUBLIC;
Modified: udd/src/udd/bugs_gatherer.pl
===================================================================
--- udd/src/udd/bugs_gatherer.pl 2008-08-17 11:31:33 UTC (rev 1105)
+++ udd/src/udd/bugs_gatherer.pl 2008-08-17 12:24:24 UTC (rev 1106)
@@ -1,5 +1,5 @@
#!/usr/bin/perl -w
-# Last-Modified: <Mon Aug 11 18:17:46 2008>
+# Last-Modified: <Sun Aug 17 12:20:19 2008>
use strict;
use warnings;
@@ -102,6 +102,19 @@
$dbh->prepare($command)->execute() or die $!;
}
+sub tables {
+ my ($config, $source, $dbh) = @_;
+ my @ret = ();
+ foreach my $prefix ($config->{$source}->{table}, $config->{$source}->{'archived-table'}) {
+ foreach my $postfix (qw{_merged_with _found_in _fixed_in _tags}, '') {
+ push @ret, "$prefix$postfix";
+ }
+ }
+ unshift @ret, $config->{$source}->{'usertags-table'};
+ return @ret;
+}
+
+
sub drop {
my ($config, $source, $dbh) = @_;
map {
@@ -109,12 +122,10 @@
}
qw{bugs_rt_affects_stable bugs_rt_affects_testing_and_unstable bugs_rt_affects_unstable bugs_rt_affects_testing};
- foreach my $prefix ($config->{$source}->{table}, $config->{$source}->{'archived-table'}) {
- foreach my $postfix ('', qw{_merged_with _found_in _fixed_in _tags}) {
- $dbh->prepare("DROP TABLE $prefix$postfix")->execute() or die $!;
- }
+ foreach my $table (tables($config, $source, $dbh)) {
+ print "$table\n";
+ $dbh->prepare("DROP TABLE $table")->execute() or die $!;
}
- $dbh->prepare("DROP TABLE " . $config->{$source}->{'usertags-table'})->execute() or die $!;
}
sub run_usertags {
@@ -338,6 +349,8 @@
setup($config, $source, $dbh);
} elsif ($command eq 'drop') {
drop($config, $source, $dbh);
+ } elsif ($command eq 'tables') {
+ print join "\n", tables($config, $source, $dbh)
} else {
print STDERR "<command> has to be one of run, drop and setup\n";
exit(1)
Modified: udd/src/udd/carnivore_gatherer.py
===================================================================
--- udd/src/udd/carnivore_gatherer.py 2008-08-17 11:31:33 UTC (rev 1105)
+++ udd/src/udd/carnivore_gatherer.py 2008-08-17 12:24:24 UTC (rev 1106)
@@ -30,10 +30,12 @@
gatherer.__init__(self, connection, config, source)
self.assert_my_config('path', 'emails-table', 'names-table', 'keys-table', 'login-table')
- def drop(self):
+ def tables(self):
cur = self.cursor()
+ ret = []
for table in ['emails', 'names', 'keys', 'login']:
- cur.execute("DROP TABLE %s" % self.my_config["%s-table" % table])
+ ret.append(self.my_config["%s-table" % table])
+ return ret
def run(self):
my_config = self.my_config
Modified: udd/src/udd/gatherer.py
===================================================================
--- udd/src/udd/gatherer.py 2008-08-17 11:31:33 UTC (rev 1105)
+++ udd/src/udd/gatherer.py 2008-08-17 12:24:24 UTC (rev 1106)
@@ -37,9 +37,14 @@
raise Exception("'schema-dir' not specified")
def drop(self):
+ for table in self.tables():
+ self.cursor().execute("DROP TABLE " + table)
+
+ def tables(self):
if 'table' in self.my_config:
- self.cursor().execute("DROP TABLE " + self.my_config['table'])
+ return [self.my_config['table']]
+
def eval_sql_file(self, path, d = None):
"""Load the SQL code from the file specified by <path>. Use pythons string
formating for the dictionary <d> if it is not None
Modified: udd/src/udd/packages_gatherer.py
===================================================================
--- udd/src/udd/packages_gatherer.py 2008-08-17 11:31:33 UTC (rev 1105)
+++ udd/src/udd/packages_gatherer.py 2008-08-17 12:24:24 UTC (rev 1106)
@@ -1,5 +1,5 @@
# /usr/bin/env python
-# Last-Modified: <Sun Aug 17 11:29:52 2008>
+# Last-Modified: <Sun Aug 17 12:24:40 2008>
# This file is a part of the Ultimate Debian Database project
import debian_bundle.deb822
@@ -135,8 +135,10 @@
else:
raise Exception("'schema-dir' not specified")
- def drop(self):
- self.cursor().execute("DROP TABLE " + self.my_config['packages-table'])
+ def tables(self):
+ return [
+ self.my_config['packages-table'],
+ self.my_config['packages-table'] + '_summary']
def run(self):
src_cfg = self.my_config
Modified: udd/src/udd/popcon_gatherer.py
===================================================================
--- udd/src/udd/popcon_gatherer.py 2008-08-17 11:31:33 UTC (rev 1105)
+++ udd/src/udd/popcon_gatherer.py 2008-08-17 12:24:24 UTC (rev 1106)
@@ -20,10 +20,11 @@
self.assert_my_config('path', 'table', 'packages-table', 'schema')
- def drop(self):
- cur = self.cursor()
+ def tables(self):
+ ret = []
for sub in ('', '_src', '_src_average'):
- cur.execute("DROP TABLE %s%s" % (self.my_config['table'], sub))
+ ret.append(self.my_config['table'] + sub)
+ return ret
def run(self):
my_config = self.my_config
Modified: udd/src/udd/sources_gatherer.py
===================================================================
--- udd/src/udd/sources_gatherer.py 2008-08-17 11:31:33 UTC (rev 1105)
+++ udd/src/udd/sources_gatherer.py 2008-08-17 12:24:24 UTC (rev 1106)
@@ -1,5 +1,5 @@
#/usr/bin/env python
-# Last-Modified: <Sun Aug 10 12:11:44 2008>
+# Last-Modified: <Sun Aug 17 12:07:25 2008>
# This file is a part of the Ultimate Debian Database project
import debian_bundle.deb822
@@ -97,8 +97,8 @@
"""
cur.execute(query, d)
- def drop(self):
- self.cursor().execute("DROP TABLE " + self.my_config['sources-table'])
+ def tables(self):
+ return [self.my_config['sources-table']]
def run(self):
src_cfg = self.my_config
Modified: udd/src/udd/src_and_pkg_gatherer.py
===================================================================
--- udd/src/udd/src_and_pkg_gatherer.py 2008-08-17 11:31:33 UTC (rev 1105)
+++ udd/src/udd/src_and_pkg_gatherer.py 2008-08-17 12:24:24 UTC (rev 1106)
@@ -23,3 +23,6 @@
def setup(self):
self.src.setup()
self.pkg.setup()
+
+ def tables(self):
+ return self.src.tables() + self.pkg.tables()
Modified: udd/src/udd/upload_history_gatherer.py
===================================================================
--- udd/src/udd/upload_history_gatherer.py 2008-08-17 11:31:33 UTC (rev 1105)
+++ udd/src/udd/upload_history_gatherer.py 2008-08-17 12:24:24 UTC (rev 1106)
@@ -1,4 +1,4 @@
-# Last-Modified: <Thu Aug 14 12:06:50 2008>
+# Last-Modified: <Sun Aug 17 12:13:02 2008>
# This file is part of the Ultimate Debian Database Project
from gatherer import gatherer
@@ -17,11 +17,11 @@
if not 'path' in self.my_config:
raise aux.ConfigException('path not specified for source ' + source)
- def drop(self):
- cur = self.cursor()
- cur.execute("DROP TABLE %s" % self.my_config['table'])
- cur.execute("DROP TABLE %s" % self.my_config['table'] + '_architecture')
- cur.execute("DROP TABLE %s" % self.my_config['table'] + '_closes')
+ def tables(self):
+ return [
+ self.my_config['table'] + '_architecture',
+ self.my_config['table'] + '_closes',
+ self.my_config['table']]
def run(self):
Modified: udd/src/udd-dispatch.py
===================================================================
--- udd/src/udd-dispatch.py 2008-08-17 11:31:33 UTC (rev 1105)
+++ udd/src/udd-dispatch.py 2008-08-17 12:24:24 UTC (rev 1106)
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Last-Modified: <Tue Aug 12 16:20:44 2008>
+# Last-Modified: <Sun Aug 17 12:03:34 2008>
"""Dispatch udd gatherers
@@ -20,8 +20,8 @@
sys.exit(1)
command = sys.argv[2]
- if command not in ('run', 'setup', 'drop'):
- sys.stderr.write("command has to be one of 'run', 'setup', 'drop'\n")
+ if command not in ('run', 'setup', 'drop', 'tables'):
+ sys.stderr.write("command has to be one of 'run', 'setup', 'drop' and 'tables'\n")
sys.exit(1)
# Check the configuration
@@ -53,7 +53,11 @@
elif src_command == "module":
exec("import " + rest)
exec "gatherer = " + rest + ".get_gatherer(connection, config, src)"
- exec "gatherer.%s()" % command
+ if command == 'tables':
+ exec "tables = gatherer.%s()" % command
+ print "\n".join(tables)
+ else:
+ exec "gatherer.%s()" % command
if 'timestamp-folder' in config['general']:
f = open(os.path.join(config['general']['timestamp-folder'], src+".dispatch"), "w")
f.write(asctime())
@@ -61,5 +65,6 @@
except:
udd.aux.unlock(config, src)
raise
+ udd.aux.unlock(config, src)
connection.commit()
More information about the Collab-qa-commits
mailing list