1
0
mirror of https://github.com/craigerl/aprsd.git synced 2025-10-29 12:00:22 -04:00

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.
This commit is contained in:
Walter Boring 2025-09-26 10:57:23 -04:00
parent f3039ebfa1
commit 556554b1a7
2 changed files with 14 additions and 3 deletions

View File

@ -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:

View File

@ -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,