mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-20 06:17:41 +00:00
Compare commits
5
Commits
ab81c136cc
...
0eb4553406
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0eb4553406 | ||
|
|
682e2c267c | ||
|
|
f39215ecdd | ||
|
|
c9c8ffc1f7 | ||
|
|
59d5f61d90 |
+1
-1
@@ -4,7 +4,7 @@ from data.band import Band
|
||||
from data.sig import SIG
|
||||
|
||||
# General software
|
||||
SOFTWARE_VERSION = "2.1.1"
|
||||
SOFTWARE_VERSION = "2.1.2"
|
||||
|
||||
# HTTP headers used for spot providers that use HTTP
|
||||
HTTP_HEADERS = {"User-Agent": f"Spothole v{SOFTWARE_VERSION} (operated by {SERVER_OWNER_CALLSIGN})"}
|
||||
|
||||
@@ -77,7 +77,12 @@ class LiveDataCache:
|
||||
logger.exception(f"Failed to write snapshot to {self._snapshot_dir}")
|
||||
|
||||
def _load_snapshot(self):
|
||||
data = self._disk_cache.get("snapshot")
|
||||
try:
|
||||
data = self._disk_cache.get("snapshot")
|
||||
except Exception:
|
||||
logger.warning(f"Failed to load snapshot from {self._snapshot_dir}, clearing it.")
|
||||
self._disk_cache.clear()
|
||||
return
|
||||
if not data:
|
||||
return
|
||||
|
||||
|
||||
@@ -21,7 +21,13 @@ class SingleObjectDataCache:
|
||||
# This cache stores a single object, doesn't matter what it's called so "object" will do
|
||||
if "object" not in self._cache:
|
||||
self._cache.add("object", object_if_empty)
|
||||
self._obj = self._cache.get("object")
|
||||
try:
|
||||
self._obj = self._cache.get("object")
|
||||
except Exception:
|
||||
logger.warning(f"Failed to load cache from {cache_dir}, clearing it.")
|
||||
self._cache.clear()
|
||||
self._cache.add("object", object_if_empty)
|
||||
self._obj = object_if_empty
|
||||
|
||||
def get(self):
|
||||
"""Get the data object. This can then be manipulated as necessary across multiple threads. Any function
|
||||
|
||||
@@ -4,7 +4,7 @@ from threading import Event, Thread
|
||||
|
||||
import pytz
|
||||
import requests
|
||||
from requests.exceptions import ConnectionError, ConnectTimeout, ReadTimeout
|
||||
from requests.exceptions import ConnectionError, ConnectTimeout, JSONDecodeError, ReadTimeout
|
||||
|
||||
from core.constants import HTTP_HEADERS
|
||||
from providers.alert.alert_provider import AlertProvider
|
||||
@@ -64,9 +64,14 @@ class HTTPAlertProvider(AlertProvider):
|
||||
logger.warning(f"HTTP {http_response.status_code} when calling {self.name} alerts API.")
|
||||
|
||||
except ConnectionError:
|
||||
self.status = "Error"
|
||||
logger.warning(f"Connection error when accessing {self.name} alerts API.")
|
||||
except (ConnectTimeout, ReadTimeout):
|
||||
self.status = "Error"
|
||||
logger.warning(f"Timeout when accessing {self.name} alerts API.")
|
||||
except JSONDecodeError:
|
||||
self.status = "Error"
|
||||
logger.warning(f"Invalid or empty JSON response from {self.name} alert API.")
|
||||
except Exception:
|
||||
self.status = "Error"
|
||||
logger.exception(f"Exception in HTTP JSON Alert Provider ({self.name})")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import logging
|
||||
import re
|
||||
from datetime import datetime
|
||||
from threading import Event, Thread
|
||||
from threading import Event, Lock, Thread
|
||||
|
||||
import pytz
|
||||
import telnetlib3
|
||||
@@ -40,6 +40,7 @@ class DXCluster(SpotProvider):
|
||||
self._LINE_PATTERN_ALLOW_RBN if self._allow_rbn_spots else self._LINE_PATTERN_EXCLUDE_RBN
|
||||
)
|
||||
self._telnet = None
|
||||
self._telnet_lock = Lock()
|
||||
self._thread = None
|
||||
self._stop_event = Event()
|
||||
|
||||
@@ -49,8 +50,9 @@ class DXCluster(SpotProvider):
|
||||
|
||||
def stop(self):
|
||||
self._stop_event.set()
|
||||
if self._telnet:
|
||||
self._telnet.close()
|
||||
with self._telnet_lock:
|
||||
if self._telnet:
|
||||
self._telnet.close()
|
||||
if self._thread:
|
||||
self._thread.join(timeout=15)
|
||||
if self._thread.is_alive():
|
||||
@@ -63,7 +65,14 @@ class DXCluster(SpotProvider):
|
||||
try:
|
||||
self.status = "Connecting"
|
||||
logger.info(f"DX Cluster {self._hostname} connecting...")
|
||||
self._telnet = telnetlib3.Telnet(self._hostname, self._port)
|
||||
new_telnet = telnetlib3.Telnet(self._hostname, self._port)
|
||||
with self._telnet_lock:
|
||||
self._telnet = new_telnet
|
||||
if self._stop_event.is_set():
|
||||
# stop() was called while we were connecting, close the connection rather than trying to
|
||||
# read when we know it won't work
|
||||
new_telnet.close()
|
||||
break
|
||||
self._telnet.read_until(self._login_prompt.encode("latin-1"))
|
||||
self._telnet.write(f"{self._login_callsign}\n".encode("latin-1"))
|
||||
connected = True
|
||||
|
||||
@@ -4,7 +4,7 @@ from threading import Event, Thread
|
||||
|
||||
import pytz
|
||||
import requests
|
||||
from requests.exceptions import ConnectionError, ConnectTimeout, ReadTimeout
|
||||
from requests.exceptions import ConnectionError, ConnectTimeout, JSONDecodeError, ReadTimeout
|
||||
|
||||
from core.constants import HTTP_HEADERS
|
||||
from providers.spot.spot_provider import SpotProvider
|
||||
@@ -73,9 +73,14 @@ class HTTPSpotProvider(SpotProvider):
|
||||
logger.warning(f"HTTP {http_response.status_code} when calling {self.name} spot API.")
|
||||
|
||||
except ConnectionError:
|
||||
self.status = "Error"
|
||||
logger.warning(f"Connection error when accessing {self.name} spots API.")
|
||||
except (ConnectTimeout, ReadTimeout):
|
||||
self.status = "Error"
|
||||
logger.warning(f"Timeout when accessing {self.name} spots API.")
|
||||
except JSONDecodeError:
|
||||
self.status = "Error"
|
||||
logger.warning(f"Invalid or empty JSON response from {self.name} spots API.")
|
||||
except Exception:
|
||||
self.status = "Error"
|
||||
logger.exception(f"Exception in HTTP Spot Provider ({self.name})")
|
||||
|
||||
+13
-4
@@ -1,7 +1,7 @@
|
||||
import logging
|
||||
import re
|
||||
from datetime import datetime
|
||||
from threading import Event, Thread
|
||||
from threading import Event, Lock, Thread
|
||||
|
||||
import pytz
|
||||
import telnetlib3
|
||||
@@ -29,6 +29,7 @@ class RBN(SpotProvider):
|
||||
super().__init__(name, provider_config)
|
||||
self._port = provider_config["port"]
|
||||
self._telnet = None
|
||||
self._telnet_lock = Lock()
|
||||
self._thread = None
|
||||
self._stop_event = Event()
|
||||
|
||||
@@ -38,8 +39,9 @@ class RBN(SpotProvider):
|
||||
|
||||
def stop(self):
|
||||
self._stop_event.set()
|
||||
if self._telnet:
|
||||
self._telnet.close()
|
||||
with self._telnet_lock:
|
||||
if self._telnet:
|
||||
self._telnet.close()
|
||||
if self._thread:
|
||||
self._thread.join(timeout=15)
|
||||
if self._thread.is_alive():
|
||||
@@ -52,7 +54,14 @@ class RBN(SpotProvider):
|
||||
try:
|
||||
self.status = "Connecting"
|
||||
logger.info(f"RBN port {self._port!s} connecting...")
|
||||
self._telnet = telnetlib3.Telnet("telnet.reversebeacon.net", self._port)
|
||||
new_telnet = telnetlib3.Telnet("telnet.reversebeacon.net", self._port)
|
||||
with self._telnet_lock:
|
||||
self._telnet = new_telnet
|
||||
if self._stop_event.is_set():
|
||||
# stop() was called while we were connecting, close the connection rather than trying to
|
||||
# read when we know it won't work
|
||||
new_telnet.close()
|
||||
break
|
||||
self._telnet.read_until("Please enter your call: ".encode("latin-1"))
|
||||
self._telnet.write(f"{SERVER_OWNER_CALLSIGN}\n".encode("latin-1"))
|
||||
connected = True
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "spothole"
|
||||
version = "2.1.1"
|
||||
version = "2.1.2"
|
||||
authors = [
|
||||
{ name = "Ian Renton", email = "ian@ianrenton.com" },
|
||||
]
|
||||
|
||||
@@ -414,8 +414,8 @@ div.band-spot:hover span.band-spot-info {
|
||||
|
||||
/* Make map stretch to horizontal screen edges */
|
||||
div#map, div#table-container, div#bands-container {
|
||||
margin-left: -1em;
|
||||
margin-right: -1em;
|
||||
margin-left: -0.75rem;
|
||||
margin-right: -0.75rem;
|
||||
}
|
||||
|
||||
/* Avoid map page filters panel being larger than the map itself */
|
||||
|
||||
@@ -77,7 +77,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
<script src="/static/js/add-spot.js?v=1789763826"></script>
|
||||
<script src="/static/js/add-spot.js?v=1789811377"></script>
|
||||
<script>$(document).ready(function () {
|
||||
$("#nav-link-add-spot").addClass("active");
|
||||
}); <!-- highlight active page in nav --></script>
|
||||
|
||||
@@ -83,7 +83,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
<script src="/static/js/alerts.js?v=1789763826"></script>
|
||||
<script src="/static/js/alerts.js?v=1789811377"></script>
|
||||
<script>$(document).ready(function () {
|
||||
$("#nav-link-alerts").addClass("active");
|
||||
}); <!-- highlight active page in nav --></script>
|
||||
|
||||
@@ -76,8 +76,8 @@
|
||||
|
||||
</div>
|
||||
|
||||
<script src="/static/js/spotsbandsandmap.js?v=1789763826"></script>
|
||||
<script src="/static/js/bands.js?v=1789763826"></script>
|
||||
<script src="/static/js/spotsbandsandmap.js?v=1789811377"></script>
|
||||
<script src="/static/js/bands.js?v=1789811377"></script>
|
||||
<script>$(document).ready(function () {
|
||||
$("#nav-link-bands").addClass("active");
|
||||
}); <!-- highlight active page in nav --></script>
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
{% extends "skeleton.html" %}
|
||||
{% block head_extra %}
|
||||
<link rel="stylesheet" href="/static/css/style.css?v=1789763825" type="text/css">
|
||||
<link rel="stylesheet" href="/static/css/style.css?v=1789811377" 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">
|
||||
@@ -16,10 +16,10 @@
|
||||
window.fetchEventSource = fetchEventSource;
|
||||
</script>
|
||||
|
||||
<script src="/static/js/utils.js?v=1789763825"></script>
|
||||
<script src="/static/js/ui-ham.js?v=1789763825"></script>
|
||||
<script src="/static/js/geo.js?v=1789763825"></script>
|
||||
<script src="/static/js/common.js?v=1789763825"></script>
|
||||
<script src="/static/js/utils.js?v=1789811377"></script>
|
||||
<script src="/static/js/ui-ham.js?v=1789811377"></script>
|
||||
<script src="/static/js/geo.js?v=1789811377"></script>
|
||||
<script src="/static/js/common.js?v=1789811377"></script>
|
||||
{% end %}
|
||||
{% block body %}
|
||||
<div class="container">
|
||||
|
||||
@@ -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=1789763825"></script>
|
||||
<script src="/static/js/conditions.js?v=1789811377"></script>
|
||||
<script>$(document).ready(function () {
|
||||
$("#nav-link-conditions").addClass("active");
|
||||
}); <!-- highlight active page in nav --></script>
|
||||
|
||||
+2
-2
@@ -113,8 +113,8 @@
|
||||
const CARTODB_API_KEY = "{{ web_ui_options.get('cartodb_api_key', '') }}";
|
||||
</script>
|
||||
|
||||
<script src="/static/js/spotsbandsandmap.js?v=1789763825"></script>
|
||||
<script src="/static/js/map.js?v=1789763825"></script>
|
||||
<script src="/static/js/spotsbandsandmap.js?v=1789811377"></script>
|
||||
<script src="/static/js/map.js?v=1789811377"></script>
|
||||
<script>$(document).ready(function () {
|
||||
$("#nav-link-map").addClass("active");
|
||||
}); <!-- highlight active page in nav --></script>
|
||||
|
||||
@@ -125,8 +125,8 @@
|
||||
|
||||
</div>
|
||||
|
||||
<script src="/static/js/spotsbandsandmap.js?v=1789763825"></script>
|
||||
<script src="/static/js/spots.js?v=1789763825"></script>
|
||||
<script src="/static/js/spotsbandsandmap.js?v=1789811377"></script>
|
||||
<script src="/static/js/spots.js?v=1789811377"></script>
|
||||
<script>$(document).ready(function () {
|
||||
$("#nav-link-spots").addClass("active");
|
||||
}); <!-- highlight active page in nav --></script>
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/static/js/status.js?v=1789763826"></script>
|
||||
<script src="/static/js/status.js?v=1789811377"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$("#nav-link-status").addClass("active");
|
||||
|
||||
Reference in New Issue
Block a user