You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2013/08/01 20:30:34 UTC
[22/22] git commit: Fix a bug with encoding in Python 3 which was
exposed by previous commit.
Fix a bug with encoding in Python 3 which was exposed by previous commit.
In Python 3, binascii.hexlify returns bytes, but we want a str.
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/ee54c26e
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/ee54c26e
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/ee54c26e
Branch: refs/heads/0.13.x
Commit: ee54c26e025ddd9ef5fc1c8661d8c1da641dc883
Parents: 506c0fc
Author: Tomaz Muraus <to...@apache.org>
Authored: Thu Aug 1 19:51:09 2013 +0200
Committer: Tomaz Muraus <to...@apache.org>
Committed: Thu Aug 1 20:29:36 2013 +0200
----------------------------------------------------------------------
libcloud/common/openstack.py | 2 +-
libcloud/compute/base.py | 3 ++-
libcloud/compute/deployment.py | 4 +++-
libcloud/compute/drivers/ecp.py | 2 +-
libcloud/storage/drivers/azure_blobs.py | 10 ++++++----
5 files changed, 13 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/ee54c26e/libcloud/common/openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/common/openstack.py b/libcloud/common/openstack.py
index ba1425a..622a275 100644
--- a/libcloud/common/openstack.py
+++ b/libcloud/common/openstack.py
@@ -605,7 +605,7 @@ class OpenStackBaseConnection(ConnectionUserAndKey):
self._tuple_from_url(url)
def _add_cache_busting_to_params(self, params):
- cache_busting_number = binascii.hexlify(os.urandom(8))
+ cache_busting_number = binascii.hexlify(os.urandom(8)).decode('ascii')
if isinstance(params, dict):
params['cache-busting'] = cache_busting_number
http://git-wip-us.apache.org/repos/asf/libcloud/blob/ee54c26e/libcloud/compute/base.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/base.py b/libcloud/compute/base.py
index 545ca00..0a84dd2 100644
--- a/libcloud/compute/base.py
+++ b/libcloud/compute/base.py
@@ -507,7 +507,8 @@ class NodeDriver(BaseDriver):
if 'password' in self.features['create_node']:
value = os.urandom(16)
- return NodeAuthPassword(binascii.hexlify(value), generated=True)
+ value = binascii.hexlify(value).decode('ascii')
+ return NodeAuthPassword(value, generated=True)
if auth:
raise LibcloudError(
http://git-wip-us.apache.org/repos/asf/libcloud/blob/ee54c26e/libcloud/compute/deployment.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/deployment.py b/libcloud/compute/deployment.py
index 103315c..d0925b5 100644
--- a/libcloud/compute/deployment.py
+++ b/libcloud/compute/deployment.py
@@ -142,7 +142,9 @@ class ScriptDeployment(Deployment):
if self.name is None:
# File is put under user's home directory
# (~/libcloud_deployment_<random_string>.sh)
- self.name = 'libcloud_deployment_%s.sh' % (binascii.hexlify(os.urandom(4)))
+ random_string = binascii.hexlify(os.urandom(4))
+ random_string = random_string.decode('ascii')
+ self.name = 'libcloud_deployment_%s.sh' % (random_string)
def run(self, node, client):
"""
http://git-wip-us.apache.org/repos/asf/libcloud/blob/ee54c26e/libcloud/compute/drivers/ecp.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ecp.py b/libcloud/compute/drivers/ecp.py
index dff49c0..aa77440 100644
--- a/libcloud/compute/drivers/ecp.py
+++ b/libcloud/compute/drivers/ecp.py
@@ -102,7 +102,7 @@ class ECPConnection(ConnectionUserAndKey):
#use a random boundary that does not appear in the fields
boundary = ''
while boundary in ''.join(fields):
- boundary = u(binascii.hexlify(os.urandom(16)))
+ boundary = binascii.hexlify(os.urandom(16)).decode('utf-8')
L = []
for i in fields:
L.append('--' + boundary)
http://git-wip-us.apache.org/repos/asf/libcloud/blob/ee54c26e/libcloud/storage/drivers/azure_blobs.py
----------------------------------------------------------------------
diff --git a/libcloud/storage/drivers/azure_blobs.py b/libcloud/storage/drivers/azure_blobs.py
index 5512d70..06e4511 100644
--- a/libcloud/storage/drivers/azure_blobs.py
+++ b/libcloud/storage/drivers/azure_blobs.py
@@ -295,8 +295,9 @@ class AzureBlobsStorageDriver(StorageDriver):
}
if extra['md5_hash']:
- extra['md5_hash'] = binascii.hexlify(
- base64.b64decode(b(extra['md5_hash'])))
+ value = binascii.hexlify(base64.b64decode(b(extra['md5_hash'])))
+ value = value.decode('ascii')
+ extra['md5_hash'] = value
meta_data = {}
for meta in metadata.getchildren():
@@ -344,8 +345,9 @@ class AzureBlobsStorageDriver(StorageDriver):
}
if extra['md5_hash']:
- extra['md5_hash'] = binascii.hexlify(
- base64.b64decode(b(extra['md5_hash'])))
+ value = binascii.hexlify(base64.b64decode(b(extra['md5_hash'])))
+ value = value.decode('ascii')
+ extra['md5_hash'] = value
meta_data = {}
for key, value in response.headers.items():