X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fupdate_db.py;h=6db74d9de35195df4d66ce782ba1495cb9d0442c;hb=f6fa12e0e3fe4d6aa9157085b77ed25e73745fe5;hp=665724e9520c32895a78f9e26f0ceb1ce51dcbe1;hpb=f9defe0eb79b8defb578d69bec2649fd37ae1e37;p=dak.git diff --git a/dak/update_db.py b/dak/update_db.py index 665724e9..6db74d9d 100755 --- a/dak/update_db.py +++ b/dak/update_db.py @@ -36,7 +36,7 @@ from daklib import utils Cnf = None projectB = None -required_database_schema = 1 +required_database_schema = 3 ################################################################################ @@ -100,7 +100,12 @@ Updates dak's database schema to the lastest version. You should disable crontab print "Determining dak database revision ..." try: - self.db = psycopg2.connect("dbname='" + Cnf["DB::Name"] + "' host='" + Cnf["DB::Host"] + "' port='" + str(Cnf["DB::Port"]) + "'") + # Build a connect string + connect_str = "dbname=%s"% (Cnf["DB::Name"]) + if Cnf["DB::Host"] != '': connect_str += " host=%s" % (Cnf["DB::Host"]) + if Cnf["DB::Port"] != '-1': connect_str += " port=%d" % (int(Cnf["DB::Port"])) + + self.db = psycopg2.connect(connect_str) except: print "FATAL: Failed connect to database" @@ -115,7 +120,7 @@ Updates dak's database schema to the lastest version. You should disable crontab print "Please make sure you have a database backup handy. If you don't, press Ctrl-C now!" print "" print "Continuing in five seconds ..." - #time.sleep(5) + time.sleep(5) print "" print "Attempting to upgrade pre-zero database to zero" @@ -134,7 +139,7 @@ Updates dak's database schema to the lastest version. You should disable crontab dakdb = __import__("dakdb", globals(), locals(), ['update'+str(i+1)]) update_module = getattr(dakdb, "update"+str(i+1)) update_module.do_update(self) - database_revision =+ 1 + database_revision += 1 ################################################################################ @@ -151,10 +156,10 @@ Updates dak's database schema to the lastest version. You should disable crontab options = Cnf.SubTree("Update-DB::Options") if options["Help"]: - usage() + self.usage() elif arguments: utils.warn("dak update-db takes no arguments.") - usage(exit_code=1) + self.usage(exit_code=1) self.update_db()