Repository: libcloud Updated Branches: refs/heads/trunk 8fa1168af -> 928b64f06
fix linting errors Signed-off-by: Tomaz Muraus <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/3af989a3 Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/3af989a3 Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/3af989a3 Branch: refs/heads/trunk Commit: 3af989a361f58c4cb0e3d2d4035ef6b246de335d Parents: 5db12e2 Author: Gertjan Oude Lohuis <[email protected]> Authored: Thu Mar 5 15:51:46 2015 +0100 Committer: Tomaz Muraus <[email protected]> Committed: Fri Mar 6 15:58:12 2015 +0100 ---------------------------------------------------------------------- libcloud/common/aws.py | 22 +++++++++++++--------- libcloud/compute/drivers/ec2.py | 5 +++-- 2 files changed, 16 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/3af989a3/libcloud/common/aws.py ---------------------------------------------------------------------- diff --git a/libcloud/common/aws.py b/libcloud/common/aws.py index 697a47e..f1b9a11 100644 --- a/libcloud/common/aws.py +++ b/libcloud/common/aws.py @@ -189,19 +189,22 @@ class V4SignedAWSConnection(AWSTokenConnection): def pre_connect_hook(self, params, headers): now = datetime.utcnow() headers['X-AMZ-Date'] = now.strftime('%Y%m%dT%H%M%SZ') - headers['Authorization'] = self._get_authorization_v4_header(params, headers, now) + headers['Authorization'] = \ + self._get_authorization_v4_header(params, headers, now) return params, headers def _get_authorization_v4_header(self, params, headers, dt): - assert self.method == 'GET', 'AWS Signature V4 not implemented for other methods than GET' + assert self.method == 'GET', 'AWS Signature V4 not implemented for ' \ + 'other methods than GET' - return 'AWS4-HMAC-SHA256 Credential=%(u)s/%(c)s, SignedHeaders=%(sh)s, Signature=%(s)s' % { - 'u': self.user_id, - 'c': self._get_credential_scope(dt), - 'sh': self._get_signed_headers(headers), - 's': self._get_signature(params, headers, dt) - } + return 'AWS4-HMAC-SHA256 Credential=%(u)s/%(c)s, ' \ + 'SignedHeaders=%(sh)s, Signature=%(s)s' % { + 'u': self.user_id, + 'c': self._get_credential_scope(dt), + 'sh': self._get_signed_headers(headers), + 's': self._get_signature(params, headers, dt) + } def _get_signature(self, params, headers, dt): return _sign( @@ -242,7 +245,8 @@ class V4SignedAWSConnection(AWSTokenConnection): def _get_request_params(self, params): # For self.method == GET - return '&'.join(["%s=%s" % (urlquote(k, safe=''), urlquote(str(v), safe='~')) + return '&'.join(["%s=%s" % + (urlquote(k, safe=''), urlquote(str(v), safe='~')) for k, v in sorted(params.items())]) def _get_canonical_request(self, params, headers): http://git-wip-us.apache.org/repos/asf/libcloud/blob/3af989a3/libcloud/compute/drivers/ec2.py ---------------------------------------------------------------------- diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py index 092f587..03c817f 100644 --- a/libcloud/compute/drivers/ec2.py +++ b/libcloud/compute/drivers/ec2.py @@ -34,7 +34,8 @@ from libcloud.utils.xml import fixxpath, findtext, findattr, findall from libcloud.utils.publickey import get_pubkey_ssh2_fingerprint from libcloud.utils.publickey import get_pubkey_comment from libcloud.utils.iso8601 import parse_date -from libcloud.common.aws import AWSBaseResponse, SignedAWSConnection, V4SignedAWSConnection +from libcloud.common.aws import (AWSBaseResponse, SignedAWSConnection, + V4SignedAWSConnection) from libcloud.common.types import (InvalidCredsError, MalformedResponseError, LibcloudError) from libcloud.compute.providers import Provider @@ -1708,7 +1709,7 @@ class EC2Connection(SignedAWSConnection): class EC2V4Connection(V4SignedAWSConnection): """ - Represents a single connection to an EC2 Endpoint using signature version 4. + Represents a single connection to an EC2 Endpoint using signature v4. """ version = API_VERSION host = REGION_DETAILS['us-east-1']['endpoint']
