Skip to content

Commit

Permalink
Support Python 3
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquev6 committed Oct 4, 2014
1 parent a6d165a commit be7b71c
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,3 +4,4 @@
/LowVoltage.egg-info/
/dist/
*.pyc
/build/
3 changes: 1 addition & 2 deletions .travis.yml
@@ -1,8 +1,7 @@
language: python
python:
- "2.7"
# - "3.3"
# - "3.4"
- "3.4"
install:
- pip install -r requirements.txt
- pip install coveralls
Expand Down
16 changes: 8 additions & 8 deletions LowVoltage/connection.py
Expand Up @@ -86,7 +86,7 @@ def _sign(self, now, operation, payload):
request = "POST\n/\n\n{}\n{}\n{}".format(
"".join("{}:{}\n".format(key.lower(), val) for key, val in sorted(headers.iteritems())),
header_names,
hashlib.sha256(payload).hexdigest(),
hashlib.sha256(payload.encode("utf-8")).hexdigest(),
)
credentials = "{}/{}/dynamodb/aws4_request".format(
datestamp,
Expand All @@ -95,7 +95,7 @@ def _sign(self, now, operation, payload):
to_sign = "AWS4-HMAC-SHA256\n{}\n{}\n{}".format(
timestamp,
credentials,
hashlib.sha256(request).hexdigest(),
hashlib.sha256(request.encode("utf-8")).hexdigest(),
)

aws_key, aws_secret = self.__credentials.get()
Expand All @@ -104,25 +104,25 @@ def _sign(self, now, operation, payload):
hmac.new(
hmac.new(
hmac.new(
"AWS4{}".format(aws_secret),
datestamp,
"AWS4{}".format(aws_secret).encode("utf-8"),
datestamp.encode("utf-8"),
hashlib.sha256
).digest(),
self.__region,
self.__region.encode("utf-8"),
hashlib.sha256
).digest(),
"dynamodb",
"dynamodb".encode("utf-8"),
hashlib.sha256
).digest(),
"aws4_request",
"aws4_request".encode("utf-8"),
hashlib.sha256
).digest()

headers["Authorization"] = "AWS4-HMAC-SHA256 Credential={}/{}, SignedHeaders={}, Signature={}".format(
aws_key,
credentials,
header_names,
hmac.new(key, to_sign, hashlib.sha256).hexdigest(),
hmac.new(key, to_sign.encode("utf-8"), hashlib.sha256).hexdigest(),
)

return headers, payload
Expand Down
2 changes: 1 addition & 1 deletion README.rst
@@ -1,4 +1,4 @@
LowVoltage is a Python client for DynamoDB that doesn't hide any feature of the API.
LowVoltage is a Python (2 and 3) client for DynamoDB that doesn't hide any feature of the API.

.. image:: https://travis-ci.org/jacquev6/LowVoltage.svg?branch=master
:target: https://travis-ci.org/jacquev6/LowVoltage
Expand Down
5 changes: 2 additions & 3 deletions setup.py
Expand Up @@ -27,9 +27,8 @@
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 2.7",
# "Programming Language :: Python :: 3",
# "Programming Language :: Python :: 3.3",
# "Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Environment :: Web Environment",
],
test_suite="LowVoltage.tests",
Expand Down

0 comments on commit be7b71c

Please sign in to comment.