Merge ~nobuto/juju-wait:tz into juju-wait:master

Proposed by Nobuto Murata
Status: Merged
Merged at revision: c5be600a2ae006ba09bab5f4dd1a770b32d8f51e
Proposed branch: ~nobuto/juju-wait:tz
Merge into: juju-wait:master
Diff against target: 40 lines (+4/-4)
1 file modified
juju_wait/__init__.py (+4/-4)
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Review via email: mp+378118@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Stuart Bishop (stub) wrote :

Code looks good. Unfortunately datetime.timezone is Python3 only. I think I'm stuck needing Python2.7 compatibility for a while longer, due to juju-wait being embedded in Mojo and IIRC some CI systems around the place.

review: Needs Fixing
Revision history for this message
Stuart Bishop (stub) wrote :

This is important, so lets land this now. We can address Python2 compatibility later if it still is a problem.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/juju_wait/__init__.py b/juju_wait/__init__.py
2index be706ca..0ea6196 100755
3--- a/juju_wait/__init__.py
4+++ b/juju_wait/__init__.py
5@@ -19,7 +19,7 @@
6
7 import argparse
8 from collections import namedtuple
9-from datetime import datetime, timedelta
10+from datetime import datetime, timedelta, timezone
11 from distutils.version import LooseVersion
12 import json
13 import logging
14@@ -60,7 +60,7 @@ class MachineState(object):
15
16 def parse_ts(ts):
17 """Parse the Juju provided timestamp, which must be UTC."""
18- return datetime.strptime(ts, "%d %b %Y %H:%M:%SZ")
19+ return datetime.strptime(ts, "%d %b %Y %H:%M:%SZ").replace(tzinfo=timezone.utc)
20
21
22 class JujuWaitException(Exception):
23@@ -486,7 +486,7 @@ def wait(
24
25 # Check workload status
26 if current not in WORKLOAD_OK_STATES and wait_for_workload:
27- logging.debug("{} workload status is {} since " "{}Z".format(uname, current, since))
28+ logging.debug("{} workload status is {} since " "{}".format(uname, current, since))
29 if uname not in exclude_units:
30 ready = False
31 else:
32@@ -519,7 +519,7 @@ def wait(
33 # update-status is an idle hook event
34 pass
35 elif current != "idle":
36- logging.debug("{} juju agent status is {} since " "{}Z".format(uname, current, since))
37+ logging.debug("{} juju agent status is {} since " "{}".format(uname, current, since))
38 ready = False
39
40 # Log storage to compare with prev_logs.

Subscribers

People subscribed via source and target branches

to all changes: