From ea9f9f0afdd801eba9ae85bc8bd9aff0afabf8a5 Mon Sep 17 00:00:00 2001 From: Jason Ertel Date: Thu, 28 Dec 2023 19:28:39 -0500 Subject: [PATCH] upgrade to Python 3.12 and remove deprecated utcnow() --- CHANGELOG.md | 15 +++++++++++++++ src/vuegraf/vuegraf.py | 6 +++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3631e2..9599887 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,21 @@ ## Other changes - TBD +# 1.6.1 + +## Breaking changes + +- None + +## New features + +- None + +## Other changes + +- Upgrade to Python 3.12.1, replace deprecated datetime invocations - [#141](https://github.com/jertel/vuegraf/pull/141) - #jertel +- Fixed extractDataPoints to recurse correctly for nested devices - [#140](https://github.com/jertel/vuegraf/pull/140) - #cdolghier + # 1.6.0 ## Breaking changes diff --git a/src/vuegraf/vuegraf.py b/src/vuegraf/vuegraf.py index 21f0f80..bac981c 100644 --- a/src/vuegraf/vuegraf.py +++ b/src/vuegraf/vuegraf.py @@ -31,7 +31,7 @@ # flush=True helps when running in a container without a tty attached # (alternatively, "python -u" or PYTHONUNBUFFERED will help here) def log(level, msg): - now = datetime.datetime.utcnow() + now = datetime.datetime.now(datetime.UTC) print('{} | {} | {}'.format(now, level.ljust(5), msg), flush=True) def info(msg): @@ -191,7 +191,7 @@ def extractDataPoints(device, usageDataPoints, pointType=None, historyStartTime= usageDataPoints.append(createDataPoint(account, chanName, watts, timestamp, 'Day')) index += 1 -startupTime = datetime.datetime.utcnow() +startupTime = datetime.datetime.now(datetime.UTC) try: #argparse includes default -h / --help as command line input parser = argparse.ArgumentParser( @@ -306,7 +306,7 @@ def extractDataPoints(device, usageDataPoints, pointType=None, historyStartTime= pastDay = pastDay.replace(hour=23, minute=59, second=59, microsecond=0) while running: - now = datetime.datetime.utcnow() + now = datetime.datetime.now(datetime.UTC) curDay = datetime.datetime.now() stopTime = now - datetime.timedelta(seconds=lagSecs) collectDetails = detailedDataEnabled and detailedIntervalSecs > 0 and (stopTime - detailedStartTime).total_seconds() >= detailedIntervalSecs