From df06402f19788240f377dede6caf7503424b1a90 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sat, 25 Nov 2023 11:24:37 +0000 Subject: [PATCH] Fix broken GWR advance ticket check --- update_gwr_advance_ticket_date.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/update_gwr_advance_ticket_date.py b/update_gwr_advance_ticket_date.py index 6688754..2ee6433 100755 --- a/update_gwr_advance_ticket_date.py +++ b/update_gwr_advance_ticket_date.py @@ -4,6 +4,7 @@ import configparser import os.path import smtplib +import sys from email.message import EmailMessage from email.utils import formatdate, make_msgid @@ -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()