/[collab-qa]/udd/udd/testing_migrations_gatherer.py
ViewVC logotype

Contents of /udd/udd/testing_migrations_gatherer.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 972 - (show annotations) (download) (as text)
Thu Jul 31 15:38:29 2008 UTC (4 years, 9 months ago) by neronus-guest
Original Path: udd/src/udd/testing_migrations_gatherer.py
File MIME type: text/x-python
File size: 1937 byte(s)
delete existing entries
1 # Last-Modified: <Thu Jul 31 15:40:12 2008>
2
3 # This file is a part of the Ultimate Debian Database Project
4
5 from gatherer import gatherer
6 from aux import ConfigException, quote
7 from time import strptime
8
9 ZERO_DATE = '0000-01-01'
10
11 def get_gatherer(config, connection):
12 return testing_migrations_gatherer(config, connection)
13
14
15 class testing_migrations_gatherer(gatherer):
16 """This class imports testing migrations data into the database.
17
18 For the files, see http://qa.debian.org/~lucas/testing-status.raw"""
19 def __init__(self, connection, config):
20 gatherer.__init__(self, connection, config)
21
22 def run(self, source):
23 if not source in self.config:
24 raise ConfigException('Source %s was not specified' % source)
25
26 src_cfg = self.config[source]
27
28 if not 'path' in src_cfg:
29 raise ConfigException('path not specified for source %s' % source)
30
31 c = self.connection.cursor()
32
33 c.execute("DELETE FROM migrations")
34
35 c.execute("PREPARE mig_insert AS INSERT INTO migrations VALUES ($1, $2, $3, $4, $5, $6, $7, $8)")
36
37 f = open(src_cfg['path'])
38 for line in f.readlines():
39 (package, in_testing, testing_version, in_unstable, unstable_version, sync, sync_version, first_seen) = line.split()
40 for field in ('in_testing', 'in_unstable', 'sync', 'first_seen'):
41 is_null = False
42 exec "is_null = %s == ZERO_DATE" % field
43 if is_null:
44 exec "%s = 'NULL'" % field
45 else:
46 exec "%s = quote(%s)" % (field, field)
47
48 for field in ('package', 'testing_version', 'unstable_version', 'sync_version'):
49 is_null = False
50 exec "is_null = %s == '-'" % field
51 if is_null:
52 exec "%s = 'NULL'" % field
53 else:
54 exec "%s = quote(%s)" % (field, field)
55
56 c.execute("EXECUTE mig_insert(%s, %s, %s, %s, %s, %s, %s, %s)" \
57 % (package, in_testing, testing_version, in_unstable, unstable_version, sync, sync_version, first_seen))
58
59 c.execute("DEALLOCATE mig_insert")
60

  ViewVC Help
Powered by ViewVC 1.1.5