From 96e2b0ce8b253928e9db05896bcb721a32583ecc Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Sun, 21 Jun 2026 11:07:17 +0100 Subject: [PATCH] Fix a bug where the software would crash on startup if GMA API key was not provided. #112 --- spotproviders/gma.py | 10 ++++++---- templates/add_spot.html | 2 +- templates/alerts.html | 2 +- templates/bands.html | 4 ++-- templates/base.html | 10 +++++----- templates/conditions.html | 2 +- templates/map.html | 4 ++-- templates/spots.html | 4 ++-- templates/status.html | 2 +- 9 files changed, 21 insertions(+), 19 deletions(-) diff --git a/spotproviders/gma.py b/spotproviders/gma.py index 6cc8481..b646c36 100644 --- a/spotproviders/gma.py +++ b/spotproviders/gma.py @@ -19,13 +19,15 @@ class GMA(HTTPSpotProvider): REF_INFO_URL_ROOT = "https://www.cqgma.org/api/ref/?" def __init__(self, provider_config): - # Ensure there is an API key in our config, and set up the query URL using it + # Ensure there is an API key in our config, and set up the query URL using it. If no key is provided, + # disable this spot provider. self.api_key = provider_config.get("api-key", "") - if self.api_key != "": - super().__init__(provider_config, self.SPOTS_URL + "?key=" + self.api_key, self.POLL_INTERVAL_SEC) - else: + if self.api_key == "": + provider_config["enabled"] = False logging.warning("GMA spot provider configured but no api key was provided, this API will not be queried.") + super().__init__(provider_config, self.SPOTS_URL + "?key=" + self.api_key, self.POLL_INTERVAL_SEC) + def _http_response_to_spots(self, http_response): new_spots = [] # Iterate through source data diff --git a/templates/add_spot.html b/templates/add_spot.html index fa4ddc4..f037c23 100644 --- a/templates/add_spot.html +++ b/templates/add_spot.html @@ -76,7 +76,7 @@ - + diff --git a/templates/alerts.html b/templates/alerts.html index a019df2..1b0cfa5 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -75,7 +75,7 @@ - + diff --git a/templates/bands.html b/templates/bands.html index 600bf17..21577d0 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -77,8 +77,8 @@ - - + + diff --git a/templates/base.html b/templates/base.html index 745727e..4537825 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,6 +1,6 @@ {% extends "skeleton.html" %} {% block head_extra %} - + @@ -10,10 +10,10 @@ - - - - + + + + {% end %} {% block body %}
diff --git a/templates/conditions.html b/templates/conditions.html index 19ad0b1..bc4edc2 100644 --- a/templates/conditions.html +++ b/templates/conditions.html @@ -284,7 +284,7 @@
- + diff --git a/templates/map.html b/templates/map.html index 5759bbd..4dd5c21 100644 --- a/templates/map.html +++ b/templates/map.html @@ -95,8 +95,8 @@ - - + + diff --git a/templates/spots.html b/templates/spots.html index 697c36c..645d1ee 100644 --- a/templates/spots.html +++ b/templates/spots.html @@ -116,8 +116,8 @@ - - + + diff --git a/templates/status.html b/templates/status.html index 0b95a4a..8326fc0 100644 --- a/templates/status.html +++ b/templates/status.html @@ -59,7 +59,7 @@ - +