コード例 #1
0
 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)
コード例 #2
0
ファイル: wdb.py プロジェクト: ananyashreyjain/python-brlcad
 def __init__(self, db_file, title=None):
     try:
         self.db_fp = None
         if os.path.isfile(db_file):
             self.db_ip = libwdb.db_open(db_file, "r+w")
             if self.db_ip == libwdb.DBI_NULL:
                 raise BRLCADException(
                     "Can't open existing DB file: <{0}>".format(db_file))
             if libwdb.db_dirbuild(self.db_ip) < 0:
                 raise BRLCADException(
                     "Failed loading directory of DB file: <{}>".format(
                         db_file))
             self.db_fp = libwdb.wdb_dbopen(self.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_file))
         if not self.db_fp:
             self.db_fp = libwdb.wdb_fopen(db_file)
             if self.db_fp == libwdb.RT_WDB_NULL:
                 raise BRLCADException(
                     "Failed creating new DB file: <{}>".format(db_file))
             self.db_ip = self.db_fp.contents.dbip
             if title:
                 libwdb.mk_id(self.db_fp, title)
     except Exception as e:
         raise BRLCADException("Can't open DB file <{0}>: {1}".format(
             db_file, e))
コード例 #3
0
ファイル: wdb.py プロジェクト: raj12lnm/python-brlcad
 def __init__(self, db_file, title=None):
     try:
         self.db_fp = None
         if os.path.isfile(db_file):
             self.db_ip = libwdb.db_open(db_file, "r+w")
             if self.db_ip == libwdb.DBI_NULL:
                 raise BRLCADException("Can't open existing DB file: <{0}>".format(db_file))
             if libwdb.db_dirbuild(self.db_ip) < 0:
                 raise BRLCADException("Failed loading directory of DB file: <{}>".format(db_file))
             self.db_fp = libwdb.wdb_dbopen(self.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_file))
         if not self.db_fp:
             self.db_fp = libwdb.wdb_fopen(db_file)
             if self.db_fp == libwdb.RT_WDB_NULL:
                 raise BRLCADException("Failed creating new DB file: <{}>".format(db_file))
             self.db_ip = self.db_fp.contents.dbip
             if title:
                 libwdb.mk_id(self.db_fp, title)
     except Exception as e:
         raise BRLCADException("Can't open DB file <{0}>: {1}".format(db_file, e))
コード例 #4
0
 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)