mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-06-24 05:35:10 +00:00
Use diskcache to store solar_conditions object
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
<p>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.</p>
|
||||
</div>
|
||||
|
||||
<script src="/js/common.js?v=1778924234"></script>
|
||||
<script src="/js/common.js?v=1778924254"></script>
|
||||
<script>$(document).ready(function() { $("#nav-link-about").addClass("active"); }); <!-- highlight active page in nav --></script>
|
||||
|
||||
{% end %}
|
||||
@@ -69,8 +69,8 @@
|
||||
|
||||
</div>
|
||||
|
||||
<script src="/js/common.js?v=1778924234"></script>
|
||||
<script src="/js/add-spot.js?v=1778924234"></script>
|
||||
<script src="/js/common.js?v=1778924254"></script>
|
||||
<script src="/js/add-spot.js?v=1778924254"></script>
|
||||
<script>$(document).ready(function() { $("#nav-link-add-spot").addClass("active"); }); <!-- highlight active page in nav --></script>
|
||||
|
||||
{% end %}
|
||||
@@ -70,8 +70,8 @@
|
||||
|
||||
</div>
|
||||
|
||||
<script src="/js/common.js?v=1778924234"></script>
|
||||
<script src="/js/alerts.js?v=1778924234"></script>
|
||||
<script src="/js/common.js?v=1778924255"></script>
|
||||
<script src="/js/alerts.js?v=1778924255"></script>
|
||||
<script>$(document).ready(function() { $("#nav-link-alerts").addClass("active"); }); <!-- highlight active page in nav --></script>
|
||||
|
||||
{% end %}
|
||||
@@ -76,9 +76,9 @@
|
||||
<script>
|
||||
let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %};
|
||||
</script>
|
||||
<script src="/js/common.js?v=1778924234"></script>
|
||||
<script src="/js/spotsbandsandmap.js?v=1778924234"></script>
|
||||
<script src="/js/bands.js?v=1778924234"></script>
|
||||
<script src="/js/common.js?v=1778924254"></script>
|
||||
<script src="/js/spotsbandsandmap.js?v=1778924254"></script>
|
||||
<script src="/js/bands.js?v=1778924254"></script>
|
||||
<script>$(document).ready(function() { $("#nav-link-bands").addClass("active"); }); <!-- highlight active page in nav --></script>
|
||||
|
||||
{% end %}
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
<title>Spothole</title>
|
||||
|
||||
<link rel="stylesheet" href="/css/style.css?v=1778924234" type="text/css">
|
||||
<link rel="stylesheet" href="/css/style.css?v=1778924254" type="text/css">
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.8/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||
integrity="sha384-sRIl4kxILFvY47J16cr9ZwB07vP4J8+LH7qKQnuqkuIAvNWLzeN8tE5YBujZqJLB" crossorigin="anonymous">
|
||||
<link href="/fa/css/fontawesome.min.css" rel="stylesheet" />
|
||||
@@ -52,9 +52,9 @@
|
||||
integrity="sha384-L1eE4eD41kpBIWe2I0eHy+GnEUC4RIpcvibVW2JCminuPlTl+2Bc528iPdVMg5Dn"
|
||||
crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://misc.ianrenton.com/jsutils/utils.js?v=1778924234"></script>
|
||||
<script src="https://misc.ianrenton.com/jsutils/ui-ham.js?v=1778924234"></script>
|
||||
<script src="https://misc.ianrenton.com/jsutils/geo.js?v=1778924234"></script>
|
||||
<script src="https://misc.ianrenton.com/jsutils/utils.js?v=1778924254"></script>
|
||||
<script src="https://misc.ianrenton.com/jsutils/ui-ham.js?v=1778924254"></script>
|
||||
<script src="https://misc.ianrenton.com/jsutils/geo.js?v=1778924254"></script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -249,8 +249,8 @@
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.9/dist/chart.umd.min.js"></script>
|
||||
<script src="/js/common.js?v=1778924234"></script>
|
||||
<script src="/js/conditions.js?v=1778924234"></script>
|
||||
<script src="/js/common.js?v=1778924254"></script>
|
||||
<script src="/js/conditions.js?v=1778924254"></script>
|
||||
<script>$(document).ready(function () {
|
||||
$("#nav-link-conditions").addClass("active");
|
||||
}); <!-- highlight active page in nav --></script>
|
||||
|
||||
@@ -94,9 +94,9 @@
|
||||
<script>
|
||||
let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %};
|
||||
</script>
|
||||
<script src="/js/common.js?v=1778924234"></script>
|
||||
<script src="/js/spotsbandsandmap.js?v=1778924234"></script>
|
||||
<script src="/js/map.js?v=1778924234"></script>
|
||||
<script src="/js/common.js?v=1778924255"></script>
|
||||
<script src="/js/spotsbandsandmap.js?v=1778924255"></script>
|
||||
<script src="/js/map.js?v=1778924255"></script>
|
||||
<script>$(document).ready(function() { $("#nav-link-map").addClass("active"); }); <!-- highlight active page in nav --></script>
|
||||
|
||||
{% end %}
|
||||
@@ -104,9 +104,9 @@
|
||||
<script>
|
||||
let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %};
|
||||
</script>
|
||||
<script src="/js/common.js?v=1778924233"></script>
|
||||
<script src="/js/spotsbandsandmap.js?v=1778924233"></script>
|
||||
<script src="/js/spots.js?v=1778924233"></script>
|
||||
<script src="/js/common.js?v=1778924254"></script>
|
||||
<script src="/js/spotsbandsandmap.js?v=1778924254"></script>
|
||||
<script src="/js/spots.js?v=1778924254"></script>
|
||||
<script>$(document).ready(function() { $("#nav-link-spots").addClass("active"); }); <!-- highlight active page in nav --></script>
|
||||
|
||||
{% end %}
|
||||
@@ -59,8 +59,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/js/common.js?v=1778924234"></script>
|
||||
<script src="/js/status.js?v=1778924234"></script>
|
||||
<script src="/js/common.js?v=1778924254"></script>
|
||||
<script src="/js/status.js?v=1778924254"></script>
|
||||
<script>
|
||||
$(document).ready(function() { $("#nav-link-status").addClass("active"); }); <!-- highlight active page in nav -->
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user