Skip to content

Commit

Permalink
Remove datetime.utcnow() support from OverrideValidation.py
Browse files Browse the repository at this point in the history
  • Loading branch information
antklein committed Oct 6, 2023
1 parent 6960fd6 commit b015a1d
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions BaseTools/Plugin/OverrideValidation/OverrideValidation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
##


import logging
import os
import io
import sys
from datetime import datetime
import subprocess
import argparse
import hashlib
import io
import logging
import os
import re
import sys
from datetime import datetime, timezone
from io import StringIO

#
Expand All @@ -25,11 +24,12 @@
#
#
try:
from edk2toolext.environment.plugintypes.uefi_build_plugin import IUefiBuildPlugin
from edk2toollib.uefi.edk2.parsers.inf_parser import InfParser
from edk2toollib.utility_functions import RunCmd
from edk2toolext.environment.plugintypes.uefi_build_plugin import \
IUefiBuildPlugin
from edk2toollib.uefi.edk2.parsers.dsc_parser import *
from edk2toollib.uefi.edk2.parsers.inf_parser import InfParser
from edk2toollib.uefi.edk2.path_utilities import Edk2Path
from edk2toollib.utility_functions import RunCmd

#Tuple for (version, entrycount)
FORMAT_VERSION_1 = (1, 4) #Version 1: #OVERRIDE : VERSION | PATH_TO_MODULE | HASH | YYYY-MM-DDThh-mm-ss
Expand Down Expand Up @@ -304,6 +304,7 @@ def override_process_line_with_version1(self, thebuilder, filelist, OverrideEntr
# Step 4: Parse the time of hash generation
try:
EntryTimestamp = datetime.strptime(OverrideEntry[3].strip(), "%Y-%m-%dT%H-%M-%S")
EntryTimestamp = EntryTimestamp.replace(tzinfo=timezone.utc)
except ValueError:
logging.error("Inf Override Parse Error, override parameter has invalid timestamp %s" %(OverrideEntry[3].strip()))
result = self.OverrideResult.OR_INVALID_FORMAT
Expand All @@ -318,7 +319,7 @@ def override_process_line_with_version1(self, thebuilder, filelist, OverrideEntr
# Step 6: House keeping
# Process the path to workspace/package path based add it to the parent node
overridden_rel_path = self.PathTool.GetEdk2RelativePathFromAbsolutePath(fullpath)
date_delta = datetime.utcnow() - EntryTimestamp
date_delta = datetime.now(timezone.utc) - EntryTimestamp

m_node.entry_hash = EntryHash
m_node.path = overridden_rel_path
Expand Down Expand Up @@ -401,7 +402,7 @@ def override_log_print(self, thebuilder, modulelist, status):
with open(logfile, 'w') as log:
log.write("Platform: %s\n" %(thebuilder.env.GetValue("PRODUCT_NAME")))
log.write("Version: %s\n" %(thebuilder.env.GetValue("BLD_*_BUILDID_STRING")))
log.write("Date: %s\n" %(datetime.utcnow().strftime("%Y-%m-%dT%H-%M-%S")))
log.write("Date: %s\n" %(datetime.now(timezone.utc).strftime("%Y-%m-%dT%H-%M-%S")))
log.write("Commit: %s\n" %(thebuilder.env.GetValue("BLD_*_BUILDSHA")))
log.write("State: %d/%d\n" %(status[0], status[1]))

Expand Down

0 comments on commit b015a1d

Please sign in to comment.