/[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 1531 - (show annotations) (download) (as text)
Thu Jul 23 14:05:39 2009 UTC (3 years, 9 months ago) by lucas
File MIME type: text/x-python
File size: 1983 byte(s)
add ANALYZE at the end of all importers to teach pgsql some stats about the data we just imported
1 # Last-Modified: <Sun Aug 10 12:16: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, source):
12 return testing_migrations_gatherer(config, connection, source)
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, source):
20 gatherer.__init__(self, connection, config, source)
21 self.assert_my_config('path')
22
23 def run(self):
24 src_cfg = self.my_config
25
26 c = self.connection.cursor()
27
28 c.execute("DELETE FROM migrations")
29
30 c.execute("PREPARE mig_insert AS INSERT INTO migrations (source, in_testing, testing_version, in_unstable, unstable_version, sync, sync_version, first_seen) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)")
31
32 f = open(src_cfg['path'])
33 for line in f:
34 (package, in_testing, testing_version, in_unstable, unstable_version, sync, sync_version, first_seen) = line.split()
35 for field in ('in_testing', 'in_unstable', 'sync', 'first_seen'):
36 is_null = False
37 exec "is_null = %s == ZERO_DATE" % field
38 if is_null:
39 exec "%s = 'NULL'" % field
40 else:
41 exec "%s = quote(%s)" % (field, field)
42
43 for field in ('package', 'testing_version', 'unstable_version', 'sync_version'):
44 is_null = False
45 exec "is_null = %s == '-'" % field
46 if is_null:
47 exec "%s = 'NULL'" % field
48 else:
49 exec "%s = quote(%s)" % (field, field)
50
51 c.execute("EXECUTE mig_insert(%s, %s, %s, %s, %s, %s, %s, %s)" \
52 % (package, in_testing, testing_version, in_unstable, unstable_version, sync, sync_version, first_seen))
53
54 c.execute("DEALLOCATE mig_insert")
55 c.execute("ANALYZE migrations")
56

  ViewVC Help
Powered by ViewVC 1.1.5