Logging tidy-up, IDE inspection fixes

This commit is contained in:
Ian Renton
2026-08-15 07:42:38 +01:00
parent 9cd6d9c177
commit bff5b79f8f
40 changed files with 128 additions and 125 deletions
@@ -1,13 +1,3 @@
import logging
from datetime import datetime
from threading import Thread, Event
import pytz
from requests import ReadTimeout
from requests.exceptions import ConnectionError, ConnectTimeout
from core.constants import HTTP_HEADERS
from core.url_data_cache import URLDataCache
from providers.callsigndata.callsign_data_provider import CallsignDataProvider
@@ -1,4 +1,3 @@
import logging
from datetime import datetime
import pytz
+2 -2
View File
@@ -41,8 +41,8 @@ class ClublogAPI(APIQueryCallsignDataProvider):
else:
return None
except Exception as e:
except Exception:
self.status = "Error"
logging.error("Exception when looking up data from Clublog API", e, exc_info=True)
logging.exception("Exception when looking up data from Clublog API")
return callsign_data
+4 -6
View File
@@ -1,8 +1,6 @@
import gzip
import logging
from datetime import datetime
import pytz
from pyhamtools import LookupLib, Callinfo
from core.data_store import DATA_STORE
@@ -47,8 +45,8 @@ class ClublogXML(FileDownloadCallsignDataProvider):
self._callinfo = Callinfo(lookuplib)
return True
except Exception as e:
logging.error("Exception when loading Clublog XML.", e, exc_info=True)
except Exception:
logging.exception("Exception when loading Clublog XML.")
return False
def _perform_new_lookup(self, callsign, lookup_credentials):
@@ -62,8 +60,8 @@ class ClublogXML(FileDownloadCallsignDataProvider):
else:
return None
except Exception as e:
except Exception:
self.status = "Error"
logging.error("Exception when looking up data from Clublog XML data", e, exc_info=True)
logging.exception("Exception when looking up data from Clublog XML data")
return callsign_data
+4 -4
View File
@@ -26,8 +26,8 @@ class CountryFiles(FileDownloadCallsignDataProvider):
self._callinfo = Callinfo(lookuplib)
return True
except Exception as e:
logging.error("Exception when loading Country Files cty.plist.", e, exc_info=True)
except Exception:
logging.exception("Exception when loading Country Files cty.plist.")
return False
def _perform_new_lookup(self, callsign, lookup_credentials):
@@ -41,8 +41,8 @@ class CountryFiles(FileDownloadCallsignDataProvider):
else:
return None
except Exception as e:
except Exception:
self.status = "Error"
logging.error("Exception when looking up data from Country file", e, exc_info=True)
logging.exception("Exception when looking up data from Country file")
return callsign_data
+3 -3
View File
@@ -97,15 +97,15 @@ class HamQTH(APIQueryCallsignDataProvider):
logging.warning(f"Timeout when looking up callsign %s using HamQTH", lookup_call)
continue
except Exception:
logging.error("Exception when looking up callsign %s using HamQTH", lookup_call, exc_info=True)
logging.exception("Exception when looking up callsign %s using HamQTH", lookup_call)
continue
# Not found in HamQTH; return a Callsign object with no data so we cache that and don't keep retrying
return Callsign(call=callsign)
except Exception as e:
except Exception:
self.status = "Error"
logging.error("Exception when looking up data from HamQTH", e, exc_info=True)
logging.exception("Exception when looking up data from HamQTH")
# Return None, this won't be cached so we will be asked to query data again for this call next time.
return None
+3 -3
View File
@@ -106,15 +106,15 @@ class QRZ(APIQueryCallsignDataProvider):
logging.warning(f"Timeout when looking up callsign %s using QRZ.", lookup_call)
continue
except Exception:
logging.error("Exception when looking up callsign %s using QRZ", lookup_call, exc_info=True)
logging.exception("Exception when looking up callsign %s using QRZ", lookup_call)
continue
# Not found in QRZ; return a Callsign object with no data so we cache that and don't keep retrying
return Callsign(call=callsign)
except Exception as e:
except Exception:
self.status = "Error"
logging.error("Exception when looking up data from QRZ.com", e, exc_info=True)
logging.exception("Exception when looking up data from QRZ.com")
# Return None, this won't be cached so we will be asked to query data again for this call next time.
return None
@@ -24,9 +24,9 @@ class LocalFileSIGRefDataProvider(SIGRefDataProvider):
else:
self.status = "Error"
logging.info("Failed to load SIG ref data for " + self.sig_name)
except Exception as e:
except Exception:
self.status = "Error"
logging.error("Exception in local file SIG Ref Data Provider (" + self.sig_name + ")", e, exc_info=True)
logging.exception("Exception in local file SIG Ref Data Provider (" + self.sig_name + ")")
def _file_to_data(self, path):
"""Load a file on the given path and turn it into SIG Ref data."""
@@ -24,7 +24,9 @@ class ParksNPeaksKMLSIGRefDataProvider(FileDownloadSIGRefDataProvider):
k = kml.KML.from_string(http_response.content)
for document in k.features:
# noinspection unresolved-references
for folder in document.features:
# noinspection unresolved-references
for placemark in folder.features:
description = placemark.description or ""
match = self.REF_PATTERN.search(description)
+2 -2
View File
@@ -115,8 +115,8 @@ class GMA(HTTPSpotProvider):
logging.warning(
f"GMA API returned a malformed response when looking up ref {source_spot['REF']}")
except:
logging.warning("Exception when looking up " + self.REF_INFO_URL_ROOT + source_spot[
"REF"] + ", ignoring this spot for now", exc_info=True)
logging.exception("Exception when looking up " + self.REF_INFO_URL_ROOT + source_spot[
"REF"] + ", ignoring this spot for now")
else:
logging.warning(f"The GMA API returned an unexpected response (HTTP {http_response.status_code}).")
+2 -2
View File
@@ -31,6 +31,6 @@ class CQZoneData(LocalFileStaticDataProvider):
DATA_STORE.cq_zone_data = cq_zone_data
return True
except Exception as e:
logging.error("Exception when loading CQ zone data.", e, exc_info=True)
except Exception:
logging.exception("Exception when loading CQ zone data.")
return False
+2 -2
View File
@@ -31,6 +31,6 @@ class ITUZoneData(LocalFileStaticDataProvider):
DATA_STORE.itu_zone_data = itu_zone_data
return True
except Exception as e:
logging.error("Exception when loading ITU zone data.", e, exc_info=True)
except Exception:
logging.exception("Exception when loading ITU zone data.")
return False
+2 -2
View File
@@ -41,8 +41,8 @@ class K0SWE(FileDownloadStaticDataProvider):
return True
except Exception as e:
logging.error("Exception when loading K0SWE dxcc.json.", e, exc_info=True)
except Exception:
logging.exception("Exception when loading K0SWE dxcc.json.")
return False
@@ -25,9 +25,9 @@ class LocalFileStaticDataProvider(StaticDataProvider):
else:
self.status = "Error"
logging.error("Failed to load data for " + self.name)
except Exception as e:
except Exception:
self.status = "Error"
logging.error("Exception in local file Static Data Provider (" + self.name + ")", e, exc_info=True)
logging.exception("Exception in local file Static Data Provider (" + self.name + ")")
def stop(self):
self._stop = True