diff --git a/update.py b/update.py index 00460c2..efa4bd9 100755 --- a/update.py +++ b/update.py @@ -29,6 +29,9 @@ from agenda.types import StrDict from web_view import app +from datetime import date, timedelta + + async def update_bank_holidays(config: flask.config.Config) -> None: """Update cached copy of UK Bank holidays.""" t0 = time() @@ -318,8 +321,7 @@ def update_thespacedevs(config: flask.config.Config) -> None: """ rocket_dir = os.path.join(config["DATA_DIR"], "thespacedevs") - existing_data = agenda.thespacedevs.load_cached_launches(rocket_dir) - assert existing_data + existing_data = agenda.thespacedevs.load_cached_launches(rocket_dir) or {} if agenda.thespacedevs.is_launches_cache_fresh(rocket_dir): return @@ -411,16 +413,13 @@ def update_gandi(config: flask.config.Config) -> None: def update_weather(config: flask.config.Config) -> None: """Refresh weather cache for home and all upcoming trips.""" - from datetime import date, timedelta today = date.today() forecast_window = today + timedelta(days=8) trips = agenda.trip.build_trip_list() upcoming = [ - t - for t in trips - if (t.end or t.start) >= today and t.start <= forecast_window + t for t in trips if (t.end or t.start) >= today and t.start <= forecast_window ] seen: set[tuple[float, float]] = set()