mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Use non-deprecated API for obtaining UTC time
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). Change-Id: Ia2c46fb87c544d98cc2dd68a829f67d4770b479c Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/386615 Tested-by: Łukasz Patron <priv.luk@gmail.com> Reviewed-by: Mike Frysinger <vapier@google.com> Reviewed-by: Łukasz Patron <priv.luk@gmail.com> Commit-Queue: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
b8fd19215f
commit
aadd12cb08
@ -795,8 +795,8 @@ class SyncAnalysisState:
|
|||||||
to be logged.
|
to be logged.
|
||||||
"""
|
"""
|
||||||
self._config = config
|
self._config = config
|
||||||
now = datetime.datetime.utcnow()
|
now = datetime.datetime.now(datetime.timezone.utc)
|
||||||
self._Set("main.synctime", now.isoformat(timespec="microseconds") + "Z")
|
self._Set("main.synctime", now.isoformat(timespec="microseconds"))
|
||||||
self._Set("main.version", "1")
|
self._Set("main.version", "1")
|
||||||
self._Set("sys.argv", sys.argv)
|
self._Set("sys.argv", sys.argv)
|
||||||
for key, value in superproject_logging_data.items():
|
for key, value in superproject_logging_data.items():
|
||||||
|
@ -71,7 +71,7 @@ class BaseEventLog(object):
|
|||||||
if env is None:
|
if env is None:
|
||||||
env = os.environ
|
env = os.environ
|
||||||
|
|
||||||
self.start = datetime.datetime.utcnow()
|
self.start = datetime.datetime.now(datetime.timezone.utc)
|
||||||
|
|
||||||
# Save both our sid component and the complete sid.
|
# Save both our sid component and the complete sid.
|
||||||
# We use our sid component (self._sid) as the unique filename prefix and
|
# We use our sid component (self._sid) as the unique filename prefix and
|
||||||
@ -126,7 +126,7 @@ class BaseEventLog(object):
|
|||||||
"event": event_name,
|
"event": event_name,
|
||||||
"sid": self._full_sid,
|
"sid": self._full_sid,
|
||||||
"thread": threading.current_thread().name,
|
"thread": threading.current_thread().name,
|
||||||
"time": datetime.datetime.utcnow().isoformat() + "Z",
|
"time": datetime.datetime.now(datetime.timezone.utc).isoformat(),
|
||||||
}
|
}
|
||||||
|
|
||||||
def StartEvent(self):
|
def StartEvent(self):
|
||||||
@ -147,7 +147,7 @@ class BaseEventLog(object):
|
|||||||
if result is None:
|
if result is None:
|
||||||
result = 0
|
result = 0
|
||||||
exit_event["code"] = result
|
exit_event["code"] = result
|
||||||
time_delta = datetime.datetime.utcnow() - self.start
|
time_delta = datetime.datetime.now(datetime.timezone.utc) - self.start
|
||||||
exit_event["t_abs"] = time_delta.total_seconds()
|
exit_event["t_abs"] = time_delta.total_seconds()
|
||||||
self._log.append(exit_event)
|
self._log.append(exit_event)
|
||||||
|
|
||||||
|
4
repo
4
repo
@ -173,7 +173,7 @@ if not REPO_REV:
|
|||||||
BUG_URL = "https://issues.gerritcodereview.com/issues/new?component=1370071"
|
BUG_URL = "https://issues.gerritcodereview.com/issues/new?component=1370071"
|
||||||
|
|
||||||
# increment this whenever we make important changes to this script
|
# increment this whenever we make important changes to this script
|
||||||
VERSION = (2, 36)
|
VERSION = (2, 37)
|
||||||
|
|
||||||
# increment this if the MAINTAINER_KEYS block is modified
|
# increment this if the MAINTAINER_KEYS block is modified
|
||||||
KEYRING_VERSION = (2, 3)
|
KEYRING_VERSION = (2, 3)
|
||||||
@ -838,7 +838,7 @@ def SetGitTrace2ParentSid(env=None):
|
|||||||
|
|
||||||
KEY = "GIT_TRACE2_PARENT_SID"
|
KEY = "GIT_TRACE2_PARENT_SID"
|
||||||
|
|
||||||
now = datetime.datetime.utcnow()
|
now = datetime.datetime.now(datetime.timezone.utc)
|
||||||
value = "repo-%s-P%08x" % (now.strftime("%Y%m%dT%H%M%SZ"), os.getpid())
|
value = "repo-%s-P%08x" % (now.strftime("%Y%m%dT%H%M%SZ"), os.getpid())
|
||||||
|
|
||||||
# If it's already set, then append ourselves.
|
# If it's already set, then append ourselves.
|
||||||
|
@ -108,7 +108,9 @@ class SuperprojectTestCase(unittest.TestCase):
|
|||||||
self.assertRegex(log_entry["sid"], self.FULL_SID_REGEX)
|
self.assertRegex(log_entry["sid"], self.FULL_SID_REGEX)
|
||||||
else:
|
else:
|
||||||
self.assertRegex(log_entry["sid"], self.SELF_SID_REGEX)
|
self.assertRegex(log_entry["sid"], self.SELF_SID_REGEX)
|
||||||
self.assertRegex(log_entry["time"], r"^\d+-\d+-\d+T\d+:\d+:\d+\.\d+Z$")
|
self.assertRegex(
|
||||||
|
log_entry["time"], r"^\d+-\d+-\d+T\d+:\d+:\d+\.\d+\+00:00$"
|
||||||
|
)
|
||||||
|
|
||||||
def readLog(self, log_path):
|
def readLog(self, log_path):
|
||||||
"""Helper function to read log data into a list."""
|
"""Helper function to read log data into a list."""
|
||||||
|
@ -90,7 +90,9 @@ class EventLogTestCase(unittest.TestCase):
|
|||||||
self.assertRegex(log_entry["sid"], self.FULL_SID_REGEX)
|
self.assertRegex(log_entry["sid"], self.FULL_SID_REGEX)
|
||||||
else:
|
else:
|
||||||
self.assertRegex(log_entry["sid"], self.SELF_SID_REGEX)
|
self.assertRegex(log_entry["sid"], self.SELF_SID_REGEX)
|
||||||
self.assertRegex(log_entry["time"], r"^\d+-\d+-\d+T\d+:\d+:\d+\.\d+Z$")
|
self.assertRegex(
|
||||||
|
log_entry["time"], r"^\d+-\d+-\d+T\d+:\d+:\d+\.\d+\+00:00$"
|
||||||
|
)
|
||||||
|
|
||||||
def readLog(self, log_path):
|
def readLog(self, log_path):
|
||||||
"""Helper function to read log data into a list."""
|
"""Helper function to read log data into a list."""
|
||||||
|
Loading…
Reference in New Issue
Block a user