Fix broken GWR advance ticket check

This commit is contained in:
Edward Betts 2023-11-25 11:24:37 +00:00
parent 9185052092
commit 8027782601

View file

@ -8,6 +8,7 @@ from email.message import EmailMessage
from email.utils import formatdate, make_msgid
import requests
import sys
from agenda import gwr
@ -35,7 +36,7 @@ def send_mail(subject: str, body: str) -> None:
def get_data_dir() -> str:
"""Read data dir from config."""
config_filename = os.path.join(os.path.dirname(__file__), "..", "config")
config_filename = os.path.join(os.path.dirname(__file__), "config")
assert os.path.exists(config_filename)
@ -57,6 +58,8 @@ def main() -> None:
new_date = gwr.extract_weekday_date(new_html)
if existing_date == new_date:
if sys.stdin.isatty():
print("date has't changed:", existing_date)
return
subject = "New GWR advance ticket booking date: {new_date}"
@ -68,3 +71,7 @@ New date: {new_date}
Agenda: https://edwardbetts.com/agenda/
"""
send_mail(subject, body)
if __name__ == "__main__":
main()