]> git.decadent.org.uk Git - dak.git/blobdiff - dak/dakdb/update2.py
Convert exception handling to Python3 syntax.
[dak.git] / dak / dakdb / update2.py
index e411662c69fd50860c135173ceeda6cacb02c2c2..9ad0da5d573cacc5b4e166a20d109e203c87b8dc 100755 (executable)
@@ -1,9 +1,14 @@
 #!/usr/bin/env python
 # coding=utf8
 
-""" Database Update Script - debversion """
-# Copyright © 2008  Michael Casadevall <mcasadevall@debian.org>
-# Copyright © 2008  Roger Leigh <rleigh@debian.org>
+"""
+debversion
+
+@contact: Debian FTP Master <ftpmaster@debian.org>
+@copyright: 2008  Michael Casadevall <mcasadevall@debian.org>
+@copyright: 2008  Roger Leigh <rleigh@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
 
 ################################################################################
 
-import psycopg2, time
+import psycopg2
+import time
+from daklib.dak_exceptions import DBUpdateError
 
 ################################################################################
 
 def do_update(self):
-vvvvvvvvvvvvvvvvvvvv
     print "Note: to be able to enable the the PL/Perl (plperl) procedural language, we do"
     print "need postgresql-plperl-$postgres-version installed. Make sure that this is the"
     print "case before you continue. Interrupt if it isn't, sleeping 5 seconds now."
     print "(We need to be database superuser for this to work!)"
     time.sleep (5)
-^^^^^^^^^^^^^^^^^^^^
 
     try:
         c = self.db.cursor()
@@ -391,8 +396,6 @@ $$
 
         self.db.commit()
 
-    except psycopg2.ProgrammingError, msg:
+    except psycopg2.ProgrammingError as msg:
         self.db.rollback()
-        print "FATAL: Unable to apply debversion table update 2!"
-        print "Error Message: " + str(msg)
-        print "Database changes have been rolled back."
+        raise DBUpdateError, "Unable to appy debversion updates, rollback issued. Error message : %s" % (str(msg))