From eed7e8801eb3dd1784bd9bbc26fce870cccb4338 Mon Sep 17 00:00:00 2001 From: Chris Doyle Date: Mon, 4 Mar 2024 21:33:06 +0000 Subject: [PATCH] chore: utcfromtimestamp is deprecated in python 3.12. This commit switched to use fromtimestamp and pass in a timezone so the datetime is tz aware. In order to keep inline with the existing code I have updated the fromts which held reference to the utcfromtimestamp function to now hold a functool.parital function which will insert the tz on any function calls to fromts Signed-off-by: Chris Doyle --- chaosreport/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/chaosreport/__init__.py b/chaosreport/__init__.py index 22699f6..ccd060a 100644 --- a/chaosreport/__init__.py +++ b/chaosreport/__init__.py @@ -9,7 +9,8 @@ import subprocess import tempfile from base64 import b64encode -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone +from functools import partial from typing import Any, Dict, List import cairosvg @@ -464,7 +465,7 @@ def generate_chart_from_prometheus(run: Run, export_format: str): # now we have our range of abscissa, let's map those # timestamps to formatted strings x = sorted(list(x)) - fromts = datetime.utcfromtimestamp + fromts = partial(datetime.fromtimestamp, tz=timezone.utc) chart.x_labels = [ fromts(v).strftime("%Y-%m-%d\n %H:%M:%S") for v in x ]