From 29eea1edc0431be396def65ffbb466acdf03ce66 Mon Sep 17 00:00:00 2001 From: Ian Renton Date: Sat, 12 Sep 2026 08:40:50 +0100 Subject: [PATCH] Telnet fixes and banner --- telnetserver/telnetserver.py | 55 ++++++++++++++++++++++++++++++------ templates/add_spot.html | 2 +- templates/alerts.html | 2 +- templates/bands.html | 4 +-- templates/base.html | 10 +++---- templates/conditions.html | 2 +- templates/map.html | 4 +-- templates/spots.html | 4 +-- templates/status.html | 2 +- 9 files changed, 61 insertions(+), 24 deletions(-) diff --git a/telnetserver/telnetserver.py b/telnetserver/telnetserver.py index 2f19d20..cfe3c29 100644 --- a/telnetserver/telnetserver.py +++ b/telnetserver/telnetserver.py @@ -4,6 +4,7 @@ import threading from datetime import datetime import pytz +from pyhamtools import callinfo from core.config import SERVER_OWNER_CALLSIGN from core.constants import SOFTWARE_VERSION @@ -12,6 +13,33 @@ from data.spot import Spot logger = logging.getLogger(__name__) +BANNER = ( + """ + == + ==== ##### ##### #### + == == ..### ..### ..### + == ###==######## ###### ####### .####### ###### .### ###### + ==###.. ..###..### ###..###...###. .###..### ###..### .### ###..### + ==###.### .### .###.### .### .### .### .### .### .### .### .####### + == .###.###.### .###.### .### .### ### .### .### .### .### .### .###... + == ...### .####### ..###### ..##### #### #####..###### #####..###### + == .###. .###=.. ...... ..... .... ..... ...... ..... ...... + == %% ... %%%%###== + == %%%%%%%%%%%#####== \r\n""" + + "== ..... ==" + + f"Welcome to Spothole v{SOFTWARE_VERSION}".rjust(56) + + "\r\n" + + "========================" + + f"This server is run by {SERVER_OWNER_CALLSIGN}".rjust(56) +) + +MOTD = ( + "Spothole's telnet server is a new feature and may not work properly in all\r\n" + + "loggers. Please give it a try in your logger of choice and let me know if it\r\n" + + "(or doesn't!) Please note that DXSpider-like commands are not yet supported\r\n" + + "so you are not yet able to filter spots server-side or log in at all." +) + class TelnetServer: """A telnet server designed to provide spots in the same format as DXSpider, for compatibility with desktop loggers.""" @@ -56,15 +84,22 @@ class TelnetServer: logger.debug("Telnet client connected") self._clients.add(writer) - # Print MOTD + # Print banner and MOTD try: - motd = ( - f"Welcome to Spothole v{SOFTWARE_VERSION}.\r\nThis server is run by {SERVER_OWNER_CALLSIGN}.\r\n===\r\n" + text = ( + BANNER + + "\r\n\r\n" + + "================================================================================" + + "\r\n" + + MOTD + + "\r\n" + + "================================================================================" + + "\r\n\r\n" ) - writer.write(motd.encode("ascii")) + writer.write(text.encode("ascii")) await writer.drain() except Exception: - pass + logger.exception("Exception printing telnet motd") # Set up buffer for user input input_buffer = "" @@ -163,12 +198,14 @@ class TelnetServer: @staticmethod def _format_dxspider_spot(spot: Spot) -> str: """Formats a spot into the format DXspider uses: - DX de CALLSIGN: FREQUENCY DX_CALLSIGN COMMENTS TIME_UTC""" + DX de CALLSIGN: FREQUENCY DX_CALLSIGN COMMENTS TIME_UTC. + Always use the base call for the spotter to save space. Everything must align properly to parse in clients, + and everything must be renderable in ASCII.""" - de_call = f"{spot.de_call + ':' if spot.de_call else '???:'!s:<9}" - frequency = f"{(spot.freq / 1000.0):8.1f}" + de_call = f"{callinfo.Callinfo.get_homecall(spot.de_call)[:6] + ':' if spot.de_call else '???:'!s:<7}" + frequency = f"{(spot.freq / 1000.0):10.1f}" dx_call = f"{spot.dx_call!s:<12}" - comment = f"{spot.comment[:29]:<30}" + comment = f"{spot.comment.encode('ascii', errors='ignore').decode()[:29]:<30}" if spot.time: timestamp = datetime.fromtimestamp(spot.time, tz=pytz.utc).strftime("%H%M") + "Z" else: diff --git a/templates/add_spot.html b/templates/add_spot.html index 583505b..087702c 100644 --- a/templates/add_spot.html +++ b/templates/add_spot.html @@ -77,7 +77,7 @@ - + diff --git a/templates/alerts.html b/templates/alerts.html index 7a18ae8..760b795 100644 --- a/templates/alerts.html +++ b/templates/alerts.html @@ -83,7 +83,7 @@ - + diff --git a/templates/bands.html b/templates/bands.html index 7737dc8..8b77f3a 100644 --- a/templates/bands.html +++ b/templates/bands.html @@ -76,8 +76,8 @@ - - + + diff --git a/templates/base.html b/templates/base.html index da7a6e6..7cd3d3e 100644 --- a/templates/base.html +++ b/templates/base.html @@ -1,6 +1,6 @@ {% extends "skeleton.html" %} {% block head_extra %} - + @@ -16,10 +16,10 @@ window.fetchEventSource = fetchEventSource; - - - - + + + + {% end %} {% block body %}
diff --git a/templates/conditions.html b/templates/conditions.html index 1b10052..3cbd0fd 100644 --- a/templates/conditions.html +++ b/templates/conditions.html @@ -284,7 +284,7 @@
- + diff --git a/templates/map.html b/templates/map.html index ff9242e..8ac296e 100644 --- a/templates/map.html +++ b/templates/map.html @@ -113,8 +113,8 @@ const CARTODB_API_KEY = "{{ web_ui_options.get('cartodb_api_key', '') }}"; - - + + diff --git a/templates/spots.html b/templates/spots.html index 9a8f312..a57df67 100644 --- a/templates/spots.html +++ b/templates/spots.html @@ -125,8 +125,8 @@ - - + + diff --git a/templates/status.html b/templates/status.html index b2ef2ae..4bb69c5 100644 --- a/templates/status.html +++ b/templates/status.html @@ -96,7 +96,7 @@ - +