summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChuck Short <chuck.short@canonical.com>2013-06-27 15:40:42 -0400
committerChuck Short <chuck.short@canonical.com>2013-06-27 15:41:58 -0400
commitd28fa6983bb628c6d111a5f16e222f7b020a3b94 (patch)
tree9a4d0f66d4e7c34151c412f58cd3b8a33b0368b4
parent7b7566bac8e2df14e17631980a7fbf2df68cf116 (diff)
downloadoslo-d28fa6983bb628c6d111a5f16e222f7b020a3b94.zip
oslo-d28fa6983bb628c6d111a5f16e222f7b020a3b94.tar.gz
oslo-d28fa6983bb628c6d111a5f16e222f7b020a3b94.tar.xz
python3: Add python3 compatibility.
Fix basestring/str idioms for both python2 and python3 (used by python-novaclient). Change-Id: I440c7c1c18660c3d73f699c0a02cbbfee331bfbf Signed-off-by: Chuck Short <chuck.short@canonical.com>
-rw-r--r--openstack/common/timeutils.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/openstack/common/timeutils.py b/openstack/common/timeutils.py
index ac2441b..bd60489 100644
--- a/openstack/common/timeutils.py
+++ b/openstack/common/timeutils.py
@@ -23,6 +23,7 @@ import calendar
import datetime
import iso8601
+import six
# ISO 8601 extended time format with microseconds
@@ -75,14 +76,14 @@ def normalize_time(timestamp):
def is_older_than(before, seconds):
"""Return True if before is older than seconds."""
- if isinstance(before, basestring):
+ if isinstance(before, six.string_types):
before = parse_strtime(before).replace(tzinfo=None)
return utcnow() - before > datetime.timedelta(seconds=seconds)
def is_newer_than(after, seconds):
"""Return True if after is newer than seconds."""
- if isinstance(after, basestring):
+ if isinstance(after, six.string_types):
after = parse_strtime(after).replace(tzinfo=None)
return after - utcnow() > datetime.timedelta(seconds=seconds)