mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 14:27:42 +00:00
Improve protection against old unsupported objects (e.g. LocationSourceForCallsign.NONE) coming back from the cache and throwing exceptions
This commit is contained in:
@@ -114,16 +114,23 @@ def get_sig_ref_info(sig_name, ref_id):
|
|||||||
# OK, this is something we have to look up. Now check to see if our data store contains reference data and if
|
# OK, this is something we have to look up. Now check to see if our data store contains reference data and if
|
||||||
# so, copy the data into the sig_ref object
|
# so, copy the data into the sig_ref object
|
||||||
key = f"{sig_name}:{ref_id}"
|
key = f"{sig_name}:{ref_id}"
|
||||||
lookup_data = DATA_STORE.sigrefs.get(key) if key in DATA_STORE.sigrefs else None
|
try:
|
||||||
if lookup_data:
|
lookup_data = DATA_STORE.sigrefs.get(key) if key in DATA_STORE.sigrefs else None
|
||||||
for key, value in lookup_data.__dict__.items():
|
if lookup_data:
|
||||||
if value is not None and sig_ref.__dict__.get(key) is None:
|
for key, value in lookup_data.__dict__.items():
|
||||||
sig_ref.__dict__[key] = value
|
if value is not None and sig_ref.__dict__.get(key) is None:
|
||||||
|
sig_ref.__dict__[key] = value
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Maybe a super new reference we don't know about yet, but more likely a typo or a test reference,
|
# Maybe a super new reference we don't know about yet, but more likely a typo or a test reference,
|
||||||
# just silently ignore it.
|
# just silently ignore it.
|
||||||
logger.debug(f"{sig_name} database did not contain data for ref {ref_id}")
|
logger.debug(f"{sig_name} database did not contain data for ref {ref_id}")
|
||||||
|
|
||||||
|
except (ValueError, KeyError):
|
||||||
|
# Catch exceptions due to e.g. old versions of objects in the cache that are no longer compatible,
|
||||||
|
# and remove them from the cache.
|
||||||
|
del DATA_STORE.sigrefs[key]
|
||||||
|
return None
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception(f"Exception when looking up sig_ref info for {sig_name} ref {ref_id}")
|
logger.exception(f"Exception when looking up sig_ref info for {sig_name} ref {ref_id}")
|
||||||
|
|||||||
@@ -42,7 +42,13 @@ class CallsignDataProvider:
|
|||||||
|
|
||||||
if self.enabled:
|
if self.enabled:
|
||||||
if callsign in self._storage:
|
if callsign in self._storage:
|
||||||
return self._storage[callsign]
|
try:
|
||||||
|
return self._storage[callsign]
|
||||||
|
except (ValueError, KeyError):
|
||||||
|
# Catch exceptions due to e.g. old versions of objects in the cache that are no longer compatible,
|
||||||
|
# and remove them from the cache.
|
||||||
|
del self._storage[callsign]
|
||||||
|
return None
|
||||||
else:
|
else:
|
||||||
c = self._perform_new_lookup(callsign, lookup_credentials)
|
c = self._perform_new_lookup(callsign, lookup_credentials)
|
||||||
if c:
|
if c:
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/add-spot.js?v=1789198850"></script>
|
<script src="/static/js/add-spot.js?v=1789712909"></script>
|
||||||
<script>$(document).ready(function () {
|
<script>$(document).ready(function () {
|
||||||
$("#nav-link-add-spot").addClass("active");
|
$("#nav-link-add-spot").addClass("active");
|
||||||
}); <!-- highlight active page in nav --></script>
|
}); <!-- highlight active page in nav --></script>
|
||||||
|
|||||||
@@ -83,7 +83,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/alerts.js?v=1789198850"></script>
|
<script src="/static/js/alerts.js?v=1789712909"></script>
|
||||||
<script>$(document).ready(function () {
|
<script>$(document).ready(function () {
|
||||||
$("#nav-link-alerts").addClass("active");
|
$("#nav-link-alerts").addClass("active");
|
||||||
}); <!-- highlight active page in nav --></script>
|
}); <!-- highlight active page in nav --></script>
|
||||||
|
|||||||
@@ -76,8 +76,8 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/spotsbandsandmap.js?v=1789198850"></script>
|
<script src="/static/js/spotsbandsandmap.js?v=1789712909"></script>
|
||||||
<script src="/static/js/bands.js?v=1789198850"></script>
|
<script src="/static/js/bands.js?v=1789712909"></script>
|
||||||
<script>$(document).ready(function () {
|
<script>$(document).ready(function () {
|
||||||
$("#nav-link-bands").addClass("active");
|
$("#nav-link-bands").addClass("active");
|
||||||
}); <!-- highlight active page in nav --></script>
|
}); <!-- highlight active page in nav --></script>
|
||||||
|
|||||||
+5
-5
@@ -1,6 +1,6 @@
|
|||||||
{% extends "skeleton.html" %}
|
{% extends "skeleton.html" %}
|
||||||
{% block head_extra %}
|
{% block head_extra %}
|
||||||
<link rel="stylesheet" href="/static/css/style.css?v=1789198850" type="text/css">
|
<link rel="stylesheet" href="/static/css/style.css?v=1789712909" type="text/css">
|
||||||
<link href="/static/vendor/css/bootstrap-5.3.8.min.css" rel="stylesheet">
|
<link href="/static/vendor/css/bootstrap-5.3.8.min.css" rel="stylesheet">
|
||||||
<link href="/static/vendor/css/fontawesome-6.7.2.min.css" rel="stylesheet">
|
<link href="/static/vendor/css/fontawesome-6.7.2.min.css" rel="stylesheet">
|
||||||
<link href="/static/vendor/css/solid-6.7.2.min.css" rel="stylesheet">
|
<link href="/static/vendor/css/solid-6.7.2.min.css" rel="stylesheet">
|
||||||
@@ -16,10 +16,10 @@
|
|||||||
window.fetchEventSource = fetchEventSource;
|
window.fetchEventSource = fetchEventSource;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script src="/static/js/utils.js?v=1789198850"></script>
|
<script src="/static/js/utils.js?v=1789712909"></script>
|
||||||
<script src="/static/js/ui-ham.js?v=1789198850"></script>
|
<script src="/static/js/ui-ham.js?v=1789712909"></script>
|
||||||
<script src="/static/js/geo.js?v=1789198850"></script>
|
<script src="/static/js/geo.js?v=1789712909"></script>
|
||||||
<script src="/static/js/common.js?v=1789198850"></script>
|
<script src="/static/js/common.js?v=1789712909"></script>
|
||||||
{% end %}
|
{% end %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|||||||
@@ -284,7 +284,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/vendor/js/chart-4.4.9.umd.min.js"></script>
|
<script src="/static/vendor/js/chart-4.4.9.umd.min.js"></script>
|
||||||
<script src="/static/js/conditions.js?v=1789198850"></script>
|
<script src="/static/js/conditions.js?v=1789712909"></script>
|
||||||
<script>$(document).ready(function () {
|
<script>$(document).ready(function () {
|
||||||
$("#nav-link-conditions").addClass("active");
|
$("#nav-link-conditions").addClass("active");
|
||||||
}); <!-- highlight active page in nav --></script>
|
}); <!-- highlight active page in nav --></script>
|
||||||
|
|||||||
+2
-2
@@ -113,8 +113,8 @@
|
|||||||
const CARTODB_API_KEY = "{{ web_ui_options.get('cartodb_api_key', '') }}";
|
const CARTODB_API_KEY = "{{ web_ui_options.get('cartodb_api_key', '') }}";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script src="/static/js/spotsbandsandmap.js?v=1789198850"></script>
|
<script src="/static/js/spotsbandsandmap.js?v=1789712909"></script>
|
||||||
<script src="/static/js/map.js?v=1789198850"></script>
|
<script src="/static/js/map.js?v=1789712909"></script>
|
||||||
<script>$(document).ready(function () {
|
<script>$(document).ready(function () {
|
||||||
$("#nav-link-map").addClass("active");
|
$("#nav-link-map").addClass("active");
|
||||||
}); <!-- highlight active page in nav --></script>
|
}); <!-- highlight active page in nav --></script>
|
||||||
|
|||||||
@@ -125,8 +125,8 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/spotsbandsandmap.js?v=1789198850"></script>
|
<script src="/static/js/spotsbandsandmap.js?v=1789712909"></script>
|
||||||
<script src="/static/js/spots.js?v=1789198850"></script>
|
<script src="/static/js/spots.js?v=1789712909"></script>
|
||||||
<script>$(document).ready(function () {
|
<script>$(document).ready(function () {
|
||||||
$("#nav-link-spots").addClass("active");
|
$("#nav-link-spots").addClass("active");
|
||||||
}); <!-- highlight active page in nav --></script>
|
}); <!-- highlight active page in nav --></script>
|
||||||
|
|||||||
@@ -96,7 +96,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/status.js?v=1789198850"></script>
|
<script src="/static/js/status.js?v=1789712909"></script>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$("#nav-link-status").addClass("active");
|
$("#nav-link-status").addClass("active");
|
||||||
|
|||||||
Reference in New Issue
Block a user