diff --git a/checkbox-ng/checkbox_ng/utils.py b/checkbox-ng/checkbox_ng/utils.py index 44f816931e..c5f86aa5f4 100644 --- a/checkbox-ng/checkbox_ng/utils.py +++ b/checkbox-ng/checkbox_ng/utils.py @@ -60,7 +60,9 @@ def generate_resume_candidate_description(candidate): last_job_id = candidate.metadata.running_job_name or "Unknown" last_job_timestamp = candidate.metadata.last_job_start_time or None if last_job_timestamp: - dt = datetime.datetime.fromtimestamp(last_job_timestamp, datetime.UTC) + dt = datetime.datetime.fromtimestamp( + last_job_timestamp, datetime.timezone.utc + ) last_job_start_time = dt.strftime("%Y-%m-%d %H:%M:%S") else: last_job_start_time = "Unknown" diff --git a/checkbox-ng/plainbox/impl/exporter/jinja2.py b/checkbox-ng/plainbox/impl/exporter/jinja2.py index 7a62afc973..b67dfe18c9 100644 --- a/checkbox-ng/plainbox/impl/exporter/jinja2.py +++ b/checkbox-ng/plainbox/impl/exporter/jinja2.py @@ -104,7 +104,7 @@ def __init__( self._system_id = system_id # Generate a time-stamp if needed self._timestamp = timestamp or datetime.datetime.now( - datetime.UTC + datetime.timezone.utc ).strftime("%Y-%m-%dT%H:%M:%S") # Use current version unless told otherwise self._client_version = client_version or get_version_string() diff --git a/checkbox-ng/plainbox/impl/runner.py b/checkbox-ng/plainbox/impl/runner.py index 87f4491145..bcb21ab86c 100644 --- a/checkbox-ng/plainbox/impl/runner.py +++ b/checkbox-ng/plainbox/impl/runner.py @@ -62,7 +62,7 @@ def on_begin(self, args, kwargs): Begins tracking time (relative time entries) """ - self.last_msg = datetime.datetime.now(datetime.UTC) + self.last_msg = datetime.datetime.now(datetime.timezone.utc) def on_line(self, stream_name, line): """ @@ -72,7 +72,7 @@ def on_line(self, stream_name, line): Maintains a timestamp of the last message so that approximate delay between each piece of output can be recorded as well. """ - now = datetime.datetime.now(datetime.UTC) + now = datetime.datetime.now(datetime.timezone.utc) delay = now - self.last_msg self.last_msg = now record = IOLogRecord(delay.total_seconds(), stream_name, line) diff --git a/checkbox-ng/plainbox/impl/session/storage.py b/checkbox-ng/plainbox/impl/session/storage.py index 6654953b8a..18b6a63162 100644 --- a/checkbox-ng/plainbox/impl/session/storage.py +++ b/checkbox-ng/plainbox/impl/session/storage.py @@ -233,7 +233,9 @@ def create(cls, prefix="pbox-"): WellKnownDirsHelper.populate_base() isoformat = "%Y-%m-%dT%H.%M.%S" - timestamp = datetime.datetime.now(datetime.UTC).strftime(isoformat) + timestamp = datetime.datetime.now(datetime.timezone.utc).strftime( + isoformat + ) session_id = "{prefix}{timestamp}".format( prefix=slugify(prefix), timestamp=timestamp )