From ab86bdc4d6776faa8c102b9cf4c531e3114d054a Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Fri, 4 Sep 2026 17:50:35 +0100 Subject: [PATCH] Improve error handling and PWA manifest --- core/enums.py | 7 +++++-- core/utils.py | 5 ++++- data/alert.py | 4 ++-- data/spot.py | 4 ++-- providers/alert/parksnpeaks.py | 1 + providers/callsigndata/hamqth.py | 2 +- providers/callsigndata/qrz.py | 2 +- templates/add_spot.html | 2 +- templates/alerts.html | 2 +- templates/bands.html | 4 ++-- templates/base.html | 10 +++++----- templates/conditions.html | 2 +- templates/manifest.webmanifest | 4 ++-- templates/map.html | 4 ++-- templates/spots.html | 4 ++-- templates/status.html | 2 +- 16 files changed, 33 insertions(+), 26 deletions(-) diff --git a/core/enums.py b/core/enums.py index 17b4016..75594cb 100644 --- a/core/enums.py +++ b/core/enums.py @@ -48,12 +48,15 @@ class Mode(str, Enum): def from_name(name): """Convert a string to an enum mode using the alias table.""" + if not name: + return Mode.UNKNOWN + try: return Mode(name.upper()) - except ValueError: + except (KeyError, ValueError): try: return Mode(MODE_ALIASES[name.upper()]) - except ValueError: + except (KeyError, ValueError): return Mode.UNKNOWN diff --git a/core/utils.py b/core/utils.py index 204b251..c76930f 100644 --- a/core/utils.py +++ b/core/utils.py @@ -42,6 +42,9 @@ def infer_mode_type_from_mode(mode: str) -> ModeType: if not mode: return ModeType.UNKNOWN + if mode in MODE_ALIASES: + mode = MODE_ALIASES[mode] + try: mode = Mode(mode.upper()) if mode.is_cw: @@ -118,7 +121,7 @@ def get_callsign_object_from_pyhamtools_callinfo(callsign, callinfo): country = data.get("country", None) dxcc_id = data.get("adif", None) - continent = Continent(data.get("continent", None)) + continent = Continent(data["continent"]) if "continent" in data else None cq_zone = data.get("cqz", None) itu_zone = data.get("ituz", None) lat = float(data["latitude"]) if "latitude" in data else None diff --git a/data/alert.py b/data/alert.py index ecdb0b0..a4e923e 100644 --- a/data/alert.py +++ b/data/alert.py @@ -92,8 +92,8 @@ class Alert: call_info = get_call_info(self.dx_calls[0], credentials) if self.dx_calls and self.dx_calls[0] and not self.dx_country: self.dx_country = call_info.country - if self.dx_calls and self.dx_calls[0] and not self.dx_continent: - self.dx_continent = Continent(call_info.continent) if call_info.continent else None + if self.dx_calls and self.dx_calls[0] and call_info.continent and not self.dx_continent: + self.dx_continent = Continent(call_info.continent) if self.dx_calls and self.dx_calls[0] and not self.dx_cq_zone: self.dx_cq_zone = call_info.cq_zone if self.dx_calls and self.dx_calls[0] and not self.dx_itu_zone: diff --git a/data/spot.py b/data/spot.py index 173c556..f52c26a 100644 --- a/data/spot.py +++ b/data/spot.py @@ -184,7 +184,7 @@ class Spot: dx_call_info = get_call_info(self.dx_call, credentials) if self.dx_call and not self.dx_country: self.dx_country = dx_call_info.country - if self.dx_call and not self.dx_continent: + if self.dx_call and dx_call_info.continent and not self.dx_continent: self.dx_continent = Continent(dx_call_info.continent) if self.dx_call and not self.dx_dxcc_id: self.dx_dxcc_id = dx_call_info.dxcc_id @@ -222,7 +222,7 @@ class Spot: ): if not self.de_country: self.de_country = de_call_info.country - if not self.de_continent: + if de_call_info.continent and not self.de_continent: self.de_continent = Continent(de_call_info.continent) if not self.de_dxcc_id: self.de_dxcc_id = de_call_info.dxcc_id diff --git a/providers/alert/parksnpeaks.py b/providers/alert/parksnpeaks.py index 1b8d335..1323470 100644 --- a/providers/alert/parksnpeaks.py +++ b/providers/alert/parksnpeaks.py @@ -59,6 +59,7 @@ class ParksNPeaks(HTTPAlertProvider): "POTA", "SOTA", "WWFF", + "HEMA", "SIOTA", "ZLOTA", "KRMNPA", diff --git a/providers/callsigndata/hamqth.py b/providers/callsigndata/hamqth.py index 77ccd9e..bfe567e 100644 --- a/providers/callsigndata/hamqth.py +++ b/providers/callsigndata/hamqth.py @@ -143,7 +143,7 @@ class HamQTH(APIQueryCallsignDataProvider): name=data.get("nick", None), qth=data.get("qth", None), country=data.get("country", None), - continent=Continent(data.get("continent", None)), + continent=Continent(data["continent"]) if "continent" in data else None, latitude=lat, longitude=lon, grid=grid, diff --git a/providers/callsigndata/qrz.py b/providers/callsigndata/qrz.py index c413bed..4ed570c 100644 --- a/providers/callsigndata/qrz.py +++ b/providers/callsigndata/qrz.py @@ -169,7 +169,7 @@ class QRZ(APIQueryCallsignDataProvider): name=name, qth=data.get("addr2", None), country=data.get("country", None), - continent=Continent(data.get("continent", None)), + continent=Continent(data["continent"]) if "continent" in data else None, latitude=lat, longitude=lon, grid=grid, diff --git a/templates/add_spot.html b/templates/add_spot.html index 18bd382..4d1384d 100644 --- a/templates/add_spot.html +++ b/templates/add_spot.html @@ -77,7 +77,7 @@ - + diff --git a/templates/alerts.html b/templates/alerts.html index e9fed46..f452526 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -84,7 +84,7 @@ - + diff --git a/templates/bands.html b/templates/bands.html index d408b8e..8b63d4f 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -76,8 +76,8 @@ - - + + diff --git a/templates/base.html b/templates/base.html index f1bc96a..b87f82c 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,6 +1,6 @@ {% extends "skeleton.html" %} {% block head_extra %} - + @@ -16,10 +16,10 @@ window.fetchEventSource = fetchEventSource; - - - - + + + + {% end %} {% block body %}
diff --git a/templates/conditions.html b/templates/conditions.html index 550ce64..1099496 100644 --- a/templates/conditions.html +++ b/templates/conditions.html @@ -284,7 +284,7 @@
- + diff --git a/templates/manifest.webmanifest b/templates/manifest.webmanifest index 1d07df2..c7e0298 100644 --- a/templates/manifest.webmanifest +++ b/templates/manifest.webmanifest @@ -16,13 +16,13 @@ "src": "/static/img/icon-192-pwa.png", "type": "image/png", "sizes": "192x192", - "purpose": "maskable" + "purpose": "maskable any" }, { "src": "/static/img/icon-512-pwa.png", "type": "image/png", "sizes": "512x512", - "purpose": "maskable" + "purpose": "maskable any" } ], "url": "{{ baseurl }}" diff --git a/templates/map.html b/templates/map.html index 6189224..f416fd3 100644 --- a/templates/map.html +++ b/templates/map.html @@ -113,8 +113,8 @@ const CARTODB_API_KEY = "{{ web_ui_options.get('cartodb_api_key', '') }}"; - - + + diff --git a/templates/spots.html b/templates/spots.html index 8953016..7cb4b23 100644 --- a/templates/spots.html +++ b/templates/spots.html @@ -113,8 +113,8 @@ - - + + diff --git a/templates/status.html b/templates/status.html index 67a8bd5..cafc681 100644 --- a/templates/status.html +++ b/templates/status.html @@ -86,7 +86,7 @@ - +