Update Bristol bins from cron to save time

Closes: #96
This commit is contained in:
Edward Betts 2024-01-08 15:43:31 +00:00
parent 1453c4015c
commit 7456f72325

31
update_bristol_bins.py Executable file
View file

@ -0,0 +1,31 @@
#!/usr/bin/python3
"""Update waste schedule from Bristol City Council."""
import asyncio
import sys
from datetime import date
from time import time
import agenda.types
import agenda.waste_schedule
config = __import__("config.default", fromlist=[""])
async def bristol_waste_collection_events() -> list[agenda.types.Event]:
"""Waste colllection events."""
uprn = "358335"
return await agenda.waste_schedule.get_bristol_gov_uk(
date.today(), config.DATA_DIR, uprn, refresh=True
)
today = date.today()
t0 = time()
events = asyncio.run(bristol_waste_collection_events())
time_taken = time() - t0
if sys.stdin.isatty():
for event in events:
print(event)
print(f"took {time_taken:.1f} seconds")