~ubuntu-branches/ubuntu/trusty/ceilometer/trusty-proposed

« back to all changes in this revision

Viewing changes to ceilometer/utils.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, James Page, Chuck Short
  • Date: 2014-01-23 15:08:11 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20140123150811-1zaismsuyh1hcl8y
Tags: 2014.1~b2-0ubuntu1
[ James Page ]
* d/control: Add python-jsonpath-rw to BD's.
* d/p/fix-setup-requirements.patch: Bump WebOb to support < 1.4.
 (LP: #1261101)

[ Chuck Short ]
* New upstream version.
* debian/control, debian/ceilometer-common.install: Split out
  ceilometer-alarm-evaluator and ceilometer-alarm-notifier into their
  own packages. (LP: #1250002)
* debian/ceilometer-agent-central.logrotate,
  debian/ceilometer-agent-compute.logrotate,
  debian/ceilometer-api.logrotate,
  debian/ceilometer-collector.logrotate: Add logrotate files, 
  thanks to Ahmed Rahal. (LP: #1224223)
* Fix typos in upstart files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
            # When doing a pair of JSON encode/decode operations to the tuple,
37
37
            # the tuple would become list. So we have to generate the value as
38
38
            # list here.
39
 
            yield name, list(map(lambda x: unicode(x).encode('utf-8'),
40
 
                                 value))
 
39
 
 
40
            # in the special case of the list item itself being a dict,
 
41
            # create an equivalent dict with a predictable insertion order
 
42
            # to avoid inconsistencies in the message signature computation
 
43
            # for equivalent payloads modulo ordering
 
44
            first = lambda i: i[0]
 
45
            m = map(lambda x: unicode(dict(sorted(x.items(), key=first))
 
46
                                      if isinstance(x, dict)
 
47
                                      else x).encode('utf-8'),
 
48
                    value)
 
49
            yield name, list(m)
41
50
        else:
42
51
            yield name, value
43
52
 
48
57
    Some databases don't store microseconds in datetime
49
58
    so we always store as Decimal unixtime.
50
59
    """
 
60
    if utc is None:
 
61
        return None
 
62
 
51
63
    decimal.getcontext().prec = 30
52
64
    return decimal.Decimal(str(calendar.timegm(utc.utctimetuple()))) + \
53
65
        (decimal.Decimal(str(utc.microsecond)) /
59
71
    """
60
72
    if dec is None:
61
73
        return None
 
74
 
62
75
    integer = int(dec)
63
76
    micro = (dec - decimal.Decimal(integer)) * decimal.Decimal(1000000)
64
77
    daittyme = datetime.datetime.utcfromtimestamp(integer)