From 3da8c80ad6ad17703d889599320b326ac31e1dc6 Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Sat, 29 Nov 2025 15:50:55 +0000 Subject: [PATCH] Defensive coding --- core/lookup_helper.py | 5 +++++ data/spot.py | 12 +++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/core/lookup_helper.py b/core/lookup_helper.py index 0fc5f90..a6e5c5a 100644 --- a/core/lookup_helper.py +++ b/core/lookup_helper.py @@ -455,6 +455,11 @@ class LookupHelper: # QRZ had no info for the call, that's OK. Cache a None so we don't try to look this up again self.QRZ_CALLSIGN_DATA_CACHE.add(call, None, expire=604800) # 1 week in seconds return None + except (Exception): + # General exception like a timeout when communicating with QRZ. Return None this time, but don't cache + # that, so we can try again next time. + logging.error("Exception when looking up QRZ data") + return None else: return None diff --git a/data/spot.py b/data/spot.py index f8f6471..aa63be1 100644 --- a/data/spot.py +++ b/data/spot.py @@ -243,13 +243,15 @@ class Spot: if not self.sig and self.sig_refs and len(self.sig_refs) > 0: self.sig = self.sig_refs[0].sig.upper() - # See if we already have a SIG reference, but the comment looks like it contains more for the same SIG. This + # See if we already have a SIG reference, but the comment looks like it contains more for the same SIG. This # should catch e.g. POTA comments like "2-fer: GB-0001 GB-0002". - if self.comment and self.sig_refs and len(self.sig_refs) > 0: + if self.comment and self.sig_refs and len(self.sig_refs) > 0 and self.sig_refs[0].sig: sig = self.sig_refs[0].sig.upper() - all_comment_ref_matches = re.finditer(r"(^|\W)(" + get_ref_regex_for_sig(sig) + r")(^|\W)", self.comment, re.IGNORECASE) - for ref_match in all_comment_ref_matches: - self.append_sig_ref_if_missing(SIGRef(id=ref_match.group(2).upper(), sig=sig)) + regex = get_ref_regex_for_sig(sig) + if regex: + all_comment_ref_matches = re.finditer(r"(^|\W)(" + regex + r")(^|\W)", self.comment, re.IGNORECASE) + for ref_match in all_comment_ref_matches: + self.append_sig_ref_if_missing(SIGRef(id=ref_match.group(2).upper(), sig=sig)) # See if the comment looks like it contains any SIGs (and optionally SIG references) that we can # add to the spot. This should catch cluster spot comments like "POTA GB-0001 WWFF GFF-0001" and e.g. POTA