From 86bb3402db4c82fbf5580b2fd03338a8b12790ac Mon Sep 17 00:00:00 2001
From: Lei Yang <lei.yang@windriver.com>
Date: Mon, 7 Apr 2025 20:19:23 +0800
Subject: [PATCH] Fix datetime.utcnow() deprecation warning in Python 3.12

Replace all instances of datetime.datetime.utcnow() with
datetime.datetime.now(datetime.timezone.utc) to address
the deprecation warning introduced in Python 3.12.

This change ensures compatibility with Python 3.12+ while
maintaining the same UTC timestamp functionality in a
timezone-aware manner as recommended in the deprecation notice.

Signed-off-by: Lei Yang <lei.yang@windriver.com>
---
 lavacli/commands/jobs.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/lavacli/commands/jobs.py b/lavacli/commands/jobs.py
index e37ec20..f57fcd0 100644
--- a/lavacli/commands/jobs.py
+++ b/lavacli/commands/jobs.py
@@ -594,7 +594,7 @@ def handle_logs(proxy, options, config):
             print_logs(
                 [
                     {
-                        "dt": datetime.datetime.utcnow().isoformat(),
+                        "dt": datetime.datetime.now(datetime.timezone.utc).isoformat(),
                         "lvl": "info",
                         "msg": "[lavacli] Failure comment: %s"
                         % details["failure_comment"],
@@ -642,7 +642,7 @@ def handle_resubmit(proxy, options, config):
         print_logs(
             [
                 {
-                    "dt": datetime.datetime.utcnow().isoformat(),
+                    "dt": datetime.datetime.now(datetime.timezone.utc).isoformat(),
                     "lvl": "info",
                     "msg": "[lavacli] Job %s submitted" % job_id,
                 }
@@ -663,7 +663,7 @@ def follow_logs(job_id, proxy, options, config):
             print_logs(
                 [
                     {
-                        "dt": datetime.datetime.utcnow().isoformat(),
+                        "dt": datetime.datetime.now(datetime.timezone.utc).isoformat(),
                         "lvl": "info",
                         "msg": "[lavacli] Seeing %s logs" % job,
                     }
@@ -683,7 +683,7 @@ def handle_run(proxy, options, config):
     print_logs(
         [
             {
-                "dt": datetime.datetime.utcnow().isoformat(),
+                "dt": datetime.datetime.now(datetime.timezone.utc).isoformat(),
                 "lvl": "info",
                 "msg": "[lavacli] Job %s submitted" % job_id,
             }
@@ -699,7 +699,7 @@ def handle_run(proxy, options, config):
             print_logs(
                 [
                     {
-                        "dt": datetime.datetime.utcnow().isoformat(),
+                        "dt": datetime.datetime.now(datetime.timezone.utc).isoformat(),
                         "lvl": "info",
                         "msg": "[lavacli] Seeing %s logs" % job,
                     }
-- 
2.34.1

