25 lines
849 B
Python
25 lines
849 B
Python
import argparse
|
|
import asyncio
|
|
|
|
import asyncpg
|
|
|
|
from env_config import get_database_url
|
|
from weather_forecast import ensure_weather_forecast_table, sync_all_weather_forecasts
|
|
|
|
|
|
async def main(force: bool) -> None:
|
|
pool = await asyncpg.create_pool(get_database_url(), min_size=1, max_size=5, command_timeout=60)
|
|
try:
|
|
async with pool.acquire() as conn:
|
|
await ensure_weather_forecast_table(conn)
|
|
stats = await sync_all_weather_forecasts(pool, force=force)
|
|
print(stats)
|
|
finally:
|
|
await pool.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser(description="Synk værprognoser fra MET for TeeOff-anlegg.")
|
|
parser.add_argument("--force", action="store_true", help="Tving ny nedlasting for alle anlegg.")
|
|
args = parser.parse_args()
|
|
asyncio.run(main(force=args.force))
|