summaryrefslogtreecommitdiff
path: root/jimbrella/routine.py
diff options
context:
space:
mode:
authorFrederick Yin <fkfd@fkfd.me>2022-02-05 16:39:41 +0800
committerFrederick Yin <fkfd@fkfd.me>2022-02-05 16:39:41 +0800
commitfcc3ce60bcfa57734a51723717fe681ee4bf1327 (patch)
treec8d883a6cd2b898fed85a7f717be34de242ded25 /jimbrella/routine.py
parent14feb6a4378668d054d28a1335eacd2026b621dc (diff)
Config format switched to .ini
Eliminated toml from dependency list
Diffstat (limited to 'jimbrella/routine.py')
-rw-r--r--jimbrella/routine.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/jimbrella/routine.py b/jimbrella/routine.py
index 2626a76..77d69f2 100644
--- a/jimbrella/routine.py
+++ b/jimbrella/routine.py
@@ -4,9 +4,8 @@ import logging
from .umbrellas import Umbrellas
from .jform import JForm
from .admin_log import AdminLog
-from .config import *
from .exceptions import *
-from .config import DUE_HOURS
+from .config import config
from .utils import CST
"""A set of routine methods, run at an interval (somewhere from ten minutes to one hour), to:
@@ -114,7 +113,7 @@ def process_overdue(db: Umbrellas, admin: AdminLog):
)
continue
- if now - lent_at > timedelta(hours=DUE_HOURS):
+ if now - lent_at > timedelta(hours=config.getint("general", "due_hours")):
db.mark_overdue(umb["id"])
logging.warning(
"Umbrella #{id} is now overdue, tenant: {tenant_name} (ID: {tenant_id}, phone: {tenant_phone})".format(
@@ -134,9 +133,9 @@ def process_overdue(db: Umbrellas, admin: AdminLog):
if __name__ == "__main__":
- takeaway = JForm("takeaway", JFORM_TAKEAWAY_URL, JFORM_BOOKMARK_DIR)
- giveback = JForm("giveback", JFORM_GIVEBACK_URL, JFORM_BOOKMARK_DIR)
- db = Umbrellas(DATABASE_PATH)
- admin_log = AdminLog(ADMIN_LOG_PATH)
+ takeaway = JForm("takeaway", config.get("jform", "takeaway_url"), config.get("jform", "bookmark_dir"))
+ giveback = JForm("giveback", config.get("jform", "giveback_url"), config.get("jform", "bookmark_dir"))
+ db = Umbrellas(config.get("general", "db_path"))
+ admin_log = AdminLog(config.get("logging", "admin_log_path"))
sync_jform(takeaway, giveback, db, admin_log)
process_overdue(db, admin_log)