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
This commit is contained in:
parent
33244c1994
commit
30dc31344c
8
Makefile
8
Makefile
|
@ -1,8 +1,8 @@
|
||||||
install:
|
install:
|
||||||
sudo apt-get update && sudo apt-get install -y python3.11 python3.11-venv
|
sudo apt-get update && sudo apt install python3-venv -y
|
||||||
python3.11 -m venv /opt/remindme_caldav/.venv
|
python3 -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 alert_processor.py /opt/remindme_caldav/
|
||||||
cp remindme_caldav.py /opt/remindme_caldav/
|
. /opt/remindme_caldav/.venv/bin/activate && pip3 install -r requirements.txt
|
||||||
sudo cp remindme_caldav.service /etc/systemd/system/
|
sudo cp remindme_caldav.service /etc/systemd/system/
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl enable remindme_caldav.service
|
sudo systemctl enable remindme_caldav.service
|
||||||
|
|
|
@ -37,13 +37,13 @@ def read_file(filename):
|
||||||
try:
|
try:
|
||||||
return Path(filename).read_text()
|
return Path(filename).read_text()
|
||||||
except FileNotFoundError as e:
|
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):
|
def parse_toml(content):
|
||||||
try:
|
try:
|
||||||
return toml.loads(content)
|
return toml.loads(content)
|
||||||
except Exception as e:
|
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):
|
def calculate_event_hash(event):
|
||||||
return hashlib.md5(json.dumps(event, sort_keys=True, cls=DateTimeEncoder).encode()).hexdigest()
|
return hashlib.md5(json.dumps(event, sort_keys=True, cls=DateTimeEncoder).encode()).hexdigest()
|
||||||
|
@ -247,7 +247,7 @@ class CalendarParser:
|
||||||
try:
|
try:
|
||||||
return Calendar.from_ical(cal_str)
|
return Calendar.from_ical(cal_str)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise RuntimeError(f"Error parsing calendar. Message from icalendar: {e}")
|
raise RuntimeError("Error parsing calendar.")
|
||||||
|
|
||||||
def process_event(self, event):
|
def process_event(self, event):
|
||||||
"""
|
"""
|
||||||
|
@ -282,7 +282,7 @@ class CalendarParser:
|
||||||
else:
|
else:
|
||||||
return dt.datetime.combine(dtstart, dt.time.min).replace(tzinfo=pytz.UTC)
|
return dt.datetime.combine(dtstart, dt.time.min).replace(tzinfo=pytz.UTC)
|
||||||
except Exception as e:
|
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):
|
def remove_exdates(self, exdates, recur_dates):
|
||||||
"""
|
"""
|
||||||
|
@ -296,7 +296,7 @@ class CalendarParser:
|
||||||
exdates = [exdates.dts[0].dt.replace(tzinfo=pytz.UTC)]
|
exdates = [exdates.dts[0].dt.replace(tzinfo=pytz.UTC)]
|
||||||
return [i for i in recur_dates if i not in exdates]
|
return [i for i in recur_dates if i not in exdates]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise RuntimeError(f"Error processing exdates. Message {e}")
|
raise RuntimeError("Error processing exdates.")
|
||||||
else:
|
else:
|
||||||
return recur_dates
|
return recur_dates
|
||||||
|
|
||||||
|
@ -344,7 +344,7 @@ def process_alert(current_time, next_alert, next_event, event, config):
|
||||||
processor = AlertProcessor(config)
|
processor = AlertProcessor(config)
|
||||||
processor.send_email(event, next_alert, next_event)
|
processor.send_email(event, next_alert, next_event)
|
||||||
except Exception as e:
|
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)
|
#processor.send_xmpp(event, next_alert, next_event)
|
||||||
|
|
||||||
with open("alert_history", 'a') as f:
|
with open("alert_history", 'a') as f:
|
||||||
|
|
Loading…
Reference in New Issue