X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fdakdb%2Fupdate4.py;h=a6456bea8095c7dd557f0a92854fa1ea5df42cb5;hb=772655d608069f12e400e0d6c7b7fac76eb98083;hp=487b4792d94d0b709e5a6944177c42612032fa95;hpb=8d5c033bb1cc903c5ce7dc87b4122ea441fa28a3;p=dak.git diff --git a/dak/dakdb/update4.py b/dak/dakdb/update4.py old mode 100755 new mode 100644 index 487b4792..a6456bea --- a/dak/dakdb/update4.py +++ b/dak/dakdb/update4.py @@ -1,12 +1,10 @@ #!/usr/bin/env python - """ -Database Update Script - Get suite_architectures table use sane values +Get suite_architectures table use sane values @contact: Debian FTP Master @copyright: 2009 Joerg Jaspert @license: GNU General Public License version 2 or later - """ # This program is free software; you can redistribute it and/or modify @@ -27,17 +25,18 @@ Database Update Script - Get suite_architectures table use sane values import psycopg2 from daklib.dak_exceptions import DBUpdateError +from daklib.utils import get_conf ################################################################################ suites = {} #: Cache of existing suites archs = {} #: Cache of existing architectures - def do_update(self): """ Execute the DB update """ print "Lets make suite_architecture table use sane values" + Cnf = get_conf() query = "INSERT into suite_architectures (suite, architecture) VALUES (%s, %s)" #: Update query try: @@ -54,15 +53,17 @@ def do_update(self): for suite in s: suites[suite[1]]=suite[0] - for suite in Cnf.SubTree("Suite").List(): + for suite in Cnf.subtree("Suite").list(): print "Processing suite %s" % (suite) - architectures = Cnf.SubTree("Suite::" + suite).ValueList("Architectures") + architectures = Cnf.subtree("Suite::" + suite).value_list("Architectures") suite = suite.lower() for arch in architectures: - c.execute(query, suites[suite], archs[arch]) + c.execute(query, [suites[suite], archs[arch]]) + + c.execute("UPDATE config SET value = '4' WHERE name = 'db_revision'") self.db.commit() - except psycopg2.ProgrammingError, msg: + except psycopg2.ProgrammingError as msg: self.db.rollback() - raise DBUpdateError, "Unable to apply sanity to suite_architecture table, rollback issued. Error message : %s" % (str(msg)) + raise DBUpdateError("Unable to apply sanity to suite_architecture table, rollback issued. Error message : %s" % (str(msg)))