Replace deprecated datetime.utcnow()

The datetime.utcnow() is deprecated in Python 3.12.
Replace datetime.utcnow() with
datetime.now(datetime.timezone.utc).replace(tzinfo=None).

Change-Id: I9bf6f69d9e174d490bb4f3eaef3b364ddf97a954
Signed-off-by: Takashi Natsume <takanattie@gmail.com>
This commit is contained in:
Takashi Natsume 2024-09-29 21:28:47 +09:00
parent 29545a5109
commit 50b0b60227

View File

@ -76,7 +76,8 @@ def main():
# with zuulv3 native jobs and ansible capture it may become # with zuulv3 native jobs and ansible capture it may become
# clearer what to do # clearer what to do
if HAS_DATE.search(line) is None: if HAS_DATE.search(line) is None:
now = datetime.datetime.utcnow() now = datetime.datetime.now(datetime.timezone.utc).replace(
tzinfo=None)
ts_line = ("%s | %s" % ( ts_line = ("%s | %s" % (
now.strftime("%Y-%m-%d %H:%M:%S.%f")[:-3], now.strftime("%Y-%m-%d %H:%M:%S.%f")[:-3],
line)) line))