agenda/update_thespacedevs.py

21 lines
456 B
Python
Executable file

#!/usr/bin/python3
"""Update cache of space launch API."""
import os
import sys
from time import time
import agenda.thespacedevs
config = __import__("config.default", fromlist=[""])
rocket_dir = os.path.join(config.DATA_DIR, "thespacedevs")
t0 = time()
rockets = agenda.thespacedevs.next_launch_api(rocket_dir)
time_taken = time() - t0
if not sys.stdin.isatty():
sys.exit(0)
print(len(rockets), "launches")
print(f"took {time_taken:.1f} seconds")