def _get_logging_level(): config_parser = get_config_parser("environment.ini") level = config_parser["environment"]["logger_level"] if level == "debug": return logging.DEBUG elif level == "info": return logging.INFO elif level != "debug" and level != "info": return None
def get_connection_string(mode=Mode.productive): config_parser = get_config_parser("database.ini") database_type = config_parser[mode.value]["database_type"] username = config_parser[mode.value]["username"] password = config_parser[mode.value]["password"] host = config_parser[mode.value]["host"] port = config_parser[mode.value]["port"] database = config_parser[mode.value]["database"] return f"{database_type}://{username}:{password}@{host}:{port}/{database}"
def data(self, value): if isinstance(value, bytes): config_parser = get_config_parser("environment.ini") path = config_parser["paths"]["images"] if not os.path.exists(path): os.mkdir(path) name = str(uuid.uuid1()) format = fleep.get(value).extension[0] full_path = f"{path}{name}.{format}" with open(full_path, "wb+") as f: f.write(value) self._data = full_path elif value is None: self._data = None else: raise TypeError("Must provide bytes as data")
def secret_key(self): if self._secret_key is None: environment_parser = get_config_parser("environment.ini") self._secret_key = environment_parser["environment"]["secret_key"] return self._secret_key
def __init__(self): config_parser = get_config_parser("environment.ini") self._host = str(config_parser["tumbleWebServer"]["host"]) self._port = str(config_parser["tumbleWebServer"]["port"]) self._route = str(config_parser["tumbleWebServer"]["route"])
def _get_path_from_config(): config_parser = get_config_parser("environment.ini") path = config_parser["paths"]["logger"] return path
def get_pool_size(mode=Mode.productive): config_parser = get_config_parser("database.ini") return int(config_parser[mode.value]["pool_size"])