Example #1
0
 def write(self) -> None:
     """Write the example DB to a SQLite DB and change the DB path."""
     self.tmp_dbdir = tempfile.mkdtemp()
     self.old_path = getconfig("database.path")
     setconfig("database.path", self.tmp_dbdir)
     dbman = CLIDbManager(DbState())
     dbman.import_new_db(self.path, User())
Example #2
0
 def tearDown(self):
     from gramps.gen.config import set as setconfig
     for (dirpath, dirnames, filenames) in os.walk(self.newpath, False):
         for afile in filenames:
             os.remove(os.path.join(dirpath, afile))
         for adir in dirnames:
             os.rmdir(os.path.join(dirpath, adir))
     os.rmdir(self.newpath)
     setconfig('database.path', self.old_path)
Example #3
0
 def tearDown(self):
     from gramps.gen.config import set as setconfig
     for (dirpath, dirnames, filenames) in os.walk(self.newpath, False):
         for afile in filenames:
             os.remove(os.path.join(dirpath, afile))
         for adir in dirnames:
             os.rmdir(os.path.join(dirpath, adir))
     os.rmdir(self.newpath)
     setconfig('behavior.database-path', self.old_path)
Example #4
0
 def setUp(self):
     from gramps.cli.clidbman import CLIDbManager
     from gramps.gen.config import set as setconfig, get as getconfig
     from gramps.gen.dbstate import DbState
     self.newpath = os.path.join(os.path.dirname(__file__),
                                 '\u0393\u03c1\u03b1\u03bc\u03c3\u03c0')
     self.newtitle = 'Gr\u00e4mps T\u00e9st'
     os.makedirs(self.newpath)
     self.old_path = getconfig('database.path')
     setconfig('database.path', self.newpath)
     self.cli = CLIDbManager(DbState())
Example #5
0
 def setUp(self):
     from gramps.cli.clidbman import CLIDbManager
     from gramps.gen.config import set as setconfig, get as getconfig
     from gramps.gen.dbstate import DbState
     self.newpath = os.path.join(os.path.dirname(__file__),
                                 '\u0393\u03c1\u03b1\u03bc\u03c3\u03c0')
     self.newtitle = 'Gr\u00e4mps T\u00e9st'
     os.makedirs(self.newpath)
     self.old_path = getconfig('behavior.database-path')
     setconfig('behavior.database-path', self.newpath)
     self.cli = CLIDbManager(DbState())
Example #6
0
 def __init__(self, name: str = None) -> None:
     """Prepare and import the example DB."""
     ExampleDbBase.__init__(self)
     self.db_path = os.path.join(os.environ["GRAMPSHOME"], "gramps",
                                 "grampsdb")
     os.makedirs(self.db_path, exist_ok=True)
     setconfig("database.path", self.db_path)
     dbstate = DbState()
     dbman = CLIDbManager(dbstate)
     user = User()
     smgr = CLIManager(dbstate, True, user)
     smgr.do_reg_plugins(dbstate, uistate=None)
     self.path, self.name = dbman.import_new_db(self.path, User())
     WebDbManager.__init__(self, self.name)
Example #7
0
 def delete(self) -> None:
     """Change the DB path back and delete the SQLite DB."""
     if self.tmp_dbdir:
         shutil.rmtree(self.tmp_dbdir)
     if self.old_path:
         setconfig("database.path", self.old_path)