mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-08-05 18:11:41 +00:00
Improve error reporting consistency and ensure SEMI_STATIC_URL_DATA_CACHE caches 400-series responses from the server so we don't keep requesting summit/park/bunker data for a reference that the user typod and doesn't actually exist.
This commit is contained in:
@@ -54,7 +54,7 @@ class HTTPAlertProvider(AlertProvider):
|
|||||||
logging.debug("Received data from " + self.name + " alert API.")
|
logging.debug("Received data from " + self.name + " alert API.")
|
||||||
else:
|
else:
|
||||||
self.status = "Error"
|
self.status = "Error"
|
||||||
logging.warning(f"{self.name} alert API returned HTTP {http_response.status_code}.")
|
logging.warning(f"HTTP {http_response.status_code} when calling {self.name} alerts API.")
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
self.status = "Error"
|
self.status = "Error"
|
||||||
|
|||||||
+5
-2
@@ -8,8 +8,11 @@ from requests_cache import CachedSession
|
|||||||
# of time has passed. This is used throughout Spothole to cache data that does not change
|
# of time has passed. This is used throughout Spothole to cache data that does not change
|
||||||
# rapidly. The ThreadSafeSession construct here protects it against some multithreading
|
# rapidly. The ThreadSafeSession construct here protects it against some multithreading
|
||||||
# contention weirdness we sometimes used to see on startup where the cache was hammered
|
# contention weirdness we sometimes used to see on startup where the cache was hammered
|
||||||
# pretty hard.
|
# pretty hard. The expanded list of allowable_codes ensures we also cache and return 400-type
|
||||||
_session = CachedSession("cache/semi_static_url_data_cache", expire_after=timedelta(days=30))
|
# responses, e.g "this SOTA summit ref doesn't actually exist", to avoid hammering remote
|
||||||
|
# servers for data they've told us they can't provide.
|
||||||
|
_session = CachedSession("cache/semi_static_url_data_cache", expire_after=timedelta(days=30),
|
||||||
|
allowable_codes=(200, 400, 401, 403, 404))
|
||||||
_lock = threading.Lock()
|
_lock = threading.Lock()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ class GIROIonosonde(SolarConditionsProvider):
|
|||||||
url = f"{LGDC_URL}?ursiCode={ursi}&charName=foF2,MUFD,fmin&DMUF=3000&fromDate={from_str}&toDate={to_str}"
|
url = f"{LGDC_URL}?ursiCode={ursi}&charName=foF2,MUFD,fmin&DMUF=3000&fromDate={from_str}&toDate={to_str}"
|
||||||
http_response = requests.get(url, headers=HTTP_HEADERS, timeout=(5, 15))
|
http_response = requests.get(url, headers=HTTP_HEADERS, timeout=(5, 15))
|
||||||
if http_response.status_code != 200:
|
if http_response.status_code != 200:
|
||||||
logging.warning(f"Giro ionosonde API returned HTTP {http_response.status_code}.")
|
logging.warning(f"HTTP {http_response.status_code} when calling Giro ionosonde API.")
|
||||||
return None, None, None
|
return None, None, None
|
||||||
return self._parse_all(http_response.text)
|
return self._parse_all(http_response.text)
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class HTTPSolarConditionsProvider(SolarConditionsProvider):
|
|||||||
logging.debug("Received data from " + self.name + " solar conditions API.")
|
logging.debug("Received data from " + self.name + " solar conditions API.")
|
||||||
else:
|
else:
|
||||||
self.status = "Error"
|
self.status = "Error"
|
||||||
logging.warning(f"{self.name} solar conditions API returned HTTP {http_response.status_code}.")
|
logging.warning(f"HTTP {http_response.status_code} when calling {self.name} solar conditions API.")
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
self.status = "Error"
|
self.status = "Error"
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class KC2GProp(SolarConditionsProvider):
|
|||||||
logging.debug("Polling KC2G ionosonde data...")
|
logging.debug("Polling KC2G ionosonde data...")
|
||||||
http_response = requests.get(KC2G_URL, headers=HTTP_HEADERS, timeout=(5, 30))
|
http_response = requests.get(KC2G_URL, headers=HTTP_HEADERS, timeout=(5, 30))
|
||||||
if http_response.status_code != 200:
|
if http_response.status_code != 200:
|
||||||
logging.warning(f"KC2G ionosonde API returned HTTP {http_response.status_code}")
|
logging.warning(f"HTTP {http_response.status_code} when calling KG2G ionosonde API.")
|
||||||
return
|
return
|
||||||
|
|
||||||
now = datetime.now(timezone.utc)
|
now = datetime.now(timezone.utc)
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class HTTPSpotProvider(SpotProvider):
|
|||||||
logging.debug("Received data from " + self.name + " spot API.")
|
logging.debug("Received data from " + self.name + " spot API.")
|
||||||
else:
|
else:
|
||||||
self.status = "Error"
|
self.status = "Error"
|
||||||
logging.warning(f"{self.name} spot API returned HTTP {http_response.status_code}.")
|
logging.warning(f"HTTP {http_response.status_code} when calling {self.name} spot API.")
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
self.status = "Error"
|
self.status = "Error"
|
||||||
|
|||||||
@@ -76,7 +76,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/js/add-spot.js?v=1784963837"></script>
|
<script src="/js/add-spot.js?v=1784964562"></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>
|
||||||
|
|||||||
@@ -75,7 +75,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/js/alerts.js?v=1784963837"></script>
|
<script src="/js/alerts.js?v=1784964563"></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>
|
||||||
|
|||||||
@@ -75,8 +75,8 @@
|
|||||||
<script>
|
<script>
|
||||||
let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %};
|
let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %};
|
||||||
</script>
|
</script>
|
||||||
<script src="/js/spotsbandsandmap.js?v=1784963837"></script>
|
<script src="/js/spotsbandsandmap.js?v=1784964562"></script>
|
||||||
<script src="/js/bands.js?v=1784963837"></script>
|
<script src="/js/bands.js?v=1784964562"></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="/css/style.css?v=1784963837" type="text/css">
|
<link rel="stylesheet" href="/css/style.css?v=1784964562" type="text/css">
|
||||||
<link href="/vendor/css/bootstrap-5.3.8.min.css" rel="stylesheet">
|
<link href="/vendor/css/bootstrap-5.3.8.min.css" rel="stylesheet">
|
||||||
<link href="/vendor/css/fontawesome-6.7.2.min.css" rel="stylesheet">
|
<link href="/vendor/css/fontawesome-6.7.2.min.css" rel="stylesheet">
|
||||||
<link href="/vendor/css/solid-6.7.2.min.css" rel="stylesheet">
|
<link href="/vendor/css/solid-6.7.2.min.css" rel="stylesheet">
|
||||||
@@ -10,10 +10,10 @@
|
|||||||
<script src="/vendor/js/bootstrap-5.3.8.bundle.min.js"></script>
|
<script src="/vendor/js/bootstrap-5.3.8.bundle.min.js"></script>
|
||||||
<script src="/vendor/js/tinycolor2-1.6.0.min.js"></script>
|
<script src="/vendor/js/tinycolor2-1.6.0.min.js"></script>
|
||||||
|
|
||||||
<script src="/js/utils.js?v=1784963837"></script>
|
<script src="/js/utils.js?v=1784964562"></script>
|
||||||
<script src="/js/ui-ham.js?v=1784963837"></script>
|
<script src="/js/ui-ham.js?v=1784964562"></script>
|
||||||
<script src="/js/geo.js?v=1784963837"></script>
|
<script src="/js/geo.js?v=1784964562"></script>
|
||||||
<script src="/js/common.js?v=1784963837"></script>
|
<script src="/js/common.js?v=1784964562"></script>
|
||||||
{% end %}
|
{% end %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|||||||
@@ -284,7 +284,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/vendor/js/chart-4.4.9.umd.min.js"></script>
|
<script src="/vendor/js/chart-4.4.9.umd.min.js"></script>
|
||||||
<script src="/js/conditions.js?v=1784963837"></script>
|
<script src="/js/conditions.js?v=1784964562"></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
@@ -95,8 +95,8 @@
|
|||||||
<script>
|
<script>
|
||||||
let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %};
|
let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %};
|
||||||
</script>
|
</script>
|
||||||
<script src="/js/spotsbandsandmap.js?v=1784963837"></script>
|
<script src="/js/spotsbandsandmap.js?v=1784964563"></script>
|
||||||
<script src="/js/map.js?v=1784963837"></script>
|
<script src="/js/map.js?v=1784964563"></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>
|
||||||
|
|||||||
@@ -116,8 +116,8 @@
|
|||||||
<script>
|
<script>
|
||||||
let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %};
|
let spotProvidersEnabledByDefault = {% raw json_encode(web_ui_options["spot-providers-enabled-by-default"]) %};
|
||||||
</script>
|
</script>
|
||||||
<script src="/js/spotsbandsandmap.js?v=1784963837"></script>
|
<script src="/js/spotsbandsandmap.js?v=1784964562"></script>
|
||||||
<script src="/js/spots.js?v=1784963837"></script>
|
<script src="/js/spots.js?v=1784964562"></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>
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/js/status.js?v=1784963837"></script>
|
<script src="/js/status.js?v=1784964562"></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