Defensive coding

This commit is contained in:
Ian Renton
2026-07-26 07:57:48 +01:00
parent 77d7fd70d9
commit 3c1b1821f5
9 changed files with 19 additions and 18 deletions
+4 -3
View File
@@ -109,12 +109,13 @@ def populate_sig_ref_info(sig_ref):
# the zeroest corner of the box, then "lat2" and "lng2" provide the other corner. We detect this
# and provide a single lat/lon for the centre. Otherwise if we don't have these extra parameters,
# just use the single point we have.
if "latitude" in data and "longitude" in data and "lat2" in data and "lng2" in data:
if data.get("latitude") is not None and data.get("longitude") is not None and data.get(
"lat2") is not None and data.get("lng2") is not None:
sig_ref.latitude = (float(data["latitude"]) + float(data["lat2"])) / 2.0
sig_ref.longitude = (float(data["longitude"]) + float(data["lng2"])) / 2.0
else:
sig_ref.latitude = float(data["latitude"]) if "latitude" in data else None
sig_ref.longitude = float(data["longitude"]) if "longitude" in data else None
sig_ref.latitude = float(data["latitude"]) if data.get("latitude") is not None else None
sig_ref.longitude = float(data["longitude"]) if data.get("longitude") is not None else None
elif not response.from_cache:
logging.warning("Malformed response looking up %s ref %s via GMA", sig, ref_id)
elif not response.from_cache:
+1 -1
View File
@@ -76,7 +76,7 @@
</div>
<script src="/static/js/add-spot.js?v=1785048685"></script>
<script src="/static/js/add-spot.js?v=1785049068"></script>
<script>$(document).ready(function () {
$("#nav-link-add-spot").addClass("active");
}); <!-- highlight active page in nav --></script>
+1 -1
View File
@@ -75,7 +75,7 @@
</div>
<script src="/static/js/alerts.js?v=1785048685"></script>
<script src="/static/js/alerts.js?v=1785049068"></script>
<script>$(document).ready(function () {
$("#nav-link-alerts").addClass("active");
}); <!-- highlight active page in nav --></script>
+2 -2
View File
@@ -75,8 +75,8 @@
<script>
let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %};
</script>
<script src="/static/js/spotsbandsandmap.js?v=1785048685"></script>
<script src="/static/js/bands.js?v=1785048685"></script>
<script src="/static/js/spotsbandsandmap.js?v=1785049068"></script>
<script src="/static/js/bands.js?v=1785049068"></script>
<script>$(document).ready(function () {
$("#nav-link-bands").addClass("active");
}); <!-- highlight active page in nav --></script>
+5 -5
View File
@@ -1,6 +1,6 @@
{% extends "skeleton.html" %}
{% block head_extra %}
<link rel="stylesheet" href="/static/css/style.css?v=1785048685" type="text/css">
<link rel="stylesheet" href="/static/css/style.css?v=1785049068" type="text/css">
<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/solid-6.7.2.min.css" rel="stylesheet">
@@ -10,10 +10,10 @@
<script src="/static/vendor/js/bootstrap-5.3.8.bundle.min.js"></script>
<script src="/static/vendor/js/tinycolor2-1.6.0.min.js"></script>
<script src="/static/js/utils.js?v=1785048685"></script>
<script src="/static/js/ui-ham.js?v=1785048685"></script>
<script src="/static/js/geo.js?v=1785048685"></script>
<script src="/static/js/common.js?v=1785048685"></script>
<script src="/static/js/utils.js?v=1785049068"></script>
<script src="/static/js/ui-ham.js?v=1785049068"></script>
<script src="/static/js/geo.js?v=1785049068"></script>
<script src="/static/js/common.js?v=1785049068"></script>
{% end %}
{% block body %}
<div class="container">
+1 -1
View File
@@ -284,7 +284,7 @@
</div>
<script src="/static/vendor/js/chart-4.4.9.umd.min.js"></script>
<script src="/static/js/conditions.js?v=1785048685"></script>
<script src="/static/js/conditions.js?v=1785049068"></script>
<script>$(document).ready(function () {
$("#nav-link-conditions").addClass("active");
}); <!-- highlight active page in nav --></script>
+2 -2
View File
@@ -108,8 +108,8 @@
<script>
let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %};
</script>
<script src="/static/js/spotsbandsandmap.js?v=1785048685"></script>
<script src="/static/js/map.js?v=1785048685"></script>
<script src="/static/js/spotsbandsandmap.js?v=1785049068"></script>
<script src="/static/js/map.js?v=1785049068"></script>
<script>$(document).ready(function () {
$("#nav-link-map").addClass("active");
}); <!-- highlight active page in nav --></script>
+2 -2
View File
@@ -116,8 +116,8 @@
<script>
let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %};
</script>
<script src="/static/js/spotsbandsandmap.js?v=1785048685"></script>
<script src="/static/js/spots.js?v=1785048685"></script>
<script src="/static/js/spotsbandsandmap.js?v=1785049068"></script>
<script src="/static/js/spots.js?v=1785049068"></script>
<script>$(document).ready(function () {
$("#nav-link-spots").addClass("active");
}); <!-- highlight active page in nav --></script>
+1 -1
View File
@@ -59,7 +59,7 @@
</div>
</div>
<script src="/static/js/status.js?v=1785048685"></script>
<script src="/static/js/status.js?v=1785049068"></script>
<script>
$(document).ready(function () {
$("#nav-link-status").addClass("active");