mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-08-06 02:21:42 +00:00
Improve error handling to spare the server log from user's malformed requests and stop trying to parse data from providers if the HTTP status was not 200
This commit is contained in:
@@ -44,9 +44,9 @@ class KC2GProp(SolarConditionsProvider):
|
||||
def _poll(self):
|
||||
try:
|
||||
logging.debug("Polling KC2G ionosonde data...")
|
||||
response = requests.get(KC2G_URL, headers=HTTP_HEADERS, timeout=(5, 30))
|
||||
if response.status_code != 200:
|
||||
logging.warning(f"KC2G ionosonde API returned HTTP {response.status_code}")
|
||||
http_response = requests.get(KC2G_URL, headers=HTTP_HEADERS, timeout=(5, 30))
|
||||
if http_response.status_code != 200:
|
||||
logging.warning(f"KC2G ionosonde API returned HTTP {http_response.status_code}")
|
||||
return
|
||||
|
||||
now = datetime.now(timezone.utc)
|
||||
@@ -57,7 +57,7 @@ class KC2GProp(SolarConditionsProvider):
|
||||
ionosonde_data = dict(self._solar_conditions.ionosonde_data or {})
|
||||
updated_count = 0
|
||||
|
||||
for reading in response.json():
|
||||
for reading in http_response.json():
|
||||
station = reading.get("station", {})
|
||||
ursi = station.get("code")
|
||||
name = station.get("name")
|
||||
|
||||
Reference in New Issue
Block a user