def test_direct_calls(self): db_name = "direct_empty_db.g" if os.path.isfile(db_name): os.remove(db_name) # first time the DB is created: db_fp = libwdb.wdb_fopen(db_name) if db_fp == libwdb.RT_WDB_NULL: raise BRLCADException( "Failed creating new DB file: <{}>".format(db_name)) db_ip = db_fp.contents.dbip self.check_empty_db(db_ip) libwdb.wdb_close(db_fp) # second time the DB exists and it is re-opened: db_ip = libwdb.db_open(db_name, "r+w") if db_ip == libwdb.DBI_NULL: raise BRLCADException( "Can't open existing DB file: <{0}>".format(db_name)) if libwdb.db_dirbuild(db_ip) < 0: raise BRLCADException( "Failed loading directory of DB file: <{}>".format(db_name)) self.db_fp = libwdb.wdb_dbopen(db_ip, libwdb.RT_WDB_TYPE_DB_DISK) if self.db_fp == libwdb.RT_WDB_NULL: raise BRLCADException( "Failed read existing DB file: <{}>".format(db_name)) self.check_empty_db(db_ip)
def test_direct_calls(self): db_name = "direct_empty_db.g" if os.path.isfile(db_name): os.remove(db_name) # first time the DB is created: db_fp = libwdb.wdb_fopen(db_name) if db_fp == libwdb.RT_WDB_NULL: raise BRLCADException("Failed creating new DB file: <{}>".format(db_name)) db_ip = db_fp.contents.dbip self.check_empty_db(db_ip) libwdb.wdb_close(db_fp) # second time the DB exists and it is re-opened: db_ip = libwdb.db_open(db_name, "r+w") if db_ip == libwdb.DBI_NULL: raise BRLCADException("Can't open existing DB file: <{0}>".format(db_name)) if libwdb.db_dirbuild(db_ip) < 0: raise BRLCADException("Failed loading directory of DB file: <{}>".format(db_name)) self.db_fp = libwdb.wdb_dbopen(db_ip, libwdb.RT_WDB_TYPE_DB_DISK) if self.db_fp == libwdb.RT_WDB_NULL: raise BRLCADException("Failed read existing DB file: <{}>".format(db_name)) self.check_empty_db(db_ip)
def close(self): libwdb.wdb_close(self.db_fp)