From 64bb8ef3eb6c79547d97299077127da9cf12f906 Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Fri, 11 Sep 2026 07:32:15 +0100 Subject: [PATCH] Fix a potential NPE and a case where callsign location source could be reported as None instead of DXCC. --- core/enums.py | 3 --- core/sig_lookup_helper.py | 5 +++-- data/callsign.py | 2 +- data/spot.py | 4 ++-- 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 +- 12 files changed, 21 insertions(+), 23 deletions(-) diff --git a/core/enums.py b/core/enums.py index 48e139b..770be24 100644 --- a/core/enums.py +++ b/core/enums.py @@ -71,7 +71,6 @@ class ModeSource(str, Enum): SPOT = "SPOT" COMMENT = "COMMENT" BANDPLAN = "BANDPLAN" - NONE = "NONE" class LocationSourceForSpot(str, Enum): @@ -82,7 +81,6 @@ class LocationSourceForSpot(str, Enum): GRID = "GRID" HOME_QTH = "HOME QTH" DXCC = "DXCC" - NONE = "NONE" class LocationSourceForCallsign(str, Enum): @@ -90,7 +88,6 @@ class LocationSourceForCallsign(str, Enum): HOME_QTH = "HOME QTH" DXCC = "DXCC" - NONE = "NONE" class SIGRefType(str, Enum): diff --git a/core/sig_lookup_helper.py b/core/sig_lookup_helper.py index 6d818bf..aebfcd0 100644 --- a/core/sig_lookup_helper.py +++ b/core/sig_lookup_helper.py @@ -43,8 +43,9 @@ def get_sig_ref_info(sig_name, ref_id): # database. if sig_name.upper() == "DME": match = re.match(r"DME[\- ](\d{3,5})", ref_id, re.IGNORECASE) - number = match.group(1) - ref_id = f"DME-{number.zfill(5)}" + if match: + number = match.group(1) + ref_id = f"DME-{number.zfill(5)}" # DTMBA spotters sometimes include spaces and dashes, our regex allows them but they must be removed here so we # can look up against the official list which doesn't have them diff --git a/data/callsign.py b/data/callsign.py index b7f6a44..83b4950 100644 --- a/data/callsign.py +++ b/data/callsign.py @@ -38,7 +38,7 @@ class Callsign: # ITU zone in which the callsign indicates they are operating itu_zone: int | None = None # Location source - location_source: LocationSourceForCallsign = LocationSourceForCallsign.NONE + location_source: LocationSourceForCallsign | None = None def fully_populated(self): """Utility method to indicate that the callsign data is fully populated. Multiple providers can return data for diff --git a/data/spot.py b/data/spot.py index 8fd869d..0380916 100644 --- a/data/spot.py +++ b/data/spot.py @@ -70,7 +70,7 @@ class Spot: dx_latitude: float | None = None dx_longitude: float | None = None # DX Location source. Indicates how accurate the location might be. - dx_location_source: LocationSourceForSpot = LocationSourceForSpot.NONE + dx_location_source: LocationSourceForSpot | None = None # DX Location good. Indicates that the software thinks the location data is good enough to plot on a map. This is # true if the location source is "SPOT", "SIG REF LOOKUP" or "GRID", or if the location source is "HOME QTH" and the # DX callsign doesn't have a suffix like /P. @@ -107,7 +107,7 @@ class Spot: # Inferred mode "family". mode_type: ModeType | None = None # Source of the mode information. - mode_source: ModeSource = ModeSource.NONE + mode_source: ModeSource | None = None # Frequency, in Hz freq: float | None = None # Band, defined by the frequency, e.g. "40m" or "70cm" diff --git a/templates/add_spot.html b/templates/add_spot.html index 66824c6..7316e43 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 e3bd50d..7ef5c42 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -83,7 +83,7 @@ - + diff --git a/templates/bands.html b/templates/bands.html index dbca34b..c4e76a9 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -76,8 +76,8 @@ - - + + diff --git a/templates/base.html b/templates/base.html index af3fd66..a7f180a 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 4a79176..84f97f1 100644 --- a/templates/conditions.html +++ b/templates/conditions.html @@ -284,7 +284,7 @@
- + diff --git a/templates/map.html b/templates/map.html index fc7dd32..398aafb 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 d2b06ba..5d13a32 100644 --- a/templates/spots.html +++ b/templates/spots.html @@ -113,8 +113,8 @@ - - + + diff --git a/templates/status.html b/templates/status.html index 24d6f51..cc6b4c7 100644 --- a/templates/status.html +++ b/templates/status.html @@ -86,7 +86,7 @@ - +