Fix broken GWR advance ticket check
This commit is contained in:
		
							parent
							
								
									9185052092
								
							
						
					
					
						commit
						df06402f19
					
				| 
						 | 
				
			
			@ -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()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue