ha-noaa-space-weather/feeder/cache.py

25 lines
525 B
Python
Raw Normal View History

import logging
import pickle
import time
from redis import Redis
2024-11-06 12:48:45 -07:00
from lib.glotec import get_latest_glotec
logging.basicConfig(level=logging.INFO)
2024-09-03 17:09:36 -06:00
def main():
redis = Redis(host='localhost', port=6379, db=0)
redis.flushall()
while True:
2024-11-06 12:48:45 -07:00
logging.info('Fetching latest GLOTEC data')
geojson = get_latest_glotec()
redis.set('latest_glotec_data', pickle.dumps(geojson))
2024-09-03 17:09:36 -06:00
logging.info('Scrape complete')
time.sleep(1800) # 30 minutes
if __name__ == '__main__':
2024-09-03 17:09:36 -06:00
main()