1
"""Generally useful utilities for AWS web services not specific to a service.
3
New things in this module should be of relevance to more than one of amazon's
7
__all__ = ['hmac_sha1', 'iso8601time']
9
from base64 import b64encode
10
from hashlib import sha1
13
# Import XML from somwhere; here in one place to prevent duplication.
15
from xml.etree.ElementTree import XML
17
from elementtree.ElementTree import XML
19
def hmac_sha1(secret, data):
20
digest = hmac.new(secret, data, sha1).digest()
21
return b64encode(digest)
24
def iso8601time(time_tuple):
25
"""Format time_tuple as a ISO8601 time string.
27
:param time_tuple: Either None, to use the current time, or a tuple tuple.
30
return time.strftime("%Y-%m-%dT%H:%M:%SZ", time_tuple)
32
return time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())