From c9d9b6914cd3bf3201e8c04be90210da58ae0b5f Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Sat, 19 Feb 2022 22:20:57 +0800 Subject: Routine can send SMS now --- jimbrella/routine.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/jimbrella/routine.py b/jimbrella/routine.py index 659fbfa..3d92482 100644 --- a/jimbrella/routine.py +++ b/jimbrella/routine.py @@ -3,9 +3,10 @@ from dateutil.parser import isoparse import logging from .umbrellas import Umbrellas from .jform import JForm +from .sms import SMS from .exceptions import * from .config import config -from .utils import CST +from .utils import human_datetime, CST """A set of routine methods, run at an interval (somewhere from ten minutes to one hour), to: - sync JImbrella's databse against data pulled from jForm @@ -39,7 +40,7 @@ def chronological_merge(*sheet_lists) -> list: return chronicle -def sync_jform(takeaway: JForm, giveback: JForm, db: Umbrellas): +def sync_jform(takeaway: JForm, giveback: JForm, db: Umbrellas, sms: SMS): takeaway_unread = takeaway.get_unread() giveback_unread = giveback.get_unread() logging.info( @@ -62,6 +63,7 @@ def sync_jform(takeaway: JForm, giveback: JForm, db: Umbrellas): sheet["id"], sheet["phone"], ) + sms.borrow_success(sheet["phone"], sheet["name"], human_datetime(sheet["date"]), sheet["key"]) except (UmbrellaStatusError, UmbrellaNotFoundError): logging.warning( tenant_identity @@ -127,5 +129,6 @@ if __name__ == "__main__": config.get("jform", "bookmark_dir"), ) db = Umbrellas(config.get("general", "db_path")) - sync_jform(takeaway, giveback, db) + sms = SMS() + sync_jform(takeaway, giveback, db, sms) process_overdue(db) -- cgit v1.2.3