Sam
64516db02a
* Added setup_log_location function to handle log directory creation and validation. * Updated setup_logging function to accept a log location instead of a log file name. * Updated parse_args function to handle log directory argument and validate the presence of a config file. * Updated read_file function to raise an error if the specified file does not exist. * Updated parse_toml function to raise an error if the parsed TOML content is None. * Added get_calendar_dir function to validate the existence of the calendar directory. * Added parse_calendar_files function to find and return a list of .ics files in the specified directory. * Added construct_initial_event_dict function to parse each .ics file into an event dictionary and store them in a list. * Updated FileChangeHandler class to log warnings instead of errors for invalid or unparseable files. * Updated CalendarParser class to log warnings if no event dates are found for an event, or if the calendar component is missing. * Added daemon function to monitor events and update status files at regular intervals. * Updated main function to use setup_log_location, parse_args, get_calendar_dir, and construct_initial_event_dict functions. |
||
---|---|---|
.gitignore | ||
LICENSE | ||
Makefile | ||
README.md | ||
alert_processor.py | ||
config.toml | ||
remindme_caldav.py | ||
remindme_caldav.service | ||
requirements.txt |
README.md
remindme_caldav
A Calendar Alerting Daemon
Purpose
This script is a simple calendar alerting daemon written in Python. It monitors .ics files for changes and sends alerts based on the events' start times, recurrence rules, and alert triggers defined within these files. The main purpose of this script is to provide reminders or notifications about upcoming events.
How it Works
The script works by parsing .ics files using the icalendar
library, which
converts them into a Python dictionary format for easier manipulation. It then
processes each event and calculates when the next alert should be triggered
based on the event's start time, recurrence rules, and alert triggers. If an
alert is due to trigger, it sends a notification via email or XMPP (an instant
messaging protocol).
The script also monitors for changes in the directory containing .ics files
using the watchdog
library. When a file is modified, created, or deleted, it
updates its internal list of events accordingly.
How to Use It
This script should be used with a calendar syncing service such as vdirsyncer. vdirsyncer can be scheduled using cron to sync regularly from the CalDav server.
To use this script, you need Python 3 installed on your system. You can install the required libraries by running:
pip install -r requirements.txt
You also need a .toml configuration file with the following structure:
[app]
calendar_dir = "/path/to/your/ics/files"
email_address = "your-email@example.com"
smtp_server = "smtp.example.com"
smtp_port = 587
smtp_username = "your-username"
smtp_password = "your-password"
...
You can then run the script with:
python3 remindme_caldav.py --config /path/to/your/config.toml
Installation
A Makefile and systemd service file is also included for Debian/Ubuntu based systems.
This Makefile does the following:
-
install: Installs Python 3.11, creates a virtual environment in /opt/remindme_caldav/.venv, installs dependencies from requirements.txt into this virtual environment, copies your script to /opt/remindme_caldav/, and sets up the systemd service file.
-
uninstall: Stops and disables the systemd service, removes the installation directory (/opt/remindme_caldav/), and deletes the systemd service file.
-
clean: Deactivates the virtual environment.