2 Commits

Author SHA1 Message Date
Ian Renton
e61d7bedb4 Exception handling #74 2025-11-02 18:00:24 +00:00
Ian Renton
ebf07f352f Exception handling #74 2025-11-02 17:59:37 +00:00

View File

@@ -1,4 +1,5 @@
import csv import csv
import logging
from pyhamtools.locator import latlong_to_locator from pyhamtools.locator import latlong_to_locator
@@ -28,6 +29,7 @@ def get_ref_regex_for_sig(sig):
# Note there is currently no support for KRMNPA location lookup, see issue #61. # Note there is currently no support for KRMNPA location lookup, see issue #61.
def get_sig_ref_info(sig, sig_ref_id): def get_sig_ref_info(sig, sig_ref_id):
sig_ref = SIGRef(id=sig_ref_id, sig=sig) sig_ref = SIGRef(id=sig_ref_id, sig=sig)
try:
if sig.upper() == "POTA": if sig.upper() == "POTA":
data = SEMI_STATIC_URL_DATA_CACHE.get("https://api.pota.app/park/" + sig_ref_id, headers=HTTP_HEADERS).json() data = SEMI_STATIC_URL_DATA_CACHE.get("https://api.pota.app/park/" + sig_ref_id, headers=HTTP_HEADERS).json()
if data: if data:
@@ -110,7 +112,8 @@ def get_sig_ref_info(sig, sig_ref_id):
sig_ref.grid = latlong_to_locator(ll[0], ll[1], 6) sig_ref.grid = latlong_to_locator(ll[0], ll[1], 6)
sig_ref.latitude = ll[0] sig_ref.latitude = ll[0]
sig_ref.longitude = ll[1] sig_ref.longitude = ll[1]
except:
logging.warn("Failed to look up sig_ref info for " + sig + " ref " + sig_ref_id + ".")
return sig_ref return sig_ref