mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 14:27:42 +00:00
Logging tidy-up, IDE inspection fixes
This commit is contained in:
@@ -12,7 +12,7 @@ def get_call_info(callsign, lookup_credentials):
|
||||
if callsign:
|
||||
# Sort callsign providers by priority order, so we query the highest priority (lowest numbers) first, and only
|
||||
# query other providers for data we are missing as we go along.
|
||||
for p in sorted(DATA_PROVIDERS.callsign_data_providers, key=lambda p: p.priority):
|
||||
for p in sorted(DATA_PROVIDERS.callsign_data_providers, key=lambda p2: p2.priority):
|
||||
if p.enabled:
|
||||
# Get new lookup data
|
||||
data = p.lookup(callsign, lookup_credentials)
|
||||
|
||||
@@ -31,10 +31,10 @@ class DataProviders:
|
||||
self.callsign_data_providers.append(create_provider_from_config("providers.callsigndata", entry))
|
||||
|
||||
@staticmethod
|
||||
def start_providers(providers, type):
|
||||
def start_providers(providers, provider_type):
|
||||
"""Helper method to activate enabled providers in the list."""
|
||||
|
||||
logging.info(f"Starting %s providers...", type)
|
||||
logging.info(f"Starting %s providers...", provider_type)
|
||||
for p in providers:
|
||||
if p.enabled:
|
||||
p.start()
|
||||
|
||||
@@ -34,7 +34,7 @@ class LiveDataCache:
|
||||
try:
|
||||
callback(value)
|
||||
except Exception:
|
||||
logging.error("Listener raised an exception for key %s", key, exc_info=True)
|
||||
logging.exception("Listener raised an exception for key %s", key)
|
||||
|
||||
|
||||
def get(self, key, default=None):
|
||||
@@ -71,7 +71,7 @@ class LiveDataCache:
|
||||
try:
|
||||
self._disk_cache.set("snapshot", data)
|
||||
except Exception as e:
|
||||
logging.error("Failed to write snapshot to %s", self._snapshot_dir, e, exc_info=True)
|
||||
logging.exception("Failed to write snapshot to %s", self._snapshot_dir, e)
|
||||
|
||||
def _load_snapshot(self):
|
||||
data = self._disk_cache.get("snapshot")
|
||||
|
||||
@@ -29,7 +29,7 @@ def get_sig_ref_info(sig, ref_id):
|
||||
|
||||
# If the SIG is HEMA, we have no current lookup for this so just skip the lookup here.
|
||||
if sig.upper() == "HEMA":
|
||||
sig_ref.type = "Summit"
|
||||
sig_ref.ref_type = "Summit"
|
||||
return sig_ref
|
||||
|
||||
### PROGRAMMATIC DATA GENERATION INSTEAD OF LOOKUPS ###
|
||||
@@ -38,7 +38,7 @@ def get_sig_ref_info(sig, ref_id):
|
||||
# calculate all the information we are going to get directly.
|
||||
if sig.upper() == "TILES":
|
||||
# Tiles on the Air just uses Maidenhead 6-digit squares, so ID, Name and Grid are all the same
|
||||
sig_ref.type = "Grid"
|
||||
sig_ref.ref_type = "Grid"
|
||||
if not sig_ref.name:
|
||||
sig_ref.name = sig_ref.id
|
||||
if not sig_ref.grid:
|
||||
@@ -50,7 +50,7 @@ def get_sig_ref_info(sig, ref_id):
|
||||
return sig_ref
|
||||
|
||||
elif sig.upper() == "WAB" or sig.upper() == "WAI":
|
||||
sig_ref.type = "Grid"
|
||||
sig_ref.ref_type = "Grid"
|
||||
ll = wab_wai_square_to_lat_lon(ref_id)
|
||||
if ll:
|
||||
sig_ref.name = ref_id
|
||||
@@ -64,10 +64,11 @@ def get_sig_ref_info(sig, ref_id):
|
||||
|
||||
elif sig.upper() == "BOTA":
|
||||
# For BOTA all we can ever generate is the URL, there is no data file or lookup for lat/longs
|
||||
sig_ref.type = "Beach"
|
||||
sig_ref.ref_type = "Beach"
|
||||
if not sig_ref.name:
|
||||
sig_ref.name = sig_ref.id
|
||||
sig_ref.url = "https://www.beachesontheair.com/beaches/" + sig_ref.name.lower().replace(" ", "-")
|
||||
if sig_ref.name:
|
||||
sig_ref.url = "https://www.beachesontheair.com/beaches/" + sig_ref.name.lower().replace(" ", "-")
|
||||
return sig_ref
|
||||
|
||||
### ACTUAL LOOKUP ###
|
||||
@@ -85,7 +86,7 @@ def get_sig_ref_info(sig, ref_id):
|
||||
logging.debug("%s database did not contain data for ref %s", sig, ref_id)
|
||||
|
||||
except Exception:
|
||||
logging.error("Exception when looking up sig_ref info for " + sig + " ref " + ref_id, exc_info=True)
|
||||
logging.exception("Exception when looking up sig_ref info for " + sig + " ref " + ref_id)
|
||||
return sig_ref
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user