diff options
Diffstat (limited to 'jimbrella/routine.py')
-rw-r--r-- | jimbrella/routine.py | 13 |
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) |