From 6058eb5053df595bf9c601a856a19c12aee6e663 Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Sat, 16 May 2026 10:37:34 +0100 Subject: [PATCH] Use diskcache to store solar_conditions object --- solarconditionsproviders/solar_conditions_provider.py | 6 ++++-- spothole.py | 6 ++++-- templates/about.html | 2 +- templates/add_spot.html | 4 ++-- templates/alerts.html | 4 ++-- templates/bands.html | 6 +++--- templates/base.html | 8 ++++---- templates/conditions.html | 4 ++-- templates/map.html | 6 +++--- templates/spots.html | 6 +++--- templates/status.html | 4 ++-- 11 files changed, 30 insertions(+), 26 deletions(-) diff --git a/solarconditionsproviders/solar_conditions_provider.py b/solarconditionsproviders/solar_conditions_provider.py index 364625b..7479456 100644 --- a/solarconditionsproviders/solar_conditions_provider.py +++ b/solarconditionsproviders/solar_conditions_provider.py @@ -16,10 +16,11 @@ class SolarConditionsProvider: self.status = "Not Started" if self.enabled else "Disabled" self._solar_conditions = None - def setup(self, solar_conditions): - """Set up the provider, giving it the solar conditions dict to update""" + def setup(self, solar_conditions, solar_conditions_cache): + """Set up the provider, giving it the solar conditions object and its backing cache""" self._solar_conditions = solar_conditions + self._solar_conditions_cache = solar_conditions_cache def start(self): """Start the provider. This should return immediately after spawning threads to access the remote resources""" @@ -39,3 +40,4 @@ class SolarConditionsProvider: if hasattr(self._solar_conditions, key): setattr(self._solar_conditions, key, value) self._solar_conditions.infer_descriptions() + self._solar_conditions_cache['solar_conditions'] = self._solar_conditions diff --git a/spothole.py b/spothole.py index 4e917ce..30b6b4e 100644 --- a/spothole.py +++ b/spothole.py @@ -18,7 +18,8 @@ from server.webserver import WebServer # Globals spots = Cache('cache/spots_cache') alerts = Cache('cache/alerts_cache') -solar_conditions = SolarConditions() +solar_conditions_cache = Cache('cache/solar_conditions_cache') +solar_conditions = solar_conditions_cache.get('solar_conditions', SolarConditions()) web_server = None status_data = {} spot_providers = [] @@ -48,6 +49,7 @@ def shutdown(sig, frame): lookup_helper.stop() spots.close() alerts.close() + solar_conditions_cache.close() os._exit(0) @@ -120,7 +122,7 @@ if __name__ == '__main__': for entry in config.get("solar-condition-providers", []): solar_condition_providers.append(get_solar_conditions_provider_from_config(entry)) for p in solar_condition_providers: - p.setup(solar_conditions=solar_conditions) + p.setup(solar_conditions=solar_conditions, solar_conditions_cache=solar_conditions_cache) if p.enabled: p.start() diff --git a/templates/about.html b/templates/about.html index 039c098..4f95d0d 100644 --- a/templates/about.html +++ b/templates/about.html @@ -69,7 +69,7 @@

This software is dedicated to the memory of Tom G1PJB, SK, a friend and colleague who sadly passed away around the time I started writing it in Autumn 2025. I was looking forward to showing it to you when it was done.

- + {% end %} \ No newline at end of file diff --git a/templates/add_spot.html b/templates/add_spot.html index afaff68..3c18416 100644 --- a/templates/add_spot.html +++ b/templates/add_spot.html @@ -69,8 +69,8 @@ - - + + {% end %} \ No newline at end of file diff --git a/templates/alerts.html b/templates/alerts.html index 1ebace6..ed836f1 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -70,8 +70,8 @@ - - + + {% end %} \ No newline at end of file diff --git a/templates/bands.html b/templates/bands.html index 3b14bb7..eba8349 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -76,9 +76,9 @@ - - - + + + {% end %} \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index fe4bdde..e4b9506 100644 --- a/templates/base.html +++ b/templates/base.html @@ -24,7 +24,7 @@ Spothole - + @@ -52,9 +52,9 @@ integrity="sha384-L1eE4eD41kpBIWe2I0eHy+GnEUC4RIpcvibVW2JCminuPlTl+2Bc528iPdVMg5Dn" crossorigin="anonymous"> - - - + + + diff --git a/templates/conditions.html b/templates/conditions.html index 62f11ce..1a55dda 100644 --- a/templates/conditions.html +++ b/templates/conditions.html @@ -249,8 +249,8 @@ - - + + diff --git a/templates/map.html b/templates/map.html index 62aa4ea..0e430bb 100644 --- a/templates/map.html +++ b/templates/map.html @@ -94,9 +94,9 @@ - - - + + + {% end %} \ No newline at end of file diff --git a/templates/spots.html b/templates/spots.html index 42b80b2..451b551 100644 --- a/templates/spots.html +++ b/templates/spots.html @@ -104,9 +104,9 @@ - - - + + + {% end %} \ No newline at end of file diff --git a/templates/status.html b/templates/status.html index b424407..f2ad850 100644 --- a/templates/status.html +++ b/templates/status.html @@ -59,8 +59,8 @@ - - + +