def __init__(self, path_to_repo): """ Opens an existing repository at given path. """ try: self._base_path = path_to_repo if not os.path.exists(self.base_path + os.sep + consts.METADATA_DIR): raise Exception("Directory {} is not a repository base path.".format(self.base_path)) engine_echo = stringToBool(UserConfig().get("sqlalchemy.engine_echo")) self.__engine = sqa.create_engine( "sqlite:///" + self.base_path + os.sep + consts.METADATA_DIR + os.sep + consts.DB_FILE, echo=engine_echo ) self.Session = sessionmaker(bind=self.__engine) except Exception as ex: raise CannotOpenRepoError(ex)
def __init__(self, path_to_repo): ''' Opens an existing repository at given path. ''' try: self._base_path = path_to_repo if not os.path.exists(self.base_path + os.sep + consts.METADATA_DIR): raise Exception("Directory {} is not a repository base path." .format(self.base_path)) engine_echo = stringToBool(UserConfig().get("sqlalchemy.engine_echo")) self.__engine = sqa.create_engine(\ "sqlite:///" + self.base_path + os.sep + consts.METADATA_DIR + os.sep + \ consts.DB_FILE, echo=engine_echo) self.Session = sessionmaker(bind=self.__engine) except Exception as ex: raise CannotOpenRepoError(ex)
def isSendStatisticsAllowed(): sendStatistics = UserConfig().get("send_statistics") return hlp.stringToBool(sendStatistics)