From 556554b1a76743989fa88877e7f694b918f770cf Mon Sep 17 00:00:00 2001 From: Walter Boring Date: Fri, 26 Sep 2025 10:57:23 -0400 Subject: [PATCH] Fixed stats issue with tcpkiss client. The tcpkiss client's stats method wasn't serializing all of the datetime objects. This patch ensures that all the dates in the stats are serializable when requested. --- aprsd/client/drivers/aprsis.py | 2 +- aprsd/client/drivers/tcpkiss.py | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/aprsd/client/drivers/aprsis.py b/aprsd/client/drivers/aprsis.py index c7013d6..188fe15 100644 --- a/aprsd/client/drivers/aprsis.py +++ b/aprsd/client/drivers/aprsis.py @@ -180,7 +180,7 @@ class APRSISDriver: LOG.warning('client is None, might be resetting.') self.connected = False - def stats(self, serializable=False) -> dict: + def stats(self, serializable: bool = False) -> dict: stats = {} if self.is_configured(): if self._client: diff --git a/aprsd/client/drivers/tcpkiss.py b/aprsd/client/drivers/tcpkiss.py index 3d58da3..3a0c391 100644 --- a/aprsd/client/drivers/tcpkiss.py +++ b/aprsd/client/drivers/tcpkiss.py @@ -271,8 +271,19 @@ class TCPKISSDriver: """ if serializable: keepalive = self.keepalive.isoformat() + if self.last_packet_sent: + last_packet_sent = self.last_packet_sent.isoformat() + else: + last_packet_sent = 'None' + if self.last_packet_received: + last_packet_received = self.last_packet_received.isoformat() + else: + last_packet_received = 'None' else: keepalive = self.keepalive + last_packet_sent = self.last_packet_sent + last_packet_received = self.last_packet_received + stats = { 'client': self.__class__.__name__, 'transport': self.transport, @@ -280,8 +291,8 @@ class TCPKISSDriver: 'path': self.path, 'packets_sent': self.packets_sent, 'packets_received': self.packets_received, - 'last_packet_sent': self.last_packet_sent, - 'last_packet_received': self.last_packet_received, + 'last_packet_sent': last_packet_sent, + 'last_packet_received': last_packet_received, 'connection_keepalive': keepalive, 'host': CONF.kiss_tcp.host, 'port': CONF.kiss_tcp.port,