get working
This commit is contained in:
parent
aa472d98cf
commit
33dae67940
|
@ -4,8 +4,9 @@ This is an MQTT sensor to send NOAA space weather data to Home Assistant. Fetchi
|
|||
|
||||
1. Create an account at <https://urs.earthdata.nasa.gov>
|
||||
2. `pip install -r requirements.txt`
|
||||
3. `sudo apt install p7zip-full redis-server`
|
||||
4. `sudo systemctl enable --now redis-server`
|
||||
3. `sudo apt-get install p7zip-full redis-server`
|
||||
4. `sudo apt-get install dvipng texlive-latex-extra texlive-fonts-recommended cm-super`
|
||||
5. `sudo systemctl enable --now redis-server`
|
||||
|
||||
### Google Chrome
|
||||
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
import logging
|
||||
import os
|
||||
import pickle
|
||||
import signal
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
import traceback
|
||||
from datetime import datetime
|
||||
|
||||
from redis import Redis
|
||||
|
@ -22,8 +19,7 @@ if not CDDIS_USERNAME or not CDDIS_PASSWORD:
|
|||
sys.exit(1)
|
||||
|
||||
|
||||
def update_cache():
|
||||
try:
|
||||
def main():
|
||||
redis = Redis(host='localhost', port=6379, db=0)
|
||||
redis.flushall()
|
||||
while True:
|
||||
|
@ -38,12 +34,7 @@ def update_cache():
|
|||
redis.set('tecmap_data', pickle.dumps(parsed_data))
|
||||
logging.info('Scrape complete')
|
||||
time.sleep(1800) # 30 minutes
|
||||
except:
|
||||
logging.critical(traceback.format_exc())
|
||||
os.kill(os.getpid(), signal.SIGKILL)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
threading.Thread(target=update_cache).start()
|
||||
while True:
|
||||
time.sleep(3600)
|
||||
main()
|
||||
|
|
|
@ -22,7 +22,6 @@ LON_RANGE_MAX = 180
|
|||
def main():
|
||||
redis = Redis(host='localhost', port=6379, db=0)
|
||||
|
||||
while True:
|
||||
utc_hr = datetime.utcnow().hour
|
||||
logging.info(f'Generating plot for hour {utc_hr}')
|
||||
|
||||
|
@ -34,7 +33,6 @@ def main():
|
|||
for tecmap, epoch in ionex_data:
|
||||
if epoch.hour == utc_hr:
|
||||
plt = plot_tec_map(tecmap, [float(LON_RANGE_MIN), float(LON_RANGE_MAX)], [float(LAT_RANGE_MIN), float(LAT_RANGE_MAX)], timestamp=epoch)[1]
|
||||
|
||||
buf = io.BytesIO()
|
||||
plt.savefig(buf, format='png', bbox_inches='tight', pad_inches=0, dpi=110)
|
||||
plt.close()
|
||||
|
@ -47,11 +45,12 @@ def main():
|
|||
|
||||
redis.set('global_map', buf.getvalue())
|
||||
buf.close()
|
||||
logging.info(f'Finished hour {utc_hr}')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
schedule.every().hour.at(":00").do(main)
|
||||
schedule.every().hour.at(':00').do(main)
|
||||
while True:
|
||||
schedule.run_pending()
|
||||
time.sleep(1)
|
||||
|
|
Loading…
Reference in New Issue