From 98ce50565a4f71544f62ddab5b8e7411745beca1 Mon Sep 17 00:00:00 2001 From: Julien Cristau Date: Mon, 30 Jun 2025 14:31:43 +0200 Subject: [PATCH] run-task: replace another use of datetime.utcnow() ``` /usr/local/bin/run-task:330: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC). now = datetime.datetime.utcnow().isoformat().encode("utf-8") ``` --- src/taskgraph/run-task/run-task | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/taskgraph/run-task/run-task b/src/taskgraph/run-task/run-task index 42a97be2a..f14267d72 100755 --- a/src/taskgraph/run-task/run-task +++ b/src/taskgraph/run-task/run-task @@ -327,9 +327,9 @@ def get_posix_user_group(user, group): def write_audit_entry(path, msg): - now = datetime.datetime.utcnow().isoformat().encode("utf-8") + now = datetime.datetime.now(tz=datetime.timezone.utc).isoformat().encode("utf-8") with open(path, "ab") as fh: - fh.write(b"[%sZ %s] %s\n" % (now, os.environb.get(b"TASK_ID", b"UNKNOWN"), msg)) + fh.write(b"[%s %s] %s\n" % (now, os.environb.get(b"TASK_ID", b"UNKNOWN"), msg)) WANTED_DIR_MODE = stat.S_IXUSR | stat.S_IRUSR | stat.S_IWUSR