Continue Flask migration.

This commit is contained in:
yohan 2024-06-02 12:24:09 +02:00
parent 5c85e194a3
commit 8001a553a2

View File

@ -121,7 +121,7 @@ def get_metric(metric, current_time, interval):
try:
r = requests.get(url)
data = json.loads(r.text)
timestamp = datetime.fromisoformat(data['timestamp']).replace(tzinfo=timezone.utc).timestamp()
timestamp = data['timestamp'].fromisoformat().replace(tzinfo=timezone.utc).timestamp()
if current_time - timestamp < interval * 2:
return data['value']
else:
@ -139,7 +139,7 @@ def get_forced_mode():
#cur.execute("SELECT value, timestamp FROM set_mode WHERE name='mode'")
#row = cur.fetchone()
data = dict(zip(['value', 'timestamp'], row))
timestamp = datetime.fromisoformat(data['timestamp']).replace(tzinfo=timezone.utc).timestamp()
timestamp = data['timestamp'].fromisoformat().replace(tzinfo=timezone.utc).timestamp()
# We ignore old targets but never ignore absence modes
if data['value'] in targets and time.time() - timestamp > forced_mode_duration:
logging.debug("Ignoring old set mode.")