From 22e15fc49d8fe22f94622ec2078ea7d70208d17d Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 15 Feb 2024 19:56:40 +0000 Subject: [PATCH] Update install process and add configuration file management - Added mkdir command to create /etc/remindme_caldav directory. - Copied config.toml to the new directory. - Updated Makefile install instructions to include these changes. - Updated comment in config.toml to provide a link to the readme for an example configuration. - Removed placeholder values from all sections of the config file. - Added check to ensure there are .ics files in the destination location before parsing them. - If no files are found, log a message and exit with an error code. --- Makefile | 2 ++ config.toml | 20 ++++++++++---------- remindme_caldav.py | 7 ++++++- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index db1bf0d..8059f9b 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,8 @@ install: cp remindme_caldav.py alert_processor.py /opt/remindme_caldav/ . /opt/remindme_caldav/.venv/bin/activate && pip3 install -r requirements.txt sudo cp remindme_caldav.service /etc/systemd/system/ + sudo mkdir /etc/remindme_caldav + sudo cp config.toml /etc/remindme_caldav/config.toml sudo systemctl daemon-reload sudo systemctl enable remindme_caldav.service sudo systemctl start remindme_caldav.service diff --git a/config.toml b/config.toml index d38fa08..2a3b4ca 100644 --- a/config.toml +++ b/config.toml @@ -1,16 +1,16 @@ -# Modify to your requirements +# Modify to your requirements. See readme for example. [app] -calendar_dir = "FULL_PATH_TO_.ICS_CALENDAR_FILES" +calendar_dir = [email] -smtp_server = "SMTP.PROVIDER.DOMAIN" -port = 587 -username = "YOUR_USERNAME" -password = "YOUR_PASSWORD" -recipient = "RECIPIENT_EMAIL_ADDRESS" +smtp_server = +port = +username = +password = +recipient = [xmpp] -jid = 'YOUR_USERNAME@SERVER_INSTANCE.DOMAIN' -password = 'YOUR_PASSWORD' -recipient = 'RECIPIENT_USERNAME@SERVER_INSTANCE.DOMAIN' +jid = +password = +recipient = [notify-send] diff --git a/remindme_caldav.py b/remindme_caldav.py index 86dbd00..ebad052 100644 --- a/remindme_caldav.py +++ b/remindme_caldav.py @@ -33,7 +33,8 @@ def read_file(filename): def parse_toml(content): try: - return toml.loads(content) + config = toml.loads(content) + return config except Exception as e: logger.error("Error: Failed to parse TOML file.") sys.exit(1) @@ -371,6 +372,10 @@ def main(): #Parse calendar events calendar_parser = CalendarParser() files = list(cal_dir.glob('*.ics')) + if len(files) == 0: + logger.info("No calendar files in destination location. Did you sync with the caldav server?") + sys.exit(1) # Exit with error code + event_list = [] # List to hold dictionaries for each event for file in files: with open(file, 'r') as f: