# - - - o p e n D a t a b a s e def openDatabase(): '''Open the CBC database. [ if file PASS_FILE is readable and contains the CBC database password -> return a pycbc.CBCData instance representing that databes else -> raise IOError ] '''
The database is password-protected, and the password is in a
local file whose name is given in Section 13.6.1, “
PASS_FILE”. The script must have the
setuid permission so that it can read
that file, and of course the password file must not have any
#-- 1 # [ if PASS_FILE is readable -> # password := first line of that file, stripped # else -> raise IOError ] passFile = file(PASS_FILE) password = passFile.readline().strip() passFile.close() #-- 2 # [ if (password is the CBC database password) and # (CBC database is available) -> # db := a pycbc.CBCData instance representing that database # else -> try: db = pycbc.CBCData(password) except Exception, x: raise IOError("Can't open the CBC database: %s" % str(x)) #-- 3 return db