################################################################################
-import psycopg2, time
+import psycopg2
+import time
+from daklib.dak_exceptions import DBUpdateError
################################################################################
except psycopg2.ProgrammingError, msg:
self.db.rollback()
- print "FATAL: Unable to apply DM table update 1!"
- print "Error Message: " + str(msg)
- print "Database changes have been rolled back."
+ raise DBUpdateError, "Unable to appy DM table updates, rollback issued. Error message : %s" % (str(msg)
################################################################################
-import psycopg2, time
+import psycopg2
+import time
+from daklib.dak_exceptions import DBUpdateError
################################################################################
except psycopg2.ProgrammingError, 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)
################################################################################
-import psycopg2, time
+import psycopg2
+import time
+from daklib.dak_exceptions import DBUpdateError
################################################################################
except psycopg2.ProgrammingError, msg:
self.db.rollback()
- print "FATAL: Unable to apply db update 3!"
- print "Error Message: " + str(msg)
- print "Database changes have been rolled back."
+ raise DBUpdateError, "Unable to appy versioncmp removal, rollback issued. Error message : %s" % (str(msg)
for i in range (database_revision, required_database_schema):
print "updating databse schema from " + str(database_revision) + " to " + str(i+1)
- dakdb = __import__("dakdb", globals(), locals(), ['update'+str(i+1)])
- update_module = getattr(dakdb, "update"+str(i+1))
- update_module.do_update(self)
+ try:
+ dakdb = __import__("dakdb", globals(), locals(), ['update'+str(i+1)])
+ update_module = getattr(dakdb, "update"+str(i+1))
+ update_module.do_update(self)
+ except DBUpdateError, e:
+ # Seems the update did not work.
+ print "Was unable to update database schema from %s to %s." % (str(database_revision), str(i+1))
+ print "The error message received was %s" % (e)
+ utils.fubar("DB Schema upgrade failed")
database_revision += 1
################################################################################
"SendmailFailedError": """Exception raised when Sendmail invocation failed.""",
"NoFreeFilenameError": """Exception raised when no alternate filename was found.""",
"TransitionsError": """Exception raised when transitions file can't be parsed.""",
- "NoSourceFieldError": """Exception raised - we cant find the source - wtf?"""
+ "NoSourceFieldError": """Exception raised - we cant find the source - wtf?""",
+ "DBUpdateError": """Exception raised - could not update the database"""
} #: All dak exceptions
def construct_dak_exception(name, description):