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.
"""
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.communicator = communicator
@ -55,7 +55,7 @@ class ConsumerLocator:
contains = True
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()
@ -71,10 +71,10 @@ class ConsumerLocator:
for consumer in self.red.consumerlist:
if not self.communicator.checkconsumer(consumer["Host"]):
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)
else:
consumer["LastOk"] = datetime.datetime.now()
consumer["LastOk"] = datetime.datetime.now().timestamp()
consumer["State"] = True
for rem in removelist:
self.red.consumerlist.remove(rem)