From 6392802d696a228250cce7f9ddeaca8f6fb92b29 Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Sun, 31 Oct 2021 14:23:29 +0800 Subject: Config: read from TOML file --- jimbrella/config.py | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'jimbrella/config.py') diff --git a/jimbrella/config.py b/jimbrella/config.py index 77e944e..85833d0 100644 --- a/jimbrella/config.py +++ b/jimbrella/config.py @@ -1,14 +1,22 @@ -# jForm -JFORM_TAKEAWAY_URL = ( - "https://wj.sjtu.edu.cn/api/v1/public/export/900e25bf6a039da04da7c5165a7cd41a/json" -) -# JFORM_GIVEBACK_URL= ( -# "https://wj.sjtu.edu.cn/api/v1/public/export/900e25bf6a039da04da7c5165a7cd41a/json" -# ) -JFORM_BOOKMARK_DIR = "/home/fkfd/p/jimbrella/" - -# database -DATABASE_PATH = "/home/fkfd/p/jimbrella/jimbrella.db.csv" - -# rules of service -DUE_HOURS = 72 +import os +import toml + +config_path = os.environ["JIMBRELLA_CONFIG"] or "/opt/jimbrella/config.toml" + +f = open(config_path) +config = toml.load(f) +f.close() + +FLASK_SECRET_KEY = config["flask"]["secret_key"] + +JFORM_TAKEAWAY_URL = config["jform"]["takeaway_url"] +JFORM_GIVEBACK_URL = config["jform"]["giveback_url"] +JFORM_BOOKMARK_DIR = config["jform"]["bookmark_dir"] + +DATABASE_PATH = config["db"]["db_path"] +USERS_PATH = config["db"]["users_path"] + +DUE_HOURS = config["rules"]["due_hours"] + +LOG_PATH = config["logging"]["log_path"] +ADMIN_LOG_PATH = config["logging"]["admin_log_path"] -- cgit v1.2.3