From 30dc31344c39888571d8607f2ea1ccc943e80b8d Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 15 Feb 2024 17:02:22 +0000 Subject: [PATCH] Update Makefile and Python scripts - Updated the install command to use python3-venv instead of python3.11-venv. - Added alert_processor.py to the list of files copied to /opt/remindme_caldav/. - Changed the activation of the virtual environment and pip installation commands. - Updated logging to not use f-strings --- Makefile | 8 ++++---- remindme_caldav.py | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index c34c759..db1bf0d 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ install: - sudo apt-get update && sudo apt-get install -y python3.11 python3.11-venv - python3.11 -m venv /opt/remindme_caldav/.venv - source /opt/remindme_caldav/.venv/bin/activate && pip install --upgrade pip && pip install -r requirements.txt - cp remindme_caldav.py /opt/remindme_caldav/ + sudo apt-get update && sudo apt install python3-venv -y + python3 -m venv /opt/remindme_caldav/.venv + 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 systemctl daemon-reload sudo systemctl enable remindme_caldav.service diff --git a/remindme_caldav.py b/remindme_caldav.py index 05a79d0..1949dfb 100644 --- a/remindme_caldav.py +++ b/remindme_caldav.py @@ -37,13 +37,13 @@ def read_file(filename): try: return Path(filename).read_text() except FileNotFoundError as e: - raise RuntimeError(f"Error: The specified file does not exist. {e}") + raise RuntimeError("Error: The specified file does not exist.") def parse_toml(content): try: return toml.loads(content) except Exception as e: - raise RuntimeError(f"Error: Failed to parse TOML file. {e}") + raise RuntimeError("Error: Failed to parse TOML file.") def calculate_event_hash(event): return hashlib.md5(json.dumps(event, sort_keys=True, cls=DateTimeEncoder).encode()).hexdigest() @@ -247,7 +247,7 @@ class CalendarParser: try: return Calendar.from_ical(cal_str) except Exception as e: - raise RuntimeError(f"Error parsing calendar. Message from icalendar: {e}") + raise RuntimeError("Error parsing calendar.") def process_event(self, event): """ @@ -282,7 +282,7 @@ class CalendarParser: else: return dt.datetime.combine(dtstart, dt.time.min).replace(tzinfo=pytz.UTC) except Exception as e: - raise RuntimeError(f"Error converting dtstart to datetime. Message: {e}") + raise RuntimeError("Error converting dtstart to datetime.") def remove_exdates(self, exdates, recur_dates): """ @@ -296,7 +296,7 @@ class CalendarParser: exdates = [exdates.dts[0].dt.replace(tzinfo=pytz.UTC)] return [i for i in recur_dates if i not in exdates] except Exception as e: - raise RuntimeError(f"Error processing exdates. Message {e}") + raise RuntimeError("Error processing exdates.") else: return recur_dates @@ -344,7 +344,7 @@ def process_alert(current_time, next_alert, next_event, event, config): processor = AlertProcessor(config) processor.send_email(event, next_alert, next_event) except Exception as e: - raise RuntimeError(f"Error sending alert for event {event['summary']}. Message {e}") + raise RuntimeError("Error sending alert for event.") #processor.send_xmpp(event, next_alert, next_event) with open("alert_history", 'a') as f: