X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fupdate_db.py;h=88d8e4e66e6425e91a6501c5c09af21a8e395b5a;hb=11edf9c1ed3b718c022f81fa10085d1c78774e9e;hp=7d7fe9fe596a91082d816d77f8490e1661967c96;hpb=4dbff62f35fdab0d7452a81a6f93956436caa0f1;p=dak.git diff --git a/dak/update_db.py b/dak/update_db.py index 7d7fe9fe..88d8e4e6 100755 --- a/dak/update_db.py +++ b/dak/update_db.py @@ -107,10 +107,9 @@ Updates dak's database schema to the lastest version. You should disable crontab try: # Build a connect string -# connect_str = "dbname=%s"% (Cnf["DB::Name"]) - connect_str = "dbname=%s"% "projectbstew" -# if Cnf["DB::Host"] != '': connect_str += " host=%s" % (Cnf["DB::Host"]) -# if Cnf["DB::Port"] != '-1': connect_str += " port=%d" % (int(Cnf["DB::Port"])) + 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) @@ -177,12 +176,12 @@ Updates dak's database schema to the lastest version. You should disable crontab self.update_db() -#STU try: -#STU lock_fd = os.open(Cnf["Dinstall::LockFile"], os.O_RDWR | os.O_CREAT) -#STU fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB) -#STU except IOError, e: -#STU if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EAGAIN': -#STU utils.fubar("Couldn't obtain lock; assuming another 'dak process-unchecked' is already running.") + try: + lock_fd = os.open(Cnf["Dinstall::LockFile"], os.O_RDWR | os.O_CREAT) + fcntl.lockf(lock_fd, fcntl.LOCK_EX | fcntl.LOCK_NB) + except IOError, e: + if errno.errorcode[e.errno] == 'EACCES' or errno.errorcode[e.errno] == 'EAGAIN': + utils.fubar("Couldn't obtain lock; assuming another 'dak process-unchecked' is already running.") ################################################################################