Author: tomaz
Date: Sat Dec 3 16:09:24 2011
New Revision: 1209941
URL: http://svn.apache.org/viewvc?rev=1209941&view=rev
Log:
More progress.
Modified:
libcloud/branches/py3k/libcloud/compute/drivers/ecp.py
libcloud/branches/py3k/libcloud/compute/drivers/linode.py
libcloud/branches/py3k/test/compute/test_elasticstack.py
Modified: libcloud/branches/py3k/libcloud/compute/drivers/ecp.py
URL:
http://svn.apache.org/viewvc/libcloud/branches/py3k/libcloud/compute/drivers/ecp.py?rev=1209941&r1=1209940&r2=1209941&view=diff
==============================================================================
--- libcloud/branches/py3k/libcloud/compute/drivers/ecp.py (original)
+++ libcloud/branches/py3k/libcloud/compute/drivers/ecp.py Sat Dec 3 16:09:24
2011
@@ -20,9 +20,11 @@ import time
import base64
import os
import socket
+import binascii
from libcloud.py3 import httplib
from libcloud.py3 import b
+from libcloud.py3 import u
# JSON is included in the standard library starting with Python 2.6. For 2.5
# and 2.4, there's a simplejson egg at: http://pypi.python.org/pypi/simplejson
@@ -99,7 +101,7 @@ class ECPConnection(ConnectionUserAndKey
#use a random boundary that does not appear in the fields
boundary = ''
while boundary in ''.join(fields):
- boundary = os.urandom(16).encode('hex')
+ boundary = u(binascii.hexlify(os.urandom(16)))
L = []
for i in fields:
L.append('--' + boundary)
Modified: libcloud/branches/py3k/libcloud/compute/drivers/linode.py
URL:
http://svn.apache.org/viewvc/libcloud/branches/py3k/libcloud/compute/drivers/linode.py?rev=1209941&r1=1209940&r2=1209941&view=diff
==============================================================================
--- libcloud/branches/py3k/libcloud/compute/drivers/linode.py (original)
+++ libcloud/branches/py3k/libcloud/compute/drivers/linode.py Sat Dec 3
16:09:24 2011
@@ -28,17 +28,21 @@ Linode(R) is a registered trademark of L
"""
try:
- import simplejson as json
+ import simplejson as json
except ImportError:
- import json
+ import json
import itertools
import os
+import binascii
from copy import copy
+from libcloud.py3 import PY3
+from libcloud.py3 import u
+
from libcloud.common.linode import (API_ROOT, LinodeException,
LinodeConnection,
- LINODE_PLAN_IDS)
+ LINODE_PLAN_IDS)
from libcloud.compute.types import Provider, NodeState
from libcloud.compute.base import NodeDriver, NodeSize, Node, NodeLocation
from libcloud.compute.base import NodeAuthPassword, NodeAuthSSHKey
@@ -295,7 +299,7 @@ class LinodeNodeDriver(NodeDriver):
# Step 2: linode.disk.createfromdistribution
if not root:
- root = os.urandom(8).encode('hex')
+ root = u(binascii.hexlifyos.urandom(8).encode('hex'))
params = {
"api_action": "linode.disk.createfromdistribution",
"LinodeID": linode["id"],
@@ -448,7 +452,12 @@ class LinodeNodeDriver(NodeDriver):
# Avoid batch limitation
ip_answers = []
args = [iter(batch)] * 25
- izip_longest = getattr(itertools, 'izip_longest', _izip_longest)
+
+ if PY3:
+ izip_longest = itertools.zip_longest
+ else:
+ izip_longest = getattr(itertools, 'izip_longest', _izip_longest)
+
for twenty_five in izip_longest(*args):
twenty_five = [q for q in twenty_five if q]
params = { "api_action": "batch",
@@ -465,7 +474,7 @@ class LinodeNodeDriver(NodeDriver):
which = nodes[lid].public_ips if ip["ISPUBLIC"] == 1 else \
nodes[lid].private_ips
which.append(ip["IPADDRESS"])
- return nodes.values()
+ return list(nodes.values())
features = {"create_node": ["ssh_key", "password"]}
Modified: libcloud/branches/py3k/test/compute/test_elasticstack.py
URL:
http://svn.apache.org/viewvc/libcloud/branches/py3k/test/compute/test_elasticstack.py?rev=1209941&r1=1209940&r2=1209941&view=diff
==============================================================================
--- libcloud/branches/py3k/test/compute/test_elasticstack.py (original)
+++ libcloud/branches/py3k/test/compute/test_elasticstack.py Sat Dec 3
16:09:24 2011
@@ -57,7 +57,8 @@ class ElasticStackTestCase(object):
self.mockHttp.type = 'UNAUTHORIZED'
try:
self.driver.list_nodes()
- except InvalidCredsError, e:
+ except InvalidCredsError:
+ e = sys.exc_info()[1]
self.assertEqual(True, isinstance(e, InvalidCredsError))
else:
self.fail('test should have thrown')
@@ -75,7 +76,8 @@ class ElasticStackTestCase(object):
self.mockHttp.type = 'PARSE_ERROR'
try:
self.driver.list_nodes()
- except Exception, e:
+ except Exception:
+ e = sys.exc_info()[1]
self.assertTrue(str(e).find('X-Elastic-Error') != -1)
else:
self.fail('test should have thrown')