~ubuntu-branches/ubuntu/trusty/heat/trusty

« back to all changes in this revision

Viewing changes to heat/openstack/common/timeutils.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short, Adam Gandelman
  • Date: 2013-09-08 21:51:19 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20130908215119-r939tu4aumqgdrkx
Tags: 2013.2~b3-0ubuntu1
[ Chuck Short ]
* New upstream release.
* debian/control: Add python-netaddr as build-dep.
* debian/heat-common.install: Remove heat-boto and associated man-page
* debian/heat-common.install: Remove heat-cfn and associated man-page
* debian/heat-common.install: Remove heat-watch and associated man-page
* debian/patches/fix-sqlalchemy-0.8.patch: Dropped

[ Adam Gandelman ]
* debian/patches/default-kombu.patch: Dropped.
* debian/patches/default-sqlite.patch: Refreshed.
* debian/*.install, rules: Install heat.conf.sample as common
  config file in heat-common. Drop other per-package configs, they
  are no longer used.
* debian/rules: Clean pbr .egg from build dir if it exists.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
import datetime
24
24
 
25
25
import iso8601
 
26
import six
26
27
 
27
28
 
28
29
# ISO 8601 extended time format with microseconds
48
49
    try:
49
50
        return iso8601.parse_date(timestr)
50
51
    except iso8601.ParseError as e:
51
 
        raise ValueError(e.message)
 
52
        raise ValueError(unicode(e))
52
53
    except TypeError as e:
53
 
        raise ValueError(e.message)
 
54
        raise ValueError(unicode(e))
54
55
 
55
56
 
56
57
def strtime(at=None, fmt=PERFECT_TIME_FORMAT):
75
76
 
76
77
def is_older_than(before, seconds):
77
78
    """Return True if before is older than seconds."""
78
 
    if isinstance(before, basestring):
 
79
    if isinstance(before, six.string_types):
79
80
        before = parse_strtime(before).replace(tzinfo=None)
80
81
    return utcnow() - before > datetime.timedelta(seconds=seconds)
81
82
 
82
83
 
83
84
def is_newer_than(after, seconds):
84
85
    """Return True if after is newer than seconds."""
85
 
    if isinstance(after, basestring):
 
86
    if isinstance(after, six.string_types):
86
87
        after = parse_strtime(after).replace(tzinfo=None)
87
88
    return after - utcnow() > datetime.timedelta(seconds=seconds)
88
89