From abf4e4d58604249da5235eb361298d863a974824 Mon Sep 17 00:00:00 2001 From: Andreas Wrede Date: Tue, 15 Mar 2022 16:20:12 -0400 Subject: [PATCH] init display state pproperly --- hbdclass.py | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/hbdclass.py b/hbdclass.py index f0faf32..2ba8f6f 100644 --- a/hbdclass.py +++ b/hbdclass.py @@ -50,8 +50,19 @@ class Connection: def registerDns(self): Host.dnsQ.put((self.host.name, self.addr)) - def statedict(self, Null=False): + def clearstate(self): d = {} + d["addr"] = "" + d["rtt"] = "" + d["lastbeat"] = "" + d["state"] = "" + d["statetime"] = "" + d["deltastatetime"] = "" + d["rttstate"] = "" + return d + + def statedict(self, Null=False): + d = self.clearstate() now = time.time() if not Null: d["addr"] = self.addr @@ -93,21 +104,9 @@ class Connection: else: # d['deltastatetime'] = time.strftime("%S", time.gmtime(delta)) d["deltastatetime"] = "%i secs" % (delta) - if self.state == Connection.UNKNOWN and now - self.lastbeat > 86400 * 10: - d["state"] = "" - d["addr"] = "" - d["rttstate"] = "" - d["statetime"] = "" - d["lastbeat"] = "" + if self.state == Connection.UNKNOWN and now - self.lastbeat > 86400 * 10: + d = self.clearstate() - else: - d["addr"] = "" - d["rtt"] = "" - d["lastbeat"] = "" - d["state"] = "" - d["statetime"] = "" - d["deltastatetime"] = "" - d["rttstate"] = "" return d def headerdict(self, afam):