mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-09-21 06:47:42 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e33eecbc4e |
@@ -156,13 +156,3 @@ def get_callsign_object_from_pyhamtools_callinfo(callsign, callinfo):
|
|||||||
except (KeyError, ValueError):
|
except (KeyError, ValueError):
|
||||||
# Unknown callsign, can't look anything up, return a Callsign object with basic data so that gets cached
|
# Unknown callsign, can't look anything up, return a Callsign object with basic data so that gets cached
|
||||||
return Callsign(call=callsign)
|
return Callsign(call=callsign)
|
||||||
|
|
||||||
|
|
||||||
def decode_telnet_bytes(data: bytes) -> str:
|
|
||||||
"""Decode a line of text received from a telnet connection, which might be UTF-8 or Latin-1 depending on the
|
|
||||||
whims of the server owner."""
|
|
||||||
|
|
||||||
try:
|
|
||||||
return data.decode("utf-8")
|
|
||||||
except UnicodeDecodeError:
|
|
||||||
return data.decode("latin-1")
|
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ import telnetlib3
|
|||||||
|
|
||||||
from core.config import SERVER_OWNER_CALLSIGN
|
from core.config import SERVER_OWNER_CALLSIGN
|
||||||
from data.spot import Spot
|
from data.spot import Spot
|
||||||
from providers.spot.spot_provider import SpotProvider
|
from providers.spot.spot_provider import SpotProvider, decode_telnet_bytes
|
||||||
from core.utils import decode_telnet_bytes
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ import telnetlib3
|
|||||||
|
|
||||||
from core.config import SERVER_OWNER_CALLSIGN
|
from core.config import SERVER_OWNER_CALLSIGN
|
||||||
from data.spot import Spot
|
from data.spot import Spot
|
||||||
from providers.spot.spot_provider import SpotProvider
|
from providers.spot.spot_provider import SpotProvider, decode_telnet_bytes
|
||||||
from core.utils import decode_telnet_bytes
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,18 @@ import pytz
|
|||||||
from core.data_store import DATA_STORE
|
from core.data_store import DATA_STORE
|
||||||
|
|
||||||
|
|
||||||
|
def decode_telnet_bytes(data: bytes) -> str:
|
||||||
|
"""Decode a line of text received from a telnet connection. DX cluster and RBN nodes are inconsistent about the
|
||||||
|
character encoding they use for spot comments: most send UTF-8, but some older ones send Latin-1/CP1252. Try
|
||||||
|
UTF-8 first, since valid multi-byte UTF-8 sequences are very unlikely to occur by chance in Latin-1 text, then
|
||||||
|
fall back to Latin-1, which can decode any byte sequence without raising."""
|
||||||
|
|
||||||
|
try:
|
||||||
|
return data.decode("utf-8")
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
return data.decode("latin-1")
|
||||||
|
|
||||||
|
|
||||||
class SpotProvider:
|
class SpotProvider:
|
||||||
"""Generic spot provider class. Subclasses of this query the individual APIs for data."""
|
"""Generic spot provider class. Subclasses of this query the individual APIs for data."""
|
||||||
|
|
||||||
|
|||||||
@@ -123,19 +123,13 @@ class TelnetServer:
|
|||||||
|
|
||||||
except asyncio.CancelledError:
|
except asyncio.CancelledError:
|
||||||
pass
|
pass
|
||||||
except (TimeoutError, ConnectionResetError):
|
|
||||||
logger.debug("Telnet client connection timed out or was reset by client")
|
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.exception("Exception handling telnet client")
|
logger.exception("Exception handling telnet client")
|
||||||
finally:
|
finally:
|
||||||
logger.debug("Telnet client disconnected")
|
logger.debug("Telnet client disconnected")
|
||||||
self._clients.remove(writer)
|
self._clients.remove(writer)
|
||||||
try:
|
|
||||||
writer.close()
|
writer.close()
|
||||||
await writer.wait_closed()
|
await writer.wait_closed()
|
||||||
except (TimeoutError, ConnectionResetError, OSError):
|
|
||||||
# Socket already closed or timed out, don't care as we were getting rid of it anyway
|
|
||||||
pass
|
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
"""Stops the telnet server"""
|
"""Stops the telnet server"""
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/add-spot.js?v=1789933862"></script>
|
<script src="/static/js/add-spot.js?v=1789927308"></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>
|
||||||
|
|||||||
@@ -85,7 +85,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/static/js/alerts.js?v=1789933862"></script>
|
<script src="/static/js/alerts.js?v=1789927308"></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=1789933862"></script>
|
<script src="/static/js/spotsbandsandmap.js?v=1789927308"></script>
|
||||||
<script src="/static/js/bands.js?v=1789933862"></script>
|
<script src="/static/js/bands.js?v=1789927308"></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=1789933862" type="text/css">
|
<link rel="stylesheet" href="/static/css/style.css?v=1789927308" 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=1789933862"></script>
|
<script src="/static/js/utils.js?v=1789927308"></script>
|
||||||
<script src="/static/js/ui-ham.js?v=1789933862"></script>
|
<script src="/static/js/ui-ham.js?v=1789927308"></script>
|
||||||
<script src="/static/js/geo.js?v=1789933862"></script>
|
<script src="/static/js/geo.js?v=1789927308"></script>
|
||||||
<script src="/static/js/common.js?v=1789933862"></script>
|
<script src="/static/js/common.js?v=1789927308"></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=1789933862"></script>
|
<script src="/static/js/conditions.js?v=1789927308"></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=1789933861"></script>
|
<script src="/static/js/spotsbandsandmap.js?v=1789927308"></script>
|
||||||
<script src="/static/js/map.js?v=1789933861"></script>
|
<script src="/static/js/map.js?v=1789927308"></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=1789933861"></script>
|
<script src="/static/js/spotsbandsandmap.js?v=1789927308"></script>
|
||||||
<script src="/static/js/spots.js?v=1789933861"></script>
|
<script src="/static/js/spots.js?v=1789927308"></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=1789933862"></script>
|
<script src="/static/js/status.js?v=1789927308"></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