From f8032973cac05548cd86ed6c93e5cc987f3b0c7a Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Sun, 16 Aug 2026 09:26:05 +0100 Subject: [PATCH] Error handling improvements --- core/utils.py | 2 +- .../file_download_callsign_data_provider.py | 3 +-- providers/callsigndata/hamqth.py | 2 +- providers/callsigndata/qrz.py | 2 +- .../sigrefdata/file_download_sig_ref_data_provider.py | 3 +-- providers/spot/http_spot_provider.py | 3 +-- providers/spot/sse_spot_provider.py | 5 ++++- .../staticdata/file_download_static_data_provider.py | 3 +-- 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 +- 16 files changed, 26 insertions(+), 27 deletions(-) diff --git a/core/utils.py b/core/utils.py index 70c0744..607d3c5 100644 --- a/core/utils.py +++ b/core/utils.py @@ -48,7 +48,7 @@ def infer_mode_type_from_mode(mode): elif mode.upper() in DATA_MODES: return "DATA" else: - if mode.upper() != "OTHER": + if mode.upper() != "OTHER" and mode != "?": logger.warning(f"Found an unrecognised mode: {mode}. Developer should categorise this.") return None diff --git a/providers/callsigndata/file_download_callsign_data_provider.py b/providers/callsigndata/file_download_callsign_data_provider.py index 8b9a311..7a7a31d 100644 --- a/providers/callsigndata/file_download_callsign_data_provider.py +++ b/providers/callsigndata/file_download_callsign_data_provider.py @@ -3,8 +3,7 @@ from datetime import datetime from threading import Event, Thread import pytz -from requests import ReadTimeout -from requests.exceptions import ConnectionError, ConnectTimeout +from requests.exceptions import ConnectionError, ConnectTimeout, ReadTimeout from core.constants import HTTP_HEADERS from core.url_data_cache import URLDataCache diff --git a/providers/callsigndata/hamqth.py b/providers/callsigndata/hamqth.py index 33366b7..f99e762 100644 --- a/providers/callsigndata/hamqth.py +++ b/providers/callsigndata/hamqth.py @@ -5,7 +5,7 @@ from datetime import datetime, timedelta import pytz import xmltodict from pyhamtools import callinfo -from requests import ConnectTimeout, ReadTimeout +from requests.exceptions import ConnectionError, ConnectTimeout, ReadTimeout from requests_cache import CachedSession from core.config import SERVER_OWNER_CALLSIGN diff --git a/providers/callsigndata/qrz.py b/providers/callsigndata/qrz.py index 8243136..1332973 100644 --- a/providers/callsigndata/qrz.py +++ b/providers/callsigndata/qrz.py @@ -5,7 +5,7 @@ from datetime import datetime, timedelta import pytz import xmltodict from pyhamtools import callinfo -from requests import ConnectTimeout, ReadTimeout +from requests.exceptions import ConnectionError, ConnectTimeout, ReadTimeout from requests_cache import CachedSession from core.constants import HTTP_HEADERS diff --git a/providers/sigrefdata/file_download_sig_ref_data_provider.py b/providers/sigrefdata/file_download_sig_ref_data_provider.py index 53cd3f9..92369d7 100644 --- a/providers/sigrefdata/file_download_sig_ref_data_provider.py +++ b/providers/sigrefdata/file_download_sig_ref_data_provider.py @@ -3,8 +3,7 @@ from datetime import datetime from threading import Event, Thread import pytz -from requests import ReadTimeout -from requests.exceptions import ConnectionError, ConnectTimeout +from requests.exceptions import ConnectionError, ConnectTimeout, ReadTimeout from core.constants import HTTP_HEADERS from core.url_data_cache import URLDataCache diff --git a/providers/spot/http_spot_provider.py b/providers/spot/http_spot_provider.py index ef44066..14b4fa4 100644 --- a/providers/spot/http_spot_provider.py +++ b/providers/spot/http_spot_provider.py @@ -4,8 +4,7 @@ from threading import Event, Thread import pytz import requests -from requests import ReadTimeout -from requests.exceptions import ConnectionError, ConnectTimeout +from requests.exceptions import ConnectionError, ConnectTimeout, ReadTimeout from core.constants import HTTP_HEADERS from providers.spot.spot_provider import SpotProvider diff --git a/providers/spot/sse_spot_provider.py b/providers/spot/sse_spot_provider.py index 4edddc3..5697ba3 100644 --- a/providers/spot/sse_spot_provider.py +++ b/providers/spot/sse_spot_provider.py @@ -3,7 +3,7 @@ from datetime import datetime from threading import Event, Lock, Thread import pytz -from requests_sse import EventSource +from requests_sse import EventSource, InvalidStatusCodeError from core.constants import HTTP_HEADERS from providers.spot.spot_provider import SpotProvider @@ -89,6 +89,9 @@ class SSESpotProvider(SpotProvider): logger.exception( f"Exception processing message from SSE Spot Provider ({self.name})" ) + except InvalidStatusCodeError as e: + self.status = "Error" + logger.exception(f"HTTP {e.status_code} returned from SSE Spot Provider ({self.name}).") finally: self._set_event_source(None) diff --git a/providers/staticdata/file_download_static_data_provider.py b/providers/staticdata/file_download_static_data_provider.py index f31aa4c..44a26a3 100644 --- a/providers/staticdata/file_download_static_data_provider.py +++ b/providers/staticdata/file_download_static_data_provider.py @@ -3,8 +3,7 @@ from datetime import datetime from threading import Event, Thread import pytz -from requests import ReadTimeout -from requests.exceptions import ConnectionError, ConnectTimeout +from requests.exceptions import ConnectionError, ConnectTimeout, ReadTimeout from core.constants import HTTP_HEADERS from core.url_data_cache import URLDataCache diff --git a/templates/add_spot.html b/templates/add_spot.html index 13f3d11..e30ecb2 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 61b5238..5ac6a0a 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -84,7 +84,7 @@ - + diff --git a/templates/bands.html b/templates/bands.html index 3c0f0d7..6497044 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -76,8 +76,8 @@ - - + + diff --git a/templates/base.html b/templates/base.html index 794fb28..4b8b140 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,6 +1,6 @@ {% extends "skeleton.html" %} {% block head_extra %} - + @@ -15,10 +15,10 @@ window.fetchEventSource = fetchEventSource; - - - - + + + + {% end %} {% block body %}
diff --git a/templates/conditions.html b/templates/conditions.html index 5eb9f07..0646d4b 100644 --- a/templates/conditions.html +++ b/templates/conditions.html @@ -284,7 +284,7 @@
- + diff --git a/templates/map.html b/templates/map.html index 3da528a..1eaf289 100644 --- a/templates/map.html +++ b/templates/map.html @@ -109,8 +109,8 @@ - - + + diff --git a/templates/spots.html b/templates/spots.html index 9008641..5997d55 100644 --- a/templates/spots.html +++ b/templates/spots.html @@ -113,8 +113,8 @@ - - + + diff --git a/templates/status.html b/templates/status.html index c0b9221..ad3d870 100644 --- a/templates/status.html +++ b/templates/status.html @@ -86,7 +86,7 @@ - +