Fix a bug where the software would crash on startup if GMA API key was not provided. #112

This commit is contained in:
Ian Renton
2026-06-21 11:07:17 +01:00
parent 316a356811
commit 96e2b0ce8b
9 changed files with 21 additions and 19 deletions

View File

@@ -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