From be6357a552e8c05b5fd5a94d4fb6318abaf78cfc Mon Sep 17 00:00:00 2001 From: Hemna Date: Sat, 23 Nov 2024 09:15:30 -0500 Subject: [PATCH] Put safety checks around the timeago for keepalive If the client isn't running yet, the keepalive date will be None, so we need a check around it before running timeago on it. --- aprsd/threads/keep_alive.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/aprsd/threads/keep_alive.py b/aprsd/threads/keep_alive.py index 309ac8c..886406e 100644 --- a/aprsd/threads/keep_alive.py +++ b/aprsd/threads/keep_alive.py @@ -100,7 +100,11 @@ class KeepAliveThread(APRSDThread): # check the APRS connection cl = client_factory.create() cl_stats = cl.stats() - keepalive = timeago.format(cl_stats.get("keepalive", None)) + ka = cl_stats.get("keepalive", None) + if ka: + keepalive = timeago.format(ka) + else: + keepalive = "N/A" LOGU.opt(colors=True).info(f"Client keepalive {keepalive}") # Reset the connection if it's dead and this isn't our # First time through the loop.