Beispiel #1
0
def load_logging_conf(log_file_path: str):
    """
    load logging conf for app
    :param log_file_path:
    :return:
    """
    try:
        with open(current_dir + "{}".format(log_file_path), "r", encoding="utf-8") as log_conf_f:
            config.dictConfig(yaml.safe_load(log_conf_f))
    except FileNotFoundError:
        raise FileNotFound("loading log conf load error")
Beispiel #2
0
def get_mm_divisions():
    """
    get all divisions list
    :return:
    """
    try:
        path = os.path.dirname(__file__) + division_file_path
        with open(path) as d:
            mm_divisions = json.load(d)
        return jsonify({
            "data": {
                "divisions": mm_divisions
            }}), 200
    except FileNotFoundError:
        current_app.logger.info("Divison json file not found:{}".format(division_file_path))
        return jsonify({"errors": [FileNotFound("Division file not found").__dict__]}), 404
Beispiel #3
0
def load_config() -> dict:
    """
    load conf based on environment
    :return:
    """
    env = "dev"
    if os.environ.get("SCRIPT_ENV") == "production":
        env = "prod"
    elif os.environ.get("SCRIPT_ENV") == "staging":
        env = "staging"
    elif os.environ.get("SCRIPT_ENV") == "test":
        env = "test"
    try:
        with open(current_dir + "config_{}.yaml".format(env), "r", encoding="utf-8") as conf_f:
            conf = yaml.safe_load(conf_f)
        return conf
    except FileNotFoundError:
        raise FileNotFound("app conf load error")