[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[dak/master 3/3] Make suite.announce an ARRAY



Signed-off-by: Mark Hymers <mhy@debian.org>
---
 dak/dakdb/update65.py |   51 +++++++++++++++++++++++++++++++++++++++++++++++++
 dak/update_db.py      |    2 +-
 daklib/queue.py       |   14 ++++++------
 3 files changed, 59 insertions(+), 8 deletions(-)
 create mode 100755 dak/dakdb/update65.py

diff --git a/dak/dakdb/update65.py b/dak/dakdb/update65.py
new file mode 100755
index 0000000..8dd83a1
--- /dev/null
+++ b/dak/dakdb/update65.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+# coding=utf8
+
+"""
+Make announce field an array
+
+@contact: Debian FTP Master <ftpmaster@debian.org>
+@copyright: 2011 Mark Hymers <mhy@debian.org>
+@license: GNU General Public License version 2 or later
+"""
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+################################################################################
+
+import psycopg2
+from daklib.dak_exceptions import DBUpdateError
+from daklib.config import Config
+
+################################################################################
+def do_update(self):
+    """
+    Make announce field an array
+    """
+    print __doc__
+    try:
+        c = self.db.cursor()
+
+        c.execute("ALTER TABLE suite RENAME COLUMN announce TO announce_temp")
+        c.execute("ALTER TABLE suite ADD COLUMN announce TEXT[]")
+        c.execute("UPDATE suite SET announce = ARRAY[announce_temp] WHERE announce_temp IS NOT NULL")
+        c.execute("ALTER TABLE suite DROP COLUMN announce_temp")
+
+        c.execute("UPDATE config SET value = '65' WHERE name = 'db_revision'")
+        self.db.commit()
+
+    except psycopg2.ProgrammingError, msg:
+        self.db.rollback()
+        raise DBUpdateError, 'Unable to apply sick update 65, rollback issued. Error message : %s' % (str(msg))
diff --git a/dak/update_db.py b/dak/update_db.py
index 62f0889..0245b95 100755
--- a/dak/update_db.py
+++ b/dak/update_db.py
@@ -46,7 +46,7 @@ from daklib.daklog import Logger
 ################################################################################
 
 Cnf = None
-required_database_schema = 64
+required_database_schema = 65
 
 ################################################################################
 
diff --git a/daklib/queue.py b/daklib/queue.py
index 20e04bd..a44ad6d 100755
--- a/daklib/queue.py
+++ b/daklib/queue.py
@@ -2019,19 +2019,19 @@ distribution."""
 
         announcetemplate = os.path.join(cnf["Dir::Templates"], 'process-unchecked.announce')
 
-        lists_done = {}
+        lists_todo = {}
         summary = ""
 
-        self.Subst["__SHORT_SUMMARY__"] = short_summary
-
+        # Get a unique list of target lists
         for dist in self.pkg.changes["distribution"].keys():
             suite = get_suite(dist)
             if suite is None: continue
-            announce_list = suite.announce
-            if announce_list == "" or lists_done.has_key(announce_list):
-                continue
+            for tgt in suite.announce:
+                lists_todo[tgt] = 1
+
+        self.Subst["__SHORT_SUMMARY__"] = short_summary
 
-            lists_done[announce_list] = 1
+        for announce_list in lists_todo.keys():
             summary += "Announcing to %s\n" % (announce_list)
 
             if action:
-- 
1.7.2.5


Reply to: