Fix exception when SOTA summit doesn't exist

This commit is contained in:
Ian Renton
2025-10-12 17:52:19 +01:00
parent 57764a46b4
commit 5da3412917

View File

@@ -1,3 +1,4 @@
import logging
from datetime import datetime, timedelta from datetime import datetime, timedelta
import requests import requests
@@ -53,10 +54,14 @@ class SOTA(HTTPSpotProvider):
activation_score=source_spot["points"]) activation_score=source_spot["points"])
# SOTA doesn't give summit lat/lon/grid in the main call, so we need another separate call for this # SOTA doesn't give summit lat/lon/grid in the main call, so we need another separate call for this
summit_data = self.SUMMIT_DATA_CACHE.get(self.SUMMIT_URL_ROOT + source_spot["summitCode"], headers=self.HTTP_HEADERS).json() try:
spot.grid = summit_data["locator"] summit_response = self.SUMMIT_DATA_CACHE.get(self.SUMMIT_URL_ROOT + source_spot["summitCode"], headers=self.HTTP_HEADERS)
spot.latitude = summit_data["latitude"] summit_data = summit_response.json()
spot.longitude = summit_data["longitude"] spot.grid = summit_data["locator"]
spot.latitude = summit_data["latitude"]
spot.longitude = summit_data["longitude"]
except Exception:
logging.warn("Looking up summit " + source_spot["summitCode"] + " from the SOTA API failed. No summit data was available.")
# Add to our list. Don't worry about de-duping, removing old spots etc. at this point; other code will do # Add to our list. Don't worry about de-duping, removing old spots etc. at this point; other code will do
# that for us. # that for us.