Fixed datetime json export
Some checks reported errors
continuous-integration/drone/push Build encountered an error

This commit is contained in:
Scharnitzky Donát 2020-04-21 19:25:27 +02:00
parent 7e9354be18
commit ed6ed3baf0

View File

@ -33,7 +33,7 @@ class ConsumerLocator:
:param communicator: the :class:'communicator.Communicator' instance that will be used for the low level communication. :param communicator: the :class:'communicator.Communicator' instance that will be used for the low level communication.
""" """
self.red = redisconnector self.red = redisconnector
self.red.consumerlist = [{"Host": KNOWNCONSUMER, "State": True, "LastOk": datetime.datetime.now()}] self.red.consumerlist = [{"Host": KNOWNCONSUMER, "State": True, "LastOk": datetime.datetime.now().timestamp()}]
self.red.currentconsumer = self.red.consumerlist[0] self.red.currentconsumer = self.red.consumerlist[0]
self.communicator = communicator self.communicator = communicator
@ -55,7 +55,7 @@ class ConsumerLocator:
contains = True contains = True
if not contains: if not contains:
self.red.consumerlist.append({"Host": recconsumer, "State": True, "LastOk": datetime.datetime.now()}) self.red.consumerlist.append({"Host": recconsumer, "State": True, "LastOk": datetime.datetime.now().timestamp()})
self.updateconsumerlist() self.updateconsumerlist()
@ -71,10 +71,10 @@ class ConsumerLocator:
for consumer in self.red.consumerlist: for consumer in self.red.consumerlist:
if not self.communicator.checkconsumer(consumer["Host"]): if not self.communicator.checkconsumer(consumer["Host"]):
consumer["State"] = False consumer["State"] = False
if datetime.datetime.now() - consumer["LastOk"] > datetime.timedelta(hours=1): if datetime.datetime.now() - datetime.datetime.fromtimestamp(consumer["LastOk"]) > datetime.timedelta(hours=1):
removelist.append(consumer) removelist.append(consumer)
else: else:
consumer["LastOk"] = datetime.datetime.now() consumer["LastOk"] = datetime.datetime.now().timestamp()
consumer["State"] = True consumer["State"] = True
for rem in removelist: for rem in removelist:
self.red.consumerlist.remove(rem) self.red.consumerlist.remove(rem)