From 03e3efaee29db784d9781befede3a34ef8a3d92e Mon Sep 17 00:00:00 2001 From: Isaac Date: Sat, 17 Aug 2024 15:52:07 -0500 Subject: [PATCH 1/2] Fix datetime.datetime.utcnow() Update datetime since datetime.utcnow() was deprecated since Python 3.12. --- howdy/src/compare.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/howdy/src/compare.py b/howdy/src/compare.py index 0b2213f6..d9a7b336 100644 --- a/howdy/src/compare.py +++ b/howdy/src/compare.py @@ -17,7 +17,7 @@ import configparser import dlib import cv2 -import datetime +from datetime import timezone, datetime import atexit import subprocess import snapshot @@ -71,7 +71,7 @@ def make_snapshot(type): """Generate snapshot after detection""" snapshot.generate(snapframes, [ type + _(" LOGIN"), - _("Date: ") + datetime.datetime.utcnow().strftime("%Y/%m/%d %H:%M:%S UTC"), + _("Date: ") + datetime.now(timezone.utc).strftime("%Y/%m/%d %H:%M:%S UTC"), _("Scan time: ") + str(round(time.time() - timings["fr"], 2)) + "s", _("Frames: ") + str(frames) + " (" + str(round(frames / (time.time() - timings["fr"]), 2)) + "FPS)", _("Hostname: ") + os.uname().nodename, From cd808762c921d4f53f7f2443a1ab47ecb8ef98f6 Mon Sep 17 00:00:00 2001 From: thecalamityjoe87 Date: Sun, 1 Sep 2024 15:06:35 -0500 Subject: [PATCH 2/2] Update other areas where datetime is invoked --- howdy/src/cli/snap.py | 4 ++-- howdy/src/snapshot.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/howdy/src/cli/snap.py b/howdy/src/cli/snap.py index 4d0d2cab..f8ba3f9d 100644 --- a/howdy/src/cli/snap.py +++ b/howdy/src/cli/snap.py @@ -3,7 +3,7 @@ # Import required modules import os import configparser -import datetime +from datetime import timezone, datetime import snapshot import paths_factory from recorders.video_capture import VideoCapture @@ -41,7 +41,7 @@ # Generate a snapshot image from the frames file = snapshot.generate(frames, [ _("GENERATED SNAPSHOT"), - _("Date: ") + datetime.datetime.utcnow().strftime("%Y/%m/%d %H:%M:%S UTC"), + _("Date: ") + datetime.now(timezone.utc).strftime("%Y/%m/%d %H:%M:%S UTC"), _("Dark threshold config: ") + str(config.getfloat("video", "dark_threshold", fallback=60.0)), _("Certainty config: ") + str(config.getfloat("video", "certainty", fallback=3.5)) ]) diff --git a/howdy/src/snapshot.py b/howdy/src/snapshot.py index ae40d47d..81e84d87 100644 --- a/howdy/src/snapshot.py +++ b/howdy/src/snapshot.py @@ -3,7 +3,7 @@ # Import modules import cv2 import os -import datetime +from datetime import timezone, datetime import numpy as np import paths_factory @@ -53,7 +53,7 @@ def generate(frames, text_lines): os.makedirs(paths_factory.snapshots_dir_path()) # Generate a filename based on the current time - filename = datetime.datetime.utcnow().strftime("%Y%m%dT%H%M%S.jpg") + filename = datetime.now(timezone.utc).strftime("%Y%m%dT%H%M%S.jpg") filepath = paths_factory.snapshot_path(filename) # Write the image to that file cv2.imwrite(filepath, snap)