Files
spothole/providers/solarconditions/solar_conditions_provider.py
T
Ian Renton 5c86346074 Merge branch 'main' into 2.0-pre
# Conflicts:
#	core/config.py
#	core/status_reporter.py
#	server/handlers/api/options.py
#	static/js/bands.js
#	static/js/map.js
#	static/js/spots.js
#	templates/status.html
2026-08-10 18:34:32 +01:00

39 lines
1.3 KiB
Python

from datetime import datetime
import pytz
from core.data_store import DATA_STORE
class SolarConditionsProvider:
"""Generic solar conditions provider class. Subclasses of this query individual APIs for space weather and
propagation data."""
def __init__(self, name, provider_config):
"""Constructor"""
self.name = name
self.enabled = provider_config.get("enabled", True)
self.last_update_time = datetime.min.replace(tzinfo=pytz.UTC)
self.status = "Not Started" if self.enabled else "Disabled"
self._solar_conditions = DATA_STORE.solar_conditions
def start(self):
"""Start the provider. This should return immediately after spawning threads to access the remote resources"""
raise NotImplementedError("Subclasses must implement this method")
def stop(self):
"""Stop any threads and prepare for application shutdown"""
raise NotImplementedError("Subclasses must implement this method")
def update_data(self, new_data):
"""Update the solar conditions object with new data"""
if new_data:
for key, value in new_data.items():
if hasattr(self._solar_conditions, key):
setattr(self._solar_conditions, key, value)
self._solar_conditions.infer_descriptions()