]> git.decadent.org.uk Git - dak.git/blob - dak/dakdb/update44.py
Convert exception handling to Python3 syntax.
[dak.git] / dak / dakdb / update44.py
1 #!/usr/bin/env python
2 # coding=utf8
3
4 """
5 Remove old contents tables that are no longer needed by the current
6 implementation.
7
8 @contact: Debian FTP Master <ftpmaster@debian.org>
9 @copyright: 2011 Torsten Werner <twerner@debian.org>
10 @license: GNU General Public License version 2 or later
11 """
12
13 # This program is free software; you can redistribute it and/or modify
14 # it under the terms of the GNU General Public License as published by
15 # the Free Software Foundation; either version 2 of the License, or
16 # (at your option) any later version.
17
18 # This program is distributed in the hope that it will be useful,
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21 # GNU General Public License for more details.
22
23 # You should have received a copy of the GNU General Public License
24 # along with this program; if not, write to the Free Software
25 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26
27 ################################################################################
28
29 import psycopg2
30 from daklib.dak_exceptions import DBUpdateError
31 from socket import gethostname;
32
33 ################################################################################
34 def do_update(self):
35     """
36     Remove old contents tables that are no longer needed by the current
37     implementation.
38     """
39     print __doc__
40     try:
41         c = self.db.cursor()
42
43         # remove useless type casts
44         for table in ('pending_bin_contents', 'deb_contents', 'udeb_contents'):
45             c.execute("DROP TABLE %s" % table)
46
47         c.execute("UPDATE config SET value = '44' WHERE name = 'db_revision'")
48         self.db.commit()
49
50     except psycopg2.ProgrammingError as msg:
51         self.db.rollback()
52         raise DBUpdateError, 'Unable to apply sick update 44, rollback issued. Error message : %s' % (str(msg))