libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1210013 [1/2] - in /libcloud/trunk: ./ demos/ dist/ libcloud/ libcloud/common/ libcloud/compute/ libcloud/compute/drivers/ libcloud/data/ libcloud/dns/ libcloud/dns/drivers/ libcloud/drivers/ libcloud/loadbalancer/ libcloud/loadbalancer/dr...
Date Sat, 03 Dec 2011 21:39:03 GMT
Author: tomaz
Date: Sat Dec  3 21:38:59 2011
New Revision: 1210013

URL: http://svn.apache.org/viewvc?rev=1210013&view=rev
Log:
Merge py3k branch into trunk.

Added:
    libcloud/trunk/libcloud/py3.py
      - copied unchanged from r1210010, libcloud/branches/py3k/libcloud/py3.py
Modified:
    libcloud/trunk/   (props changed)
    libcloud/trunk/demos/   (props changed)
    libcloud/trunk/demos/compute_demo.py
    libcloud/trunk/dist/   (props changed)
    libcloud/trunk/example_compute.py
    libcloud/trunk/example_loadbalancer.py
    libcloud/trunk/libcloud/   (props changed)
    libcloud/trunk/libcloud/common/   (props changed)
    libcloud/trunk/libcloud/common/base.py
    libcloud/trunk/libcloud/common/cloudstack.py
    libcloud/trunk/libcloud/common/gandi.py
    libcloud/trunk/libcloud/common/gogrid.py
    libcloud/trunk/libcloud/common/openstack.py
    libcloud/trunk/libcloud/compute/   (props changed)
    libcloud/trunk/libcloud/compute/base.py
    libcloud/trunk/libcloud/compute/deployment.py
    libcloud/trunk/libcloud/compute/drivers/   (props changed)
    libcloud/trunk/libcloud/compute/drivers/bluebox.py
    libcloud/trunk/libcloud/compute/drivers/brightbox.py
    libcloud/trunk/libcloud/compute/drivers/cloudsigma.py
    libcloud/trunk/libcloud/compute/drivers/dreamhost.py
    libcloud/trunk/libcloud/compute/drivers/dummy.py
    libcloud/trunk/libcloud/compute/drivers/ec2.py
    libcloud/trunk/libcloud/compute/drivers/ecp.py
    libcloud/trunk/libcloud/compute/drivers/elasticstack.py
    libcloud/trunk/libcloud/compute/drivers/gandi.py
    libcloud/trunk/libcloud/compute/drivers/gogrid.py
    libcloud/trunk/libcloud/compute/drivers/ibm_sbc.py
    libcloud/trunk/libcloud/compute/drivers/linode.py
    libcloud/trunk/libcloud/compute/drivers/opennebula.py
    libcloud/trunk/libcloud/compute/drivers/openstack.py
    libcloud/trunk/libcloud/compute/drivers/opsource.py
    libcloud/trunk/libcloud/compute/drivers/rimuhosting.py
    libcloud/trunk/libcloud/compute/drivers/slicehost.py
    libcloud/trunk/libcloud/compute/drivers/softlayer.py
    libcloud/trunk/libcloud/compute/drivers/vcloud.py
    libcloud/trunk/libcloud/compute/drivers/voxel.py
    libcloud/trunk/libcloud/compute/drivers/vpsnet.py
    libcloud/trunk/libcloud/compute/ssh.py
    libcloud/trunk/libcloud/data/   (props changed)
    libcloud/trunk/libcloud/dns/   (props changed)
    libcloud/trunk/libcloud/dns/drivers/   (props changed)
    libcloud/trunk/libcloud/dns/drivers/linode.py
    libcloud/trunk/libcloud/dns/drivers/rackspace.py
    libcloud/trunk/libcloud/dns/drivers/zerigo.py
    libcloud/trunk/libcloud/drivers/   (props changed)
    libcloud/trunk/libcloud/httplib_ssl.py
    libcloud/trunk/libcloud/loadbalancer/   (props changed)
    libcloud/trunk/libcloud/loadbalancer/drivers/   (props changed)
    libcloud/trunk/libcloud/loadbalancer/drivers/gogrid.py
    libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py
    libcloud/trunk/libcloud/storage/   (props changed)
    libcloud/trunk/libcloud/storage/base.py
    libcloud/trunk/libcloud/storage/drivers/   (props changed)
    libcloud/trunk/libcloud/storage/drivers/atmos.py
    libcloud/trunk/libcloud/storage/drivers/cloudfiles.py
    libcloud/trunk/libcloud/storage/drivers/dummy.py
    libcloud/trunk/libcloud/storage/drivers/google_storage.py
    libcloud/trunk/libcloud/storage/drivers/s3.py
    libcloud/trunk/libcloud/utils.py
    libcloud/trunk/setup.py
    libcloud/trunk/test/   (props changed)
    libcloud/trunk/test/__init__.py
    libcloud/trunk/test/common/   (props changed)
    libcloud/trunk/test/common/test_cloudstack.py
    libcloud/trunk/test/compute/   (props changed)
    libcloud/trunk/test/compute/fixtures/   (props changed)
    libcloud/trunk/test/compute/fixtures/bluebox/   (props changed)
    libcloud/trunk/test/compute/fixtures/brightbox/   (props changed)
    libcloud/trunk/test/compute/fixtures/cloudsigma/   (props changed)
    libcloud/trunk/test/compute/fixtures/cloudstack/   (props changed)
    libcloud/trunk/test/compute/fixtures/ec2/   (props changed)
    libcloud/trunk/test/compute/fixtures/ecp/   (props changed)
    libcloud/trunk/test/compute/fixtures/elastichosts/   (props changed)
    libcloud/trunk/test/compute/fixtures/gandi/   (props changed)
    libcloud/trunk/test/compute/fixtures/gogrid/   (props changed)
    libcloud/trunk/test/compute/fixtures/ibm_sbc/   (props changed)
    libcloud/trunk/test/compute/fixtures/meta/   (props changed)
    libcloud/trunk/test/compute/fixtures/opennebula_1_4/   (props changed)
    libcloud/trunk/test/compute/fixtures/opennebula_2_0/   (props changed)
    libcloud/trunk/test/compute/fixtures/openstack/   (props changed)
    libcloud/trunk/test/compute/fixtures/openstack_v1.1/   (props changed)
    libcloud/trunk/test/compute/fixtures/opsource/   (props changed)
    libcloud/trunk/test/compute/fixtures/rimuhosting/   (props changed)
    libcloud/trunk/test/compute/fixtures/slicehost/   (props changed)
    libcloud/trunk/test/compute/fixtures/softlayer/   (props changed)
    libcloud/trunk/test/compute/fixtures/terremark/   (props changed)
    libcloud/trunk/test/compute/fixtures/voxel/   (props changed)
    libcloud/trunk/test/compute/test_bluebox.py
    libcloud/trunk/test/compute/test_brightbox.py
    libcloud/trunk/test/compute/test_cloudsigma.py
    libcloud/trunk/test/compute/test_cloudstack.py
    libcloud/trunk/test/compute/test_deployment.py
    libcloud/trunk/test/compute/test_dreamhost.py
    libcloud/trunk/test/compute/test_ec2.py
    libcloud/trunk/test/compute/test_ecp.py
    libcloud/trunk/test/compute/test_elasticstack.py
    libcloud/trunk/test/compute/test_gandi.py
    libcloud/trunk/test/compute/test_gogrid.py
    libcloud/trunk/test/compute/test_ibm_sbc.py
    libcloud/trunk/test/compute/test_linode.py
    libcloud/trunk/test/compute/test_opennebula.py
    libcloud/trunk/test/compute/test_openstack.py
    libcloud/trunk/test/compute/test_opsource.py
    libcloud/trunk/test/compute/test_rimuhosting.py
    libcloud/trunk/test/compute/test_slicehost.py
    libcloud/trunk/test/compute/test_softlayer.py
    libcloud/trunk/test/compute/test_ssh_client.py
    libcloud/trunk/test/compute/test_vcloud.py
    libcloud/trunk/test/compute/test_voxel.py
    libcloud/trunk/test/compute/test_vpsnet.py
    libcloud/trunk/test/dns/   (props changed)
    libcloud/trunk/test/dns/fixtures/   (props changed)
    libcloud/trunk/test/dns/fixtures/linode/   (props changed)
    libcloud/trunk/test/dns/fixtures/rackspace/   (props changed)
    libcloud/trunk/test/dns/fixtures/zerigo/   (props changed)
    libcloud/trunk/test/dns/test_linode.py
    libcloud/trunk/test/dns/test_rackspace.py
    libcloud/trunk/test/dns/test_zerigo.py
    libcloud/trunk/test/file_fixtures.py
    libcloud/trunk/test/loadbalancer/   (props changed)
    libcloud/trunk/test/loadbalancer/fixtures/   (props changed)
    libcloud/trunk/test/loadbalancer/fixtures/cloudstack/   (props changed)
    libcloud/trunk/test/loadbalancer/fixtures/gogrid/   (props changed)
    libcloud/trunk/test/loadbalancer/fixtures/rackspace/   (props changed)
    libcloud/trunk/test/loadbalancer/test_cloudstack.py
    libcloud/trunk/test/loadbalancer/test_gogrid.py
    libcloud/trunk/test/loadbalancer/test_rackspace.py
    libcloud/trunk/test/resource/   (props changed)
    libcloud/trunk/test/resource/fixtures/   (props changed)
    libcloud/trunk/test/storage/   (props changed)
    libcloud/trunk/test/storage/fixtures/   (props changed)
    libcloud/trunk/test/storage/fixtures/atmos/   (props changed)
    libcloud/trunk/test/storage/fixtures/cloudfiles/   (props changed)
    libcloud/trunk/test/storage/fixtures/google_storage/   (props changed)
    libcloud/trunk/test/storage/fixtures/s3/   (props changed)
    libcloud/trunk/test/storage/test_atmos.py
    libcloud/trunk/test/storage/test_base.py
    libcloud/trunk/test/storage/test_cloudfiles.py
    libcloud/trunk/test/storage/test_google_storage.py
    libcloud/trunk/test/storage/test_s3.py
    libcloud/trunk/test/test_response_classes.py
    libcloud/trunk/test/test_utils.py
    libcloud/trunk/tox.ini

Propchange: libcloud/trunk/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Sat Dec  3 21:38:59 2011
@@ -1,7 +1 @@
-.hg
-.svn
-.hgtags
-project.log
-tailor.state
-tailor.state.old
-tailor.state.journal
+__pycache__

Propchange: libcloud/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Dec  3 21:38:59 2011
@@ -1 +1,2 @@
 /libcloud/branches/0.6.x:1202005
+/libcloud/branches/py3k:1209909-1210010

Propchange: libcloud/trunk/demos/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec  3 21:38:59 2011
@@ -0,0 +1 @@
+__pycache__

Modified: libcloud/trunk/demos/compute_demo.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/demos/compute_demo.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/demos/compute_demo.py (original)
+++ libcloud/trunk/demos/compute_demo.py Sat Dec  3 21:38:59 2011
@@ -55,7 +55,7 @@ def get_demo_driver(provider_name='RACKS
     >>> driver.load_nodes()
     >>> images = driver.load_images()
     >>> sizes = driver.load_sizes()
-    
+
     # And maybe do more than that:
     >>> node = driver.create_node(
             name='my_first_node',

Propchange: libcloud/trunk/dist/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec  3 21:38:59 2011
@@ -0,0 +1 @@
+__pycache__

Modified: libcloud/trunk/example_compute.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/example_compute.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/example_compute.py (original)
+++ libcloud/trunk/example_compute.py Sat Dec  3 21:38:59 2011
@@ -12,6 +12,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
+
 from libcloud.compute.types import Provider
 from libcloud.compute.providers import get_driver
 
@@ -19,18 +20,18 @@ EC2 = get_driver(Provider.EC2_US_EAST)
 Slicehost = get_driver(Provider.SLICEHOST)
 Rackspace = get_driver(Provider.RACKSPACE)
 
-drivers = [ EC2('access key id', 'secret key'), 
-            Slicehost('api key'), 
+drivers = [ EC2('access key id', 'secret key'),
+            Slicehost('api key'),
             Rackspace('username', 'api key') ]
 
 nodes = [ driver.list_nodes() for driver in drivers ]
 
-print nodes
+print(nodes)
 # [ <Node: provider=Amazon, status=RUNNING, name=bob, ip=1.2.3.4.5>,
 # <Node: provider=Slicehost, status=REBOOT, name=korine, ip=6.7.8.9.10>, ... ]
 
 # grab the node named "test"
-node = filter(lambda x: x.name == 'test', nodes)[0]
+node = [n for n in nodes if n.name == 'test'][0]
 
 # reboot "test"
 node.reboot()

Modified: libcloud/trunk/example_loadbalancer.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/example_loadbalancer.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/example_loadbalancer.py (original)
+++ libcloud/trunk/example_loadbalancer.py Sat Dec  3 21:38:59 2011
@@ -29,7 +29,7 @@ def main():
 
     balancers = driver.list_balancers()
 
-    print balancers
+    print(balancers)
 
     # creating a balancer which balances traffic across two
     # nodes: 192.168.86.1:80 and 192.168.86.2:8080. Balancer
@@ -43,7 +43,7 @@ def main():
                      Member(None, '192.168.86.2', 8080))
             )
 
-    print new_balancer
+    print(new_balancer)
 
     # wait for balancer to become ready
     # NOTE: in real life code add timeout to not end up in
@@ -54,12 +54,12 @@ def main():
         if balancer.state == State.RUNNING:
             break
 
-        print "sleeping for 30 seconds for balancers to become ready"
+        print('sleeping for 30 seconds for balancers to become ready')
         time.sleep(30)
 
     # fetch list of members
     members = balancer.list_members()
-    print members
+    print(members)
 
     # remove first member
     balancer.detach_member(members[0])

Propchange: libcloud/trunk/libcloud/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec  3 21:38:59 2011
@@ -0,0 +1 @@
+__pycache__

Propchange: libcloud/trunk/libcloud/common/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec  3 21:38:59 2011
@@ -0,0 +1 @@
+__pycache__

Modified: libcloud/trunk/libcloud/common/base.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/common/base.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/common/base.py (original)
+++ libcloud/trunk/libcloud/common/base.py Sat Dec  3 21:38:59 2011
@@ -13,15 +13,12 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-import httplib
-import urllib
-import StringIO
+import sys
 import ssl
 import time
 
 from xml.etree import ElementTree as ET
 from pipes import quote as pquote
-import urlparse
 
 try:
     import simplejson as json
@@ -29,10 +26,19 @@ except:
     import json
 
 import libcloud
+
+from libcloud.py3 import urllib
+from libcloud.py3 import httplib
+from libcloud.py3 import urlparse
+from libcloud.py3 import urlencode
+from libcloud.py3 import StringIO
+from libcloud.py3 import u
+
 from libcloud.common.types import LibcloudError, MalformedResponseError
 
 from libcloud.httplib_ssl import LibcloudHTTPSConnection
-from httplib import HTTPConnection as LibcloudHTTPConnection
+
+LibcloudHTTPConnection = httplib.HTTPConnection
 
 class Response(object):
     """
@@ -463,7 +469,7 @@ class Connection(object):
         params, headers = self.pre_connect_hook(params, headers)
 
         if params:
-            url = '?'.join((action, urllib.urlencode(params)))
+            url = '?'.join((action, urlencode(params)))
         else:
             url = action
 
@@ -476,14 +482,15 @@ class Connection(object):
             if raw:
                 self.connection.putrequest(method, url)
 
-                for key, value in headers.iteritems():
+                for key, value in headers.items():
                     self.connection.putheader(key, str(value))
 
                 self.connection.endheaders()
             else:
                 self.connection.request(method=method, url=url, body=data,
                                         headers=headers)
-        except ssl.SSLError, e:
+        except ssl.SSLError:
+            e = sys.exc_info()[1]
             raise ssl.SSLError(str(e))
 
         if raw:

Modified: libcloud/trunk/libcloud/common/cloudstack.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/common/cloudstack.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/common/cloudstack.py (original)
+++ libcloud/trunk/libcloud/common/cloudstack.py Sat Dec  3 21:38:59 2011
@@ -16,8 +16,9 @@
 import base64
 import hashlib
 import hmac
-import time
-import urllib
+
+from libcloud.py3 import urlencode
+from libcloud.py3 import b
 
 from libcloud.common.base import ConnectionUserAndKey, PollingConnection
 from libcloud.common.base import JsonResponse
@@ -38,10 +39,10 @@ class CloudStackConnection(ConnectionUse
     def _make_signature(self, params):
         signature = [(k.lower(), v) for k, v in params.items()]
         signature.sort(key=lambda x: x[0])
-        signature = urllib.urlencode(signature)
+        signature = urlencode(signature)
         signature = signature.lower().replace('+', '%20')
-        signature = hmac.new(self.key, msg=signature, digestmod=hashlib.sha1)
-        return base64.b64encode(signature.digest())
+        signature = hmac.new(b(self.key), msg=b(signature), digestmod=hashlib.sha1)
+        return base64.b64encode(b(signature.digest()))
 
     def add_default_params(self, params):
         params['apiKey'] = self.user_id

Modified: libcloud/trunk/libcloud/common/gandi.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/common/gandi.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/common/gandi.py (original)
+++ libcloud/trunk/libcloud/common/gandi.py Sat Dec  3 21:38:59 2011
@@ -18,7 +18,9 @@ Gandi driver base classes
 
 import time
 import hashlib
-import xmlrpclib
+
+from libcloud.py3 import xmlrpclib
+from libcloud.py3 import b
 
 import libcloud
 from libcloud.common.base import ConnectionKey
@@ -84,14 +86,16 @@ class GandiConnection(ConnectionKey):
 
         try:
             self._proxy = self.proxyCls(self._user_agent())
-        except xmlrpclib.Fault, e:
+        except xmlrpclib.Fault:
+            e = sys.exc_info()[1]
             raise GandiException(1000, e)
 
     def request(self, method, *args):
         """ Request xmlrpc method with given args"""
         try:
             return getattr(self._proxy, method)(self.key, *args)
-        except xmlrpclib.Fault, e:
+        except xmlrpclib.Fault:
+            e = sys.exc_info()[1]
             raise GandiException(1001, e)
 
 
@@ -124,7 +128,8 @@ class BaseGandiDriver(object):
                     return False
             except (KeyError, IndexError):
                 pass
-            except Exception, e:
+            except Exception:
+                e = sys.exc_info()[1]
                 raise GandiException(1002, e)
 
             time.sleep(check_interval)
@@ -160,8 +165,8 @@ class BaseObject(object):
         Note, for example, that this example will always produce the
         same UUID!
         """
-        return hashlib.sha1("%s:%s:%d" % \
-            (self.uuid_prefix, self.id, self.driver.type)).hexdigest()
+        return hashlib.sha1(b("%s:%s:%d" % \
+            (self.uuid_prefix, self.id, self.driver.type))).hexdigest()
 
 
 class IPAddress(BaseObject):

Modified: libcloud/trunk/libcloud/common/gogrid.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/common/gogrid.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/common/gogrid.py (original)
+++ libcloud/trunk/libcloud/common/gogrid.py Sat Dec  3 21:38:59 2011
@@ -16,6 +16,8 @@
 import hashlib
 import time
 
+from libcloud.py3 import b
+
 from libcloud.common.types import InvalidCredsError, LibcloudError
 from libcloud.common.types import MalformedResponseError
 from libcloud.common.base import ConnectionUserAndKey, JsonResponse
@@ -74,7 +76,7 @@ class GoGridConnection(ConnectionUserAnd
 
     def get_signature(self, key, secret):
         """ create sig from md5 of key + secret + time """
-        m = hashlib.md5(key+secret+str(int(time.time())))
+        m = hashlib.md5(b(key+secret+str(int(time.time()))))
         return m.hexdigest()
 
 class GoGridIpAddress(object):

Modified: libcloud/trunk/libcloud/common/openstack.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/common/openstack.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/common/openstack.py (original)
+++ libcloud/trunk/libcloud/common/openstack.py Sat Dec  3 21:38:59 2011
@@ -16,8 +16,11 @@
 """
 Common utilities for OpenStack
 """
-import httplib
-from urllib2 import urlparse
+import sys
+
+from libcloud.py3 import httplib
+from libcloud.py3 import urlparse
+
 from libcloud.common.base import ConnectionUserAndKey, Response
 from libcloud.compute.types import LibcloudError, InvalidCredsError, MalformedResponseError
 
@@ -147,12 +150,14 @@ class OpenStackAuthConnection(Connection
         else:
             try:
                 body = json.loads(resp.body)
-            except Exception, e:
+            except Exception:
+                e = sys.exc_info()[1]
                 raise MalformedResponseError('Failed to parse JSON', e)
             try:
                 self.auth_token = body['auth']['token']['id']
                 self.urls = body['auth']['serviceCatalog']
-            except KeyError, e:
+            except KeyError:
+                e = sys.exc_info()[1]
                 raise MalformedResponseError('Auth JSON response is missing required elements', e)
 
     def authenticate_2_0_with_apikey(self):
@@ -181,7 +186,8 @@ class OpenStackAuthConnection(Connection
         else:
             try:
                 body = json.loads(resp.body)
-            except Exception, e:
+            except Exception:
+                e = sys.exc_info()[1]
                 raise MalformedResponseError('Failed to parse JSON', e)
 
             try:
@@ -189,7 +195,8 @@ class OpenStackAuthConnection(Connection
                 token = access['token']
                 self.auth_token = token['id']
                 self.urls = access['serviceCatalog']
-            except KeyError, e:
+            except KeyError:
+                e = sys.exc_info()[1]
                 raise MalformedResponseError('Auth JSON response is missing required elements', e)
 
 class OpenStackBaseConnection(ConnectionUserAndKey):

Propchange: libcloud/trunk/libcloud/compute/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec  3 21:38:59 2011
@@ -0,0 +1 @@
+__pycache__

Modified: libcloud/trunk/libcloud/compute/base.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/base.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/base.py (original)
+++ libcloud/trunk/libcloud/compute/base.py Sat Dec  3 21:38:59 2011
@@ -17,11 +17,15 @@
 Provides base classes for working with drivers
 """
 
+import sys
 import time
 import hashlib
 import os
 import socket
 import struct
+import binascii
+
+from libcloud.py3 import b
 
 import libcloud.compute.ssh
 from libcloud.pricing import get_size_price
@@ -161,7 +165,7 @@ class Node(object):
         Note, for example, that this example will always produce the
         same UUID!
         """
-        return hashlib.sha1("%s:%d" % (self.id, self.driver.type)).hexdigest()
+        return hashlib.sha1(b("%s:%d" % (self.id, self.driver.type))).hexdigest()
 
     def reboot(self):
         """Reboot this node
@@ -502,7 +506,7 @@ class NodeDriver(BaseDriver):
         ...     try:
         ...         node = driver.deploy_node(deploy=msd)
         ...     except NotImplementedError:
-        ...         print "not implemented for dummy driver"
+        ...         print ("not implemented for dummy driver")
         >>> d()
         not implemented for dummy driver
 
@@ -525,7 +529,7 @@ class NodeDriver(BaseDriver):
                     'deploy_node not implemented for this driver')
 
             if 'auth' not in kwargs:
-                kwargs['auth'] = NodeAuthPassword(os.urandom(16).encode('hex'))
+                kwargs['auth'] = NodeAuthPassword(binascii.hexlify(os.urandom(16)))
 
             if 'ssh_key' not in kwargs:
                 password = kwargs['auth'].password
@@ -560,7 +564,8 @@ class NodeDriver(BaseDriver):
                                         node=node,
                                         ssh_client=ssh_client,
                                         max_tries=3)
-        except Exception, e:
+        except Exception:
+            e = sys.exc_info()[1]
             raise DeploymentError(node, e)
         return node
 
@@ -586,7 +591,7 @@ class NodeDriver(BaseDriver):
 
         while time.time() < end:
             nodes = self.list_nodes()
-            nodes = filter(lambda n: n.uuid == node.uuid, nodes)
+            nodes = list(filter(lambda n: n.uuid == node.uuid, nodes))
 
             if len(nodes) == 0:
                 raise LibcloudError(value=('Booted node[%s] ' % node

Modified: libcloud/trunk/libcloud/compute/deployment.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/deployment.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/deployment.py (original)
+++ libcloud/trunk/libcloud/compute/deployment.py Sat Dec  3 21:38:59 2011
@@ -17,6 +17,9 @@
 Provides generic deployment steps for machines post boot.
 """
 import os
+import binascii
+
+from libcloud.py3 import basestring
 
 class Deployment(object):
     """
@@ -35,8 +38,8 @@ class Deployment(object):
 
         @return: L{Node}
         """
-        raise NotImplementedError, \
-            'run not implemented for this deployment'
+        raise NotImplementedError(
+            'run not implemented for this deployment')
 
     def _get_string_value(self, argument_name, argument_value):
         if not isinstance(argument_value, basestring) and \
@@ -98,7 +101,7 @@ class ScriptDeployment(Deployment):
         self.delete = delete
         self.name = name
         if self.name is None:
-            self.name = "/root/deployment_%s.sh" % (os.urandom(4).encode('hex'))
+            self.name = "/root/deployment_%s.sh" % (binascii.hexlify(os.urandom(4)))
 
     def run(self, node, client):
         """
@@ -106,7 +109,8 @@ class ScriptDeployment(Deployment):
 
         See also L{Deployment.run}
         """
-        client.put(path=self.name, chmod=0755, contents=self.script)
+
+        client.put(path=self.name, chmod=int('755', 8), contents=self.script)
         self.stdout, self.stderr, self.exit_status = client.run(self.name)
         if self.delete:
             client.delete(self.name)

Propchange: libcloud/trunk/libcloud/compute/drivers/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec  3 21:38:59 2011
@@ -0,0 +1 @@
+__pycache__

Modified: libcloud/trunk/libcloud/compute/drivers/bluebox.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/bluebox.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/bluebox.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/bluebox.py Sat Dec  3 21:38:59 2011
@@ -23,9 +23,12 @@ Blue Box API documentation    https://bo
 """
 
 import copy
-import urllib
+from libcloud.py3 import urllib
 import base64
 
+from libcloud.py3 import urlencode
+from libcloud.py3 import b
+
 from libcloud.common.base import JsonResponse, ConnectionUserAndKey
 from libcloud.compute.providers import Provider
 from libcloud.compute.types import NodeState, InvalidCredsError
@@ -112,7 +115,7 @@ class BlueboxConnection(ConnectionUserAn
     responseCls = BlueboxResponse
 
     def add_default_headers(self, headers):
-        user_b64 = base64.b64encode('%s:%s' % (self.user_id, self.key))
+        user_b64 = base64.b64encode(b('%s:%s' % (self.user_id, self.key)))
         headers['Authorization'] = 'Basic %s' % (user_b64)
         return headers
 
@@ -132,7 +135,7 @@ class BlueboxNodeDriver(NodeDriver):
 
     def list_sizes(self, location=None):
         sizes = []
-        for key, values in BLUEBOX_INSTANCE_TYPES.iteritems():
+        for key, values in BLUEBOX_INSTANCE_TYPES.items():
             attributes = copy.deepcopy(values)
             attributes.update({ 'price': self._get_size_price(size_id=key) })
             sizes.append(BlueboxNodeSize(driver=self.connection.driver,
@@ -183,7 +186,7 @@ class BlueboxNodeDriver(NodeDriver):
         if not ssh and not password:
             raise Exception("SSH public key or password required.")
 
-        params = urllib.urlencode(data)
+        params = urlencode(data)
         result = self.connection.request('/api/blocks.json', headers=headers, data=params, method='POST')
         node = self._to_node(result.object)
         return node

Modified: libcloud/trunk/libcloud/compute/drivers/brightbox.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/brightbox.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/brightbox.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/brightbox.py Sat Dec  3 21:38:59 2011
@@ -15,9 +15,11 @@
 """
 Brightbox Driver
 """
-import httplib
+from libcloud.py3 import httplib
 import base64
 
+from libcloud.py3 import b
+
 from libcloud.common.base import ConnectionUserAndKey, JsonResponse
 from libcloud.compute.types import Provider, NodeState, InvalidCredsError
 from libcloud.compute.base import NodeDriver
@@ -56,7 +58,8 @@ class BrightboxConnection(ConnectionUser
     def _fetch_oauth_token(self):
         body = json.dumps({'client_id': self.user_id, 'grant_type': 'none'})
 
-        authorization = 'Basic ' + base64.encodestring('%s:%s' % (self.user_id, self.key)).rstrip()
+        authorization = 'Basic ' + str(base64.encodestring(b('%s:%s' %
+                                        (self.user_id, self.key)))).rstrip()
 
         self.connect()
 
@@ -75,7 +78,7 @@ class BrightboxConnection(ConnectionUser
         else:
             message = '%s (%s)' % (json.loads(response.read())['error'], response.status)
 
-            raise InvalidCredsError, message
+            raise InvalidCredsError(message)
 
     def add_default_headers(self, headers):
         try:
@@ -114,8 +117,10 @@ class BrightboxNodeDriver(NodeDriver):
             id = data['id'],
             name = data['name'],
             state = self.NODE_STATE_MAP[data['status']],
-            public_ips = map(lambda cloud_ip: cloud_ip['public_ip'], data['cloud_ips']),
-            private_ips = map(lambda interface: interface['ipv4_address'], data['interfaces']),
+            public_ips = list(map(lambda cloud_ip: cloud_ip['public_ip'],
+                                                   data['cloud_ips'])),
+            private_ips = list(map(lambda interface: interface['ipv4_address'],
+                                                     data['interfaces'])),
             driver = self.connection.driver,
             extra = {
                 'status': data['status'],
@@ -166,7 +171,7 @@ class BrightboxNodeDriver(NodeDriver):
             'user_data': ''
         }
 
-        if kwargs.has_key('location'):
+        if 'location' in kwargs:
             data['zone'] = kwargs['location'].id
         else:
             data['zone'] = ''
@@ -183,22 +188,22 @@ class BrightboxNodeDriver(NodeDriver):
     def list_nodes(self):
         data = self.connection.request('/%s/servers' % API_VERSION).object
 
-        return map(self._to_node, data)
+        return list(map(self._to_node, data))
 
     def list_images(self):
         data = self.connection.request('/%s/images' % API_VERSION).object
 
-        return map(self._to_image, data)
+        return list(map(self._to_image, data))
 
     def list_sizes(self):
         data = self.connection.request('/%s/server_types' % API_VERSION).object
 
-        return map(self._to_size, data)
+        return list(map(self._to_size, data))
 
     def list_locations(self):
         data = self.connection.request('/%s/zones' % API_VERSION).object
 
-        return map(self._to_location, data)
+        return list(map(self._to_location, data))
 
     def ex_list_cloud_ips(self):
         return self.connection.request('/%s/cloud_ips' % API_VERSION).object

Modified: libcloud/trunk/libcloud/compute/drivers/cloudsigma.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/cloudsigma.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/cloudsigma.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/cloudsigma.py Sat Dec  3 21:38:59 2011
@@ -20,6 +20,9 @@ import re
 import time
 import base64
 
+from libcloud.py3 import b
+
+
 from libcloud.utils import str2dicts, str2list, dict2str
 from libcloud.common.base import ConnectionUserAndKey, Response
 from libcloud.common.types import InvalidCredsError
@@ -186,7 +189,8 @@ class CloudSigmaBaseConnection(Connectio
         headers['Accept'] = 'application/json'
         headers['Content-Type'] = 'application/json'
 
-        headers['Authorization'] = 'Basic %s' % (base64.b64encode('%s:%s' % (self.user_id, self.key)))
+        headers['Authorization'] = 'Basic %s' % (base64.b64encode(b('%s:%s' %
+                                                 (self.user_id, self.key))))
 
         return headers
 
@@ -259,7 +263,7 @@ class CloudSigmaBaseNodeDriver(NodeDrive
         Return a list of available node sizes.
         """
         sizes = []
-        for key, value in INSTANCE_TYPES.iteritems():
+        for key, value in INSTANCE_TYPES.items():
             size = CloudSigmaNodeSize(id = value['id'], name = value['name'],
                                       cpu = value['cpu'], ram = value['memory'],
                                       disk = value['disk'], bandwidth = value['bandwidth'],
@@ -332,10 +336,10 @@ class CloudSigmaBaseNodeDriver(NodeDrive
 
         response = self.connection.request(action = '/drives/%s/info' % (drive_uuid)).object
         imaging_start = time.time()
-        while response[0].has_key('imaging'):
+        while 'imaging' in response[0]:
             response = self.connection.request(action = '/drives/%s/info' % (drive_uuid)).object
             elapsed_time = time.time() - imaging_start
-            if response[0].has_key('imaging') and elapsed_time >= IMAGING_TIMEOUT:
+            if 'imaging' in response[0] and elapsed_time >= IMAGING_TIMEOUT:
                 raise CloudSigmaException('Drive imaging timed out')
             time.sleep(1)
 
@@ -374,7 +378,7 @@ class CloudSigmaBaseNodeDriver(NodeDrive
         node = self._get_node_info(node)
 
         drive_uuids = []
-        for key, value in node.iteritems():
+        for key, value in node.items():
             if (key.startswith('ide:') or key.startswith('scsi') or key.startswith('block')) and \
                not (key.endswith(':bytes') or key.endswith(':requests') or key.endswith('media')):
                 drive_uuids.append(value)
@@ -447,7 +451,8 @@ class CloudSigmaBaseNodeDriver(NodeDrive
                       '^ide:[0-1]:[0-1](:media)?$', '^scsi:0:[0-7](:media)?$', '^block:[0-7](:media)?$')
 
         invalid_keys = []
-        for key in kwargs.keys():
+        keys = list(kwargs.keys())
+        for key in keys:
             matches = False
             for regex in valid_keys:
                 if re.match(regex, key):
@@ -508,7 +513,7 @@ class CloudSigmaBaseNodeDriver(NodeDrive
                 return None
 
             public_ips = []
-            if data.has_key('nic:0:dhcp'):
+            if 'nic:0:dhcp' in data:
                 if isinstance(data['nic:0:dhcp'], list):
                     public_ips = data['nic:0:dhcp']
                 else:
@@ -517,7 +522,7 @@ class CloudSigmaBaseNodeDriver(NodeDrive
             extra = {}
             extra_keys = [ ('cpu', 'int'), ('smp', 'auto'), ('mem', 'int'), ('status', 'str') ]
             for key, value_type in extra_keys:
-                if data.has_key(key):
+                if key in data:
                     value = data[key]
 
                     if value_type == 'int':
@@ -530,7 +535,7 @@ class CloudSigmaBaseNodeDriver(NodeDrive
 
                     extra.update({key: value})
 
-            if data.has_key('vnc:ip') and data.has_key('vnc:password'):
+            if 'vnc:ip' in data and 'vnc:password' in data:
                 extra.update({'vnc_ip': data['vnc:ip'], 'vnc_password': data['vnc:password']})
 
             node = Node(id = data['server'], name = data['name'], state =  state,

Modified: libcloud/trunk/libcloud/compute/drivers/dreamhost.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/dreamhost.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/dreamhost.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/dreamhost.py Sat Dec  3 21:38:59 2011
@@ -198,7 +198,7 @@ class DreamhostNodeDriver(NodeDriver):
 
     def list_sizes(self, **kwargs):
         sizes = []
-        for key, values in self._sizes.iteritems():
+        for key, values in self._sizes.items():
             attributes = copy.deepcopy(values)
             attributes.update({ 'price': self._get_size_price(size_id=key) })
             sizes.append(NodeSize(driver=self.connection.driver, **attributes))

Modified: libcloud/trunk/libcloud/compute/drivers/dummy.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/dummy.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/dummy.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/dummy.py Sat Dec  3 21:38:59 2011
@@ -73,7 +73,7 @@ class DummyNodeDriver(NodeDriver):
         if num:
           self.nl = []
           startip = _ip_to_int('127.0.0.1')
-          for i in xrange(num):
+          for i in range(num):
             ip = _int_to_ip(startip + i)
             self.nl.append(
               Node(id=i,

Modified: libcloud/trunk/libcloud/compute/drivers/ec2.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/ec2.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/ec2.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/ec2.py Sat Dec  3 21:38:59 2011
@@ -18,16 +18,19 @@ Amazon EC2 driver
 """
 from __future__ import with_statement
 
+import sys
 import base64
 import hmac
 import os
 import time
-import urllib
 import copy
 
 from hashlib import sha256
 from xml.etree import ElementTree as ET
 
+from libcloud.py3 import urlquote
+from libcloud.py3 import b
+
 from libcloud.utils import fixxpath, findtext, findattr, findall
 from libcloud.common.base import ConnectionUserAndKey
 from libcloud.common.aws import AWSBaseResponse
@@ -226,12 +229,12 @@ class EC2Connection(ConnectionUserAndKey
                        HTTPRequestURI + "\n" +
                        CanonicalizedQueryString <from the preceding step>
         """
-        keys = params.keys()
+        keys = list(params.keys())
         keys.sort()
         pairs = []
         for key in keys:
-            pairs.append(urllib.quote(key, safe='') + '=' +
-                         urllib.quote(params[key], safe='-_~'))
+            pairs.append(urlquote(key, safe='') + '=' +
+                         urlquote(params[key], safe='-_~'))
 
         qs = '&'.join(pairs)
 
@@ -243,7 +246,7 @@ class EC2Connection(ConnectionUserAndKey
         string_to_sign = '\n'.join(('GET', hostname, path, qs))
 
         b64_hmac = base64.b64encode(
-            hmac.new(secret_key, string_to_sign, digestmod=sha256).digest()
+            hmac.new(b(secret_key), b(string_to_sign), digestmod=sha256).digest()
         )
         return b64_hmac
 
@@ -484,7 +487,7 @@ class EC2NodeDriver(NodeDriver):
 
     def _get_sizes(self, include_cluser_instances=False):
         sizes = []
-        for key, values in self._instance_types.iteritems():
+        for key, values in self._instance_types.items():
             if not include_cluser_instances and\
                key in CLUSTER_INSTANCES_IDS:
                 continue
@@ -627,7 +630,8 @@ class EC2NodeDriver(NodeDriver):
             results.append(
                 self.connection.request(self.path, params=params.copy()).object
             )
-        except Exception, e:
+        except Exception:
+            e = sys.exc_info()[1]
             if e.args[0].find("InvalidPermission.Duplicate") == -1:
                 raise e
         params['IpProtocol'] = 'udp'
@@ -636,7 +640,8 @@ class EC2NodeDriver(NodeDriver):
             results.append(
                 self.connection.request(self.path, params=params.copy()).object
             )
-        except Exception, e:
+        except Exception:
+            e = sys.exc_info()[1]
             if e.args[0].find("InvalidPermission.Duplicate") == -1:
                 raise e
 
@@ -646,7 +651,9 @@ class EC2NodeDriver(NodeDriver):
             results.append(
                 self.connection.request(self.path, params=params.copy()).object
             )
-        except Exception, e:
+        except Exception:
+            e = sys.exc_info()[1]
+
             if e.args[0].find("InvalidPermission.Duplicate") == -1:
                 raise e
         return results

Modified: libcloud/trunk/libcloud/compute/drivers/ecp.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/ecp.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/ecp.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/ecp.py Sat Dec  3 21:38:59 2011
@@ -18,9 +18,13 @@ Enomaly ECP driver
 """
 import time
 import base64
-import httplib
-import socket
 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
@@ -83,7 +87,7 @@ class ECPConnection(ConnectionUserAndKey
         username = self.user_id
         password = self.key
         base64string =  base64.encodestring(
-                '%s:%s' % (username, password))[:-1]
+                b('%s:%s' % (username, password)))[:-1]
         authheader =  "Basic %s" % base64string
         headers['Authorization']= authheader
 
@@ -97,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/trunk/libcloud/compute/drivers/elasticstack.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/elasticstack.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/elasticstack.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/elasticstack.py Sat Dec  3 21:38:59 2011
@@ -21,7 +21,9 @@ http://www.elasticstack.com.
 import re
 import time
 import base64
-import httplib
+
+from libcloud.py3 import httplib
+from libcloud.py3 import b
 
 try:
     import simplejson as json
@@ -153,9 +155,9 @@ class ElasticStackBaseConnection(Connect
         headers['Accept'] = 'application/json'
         headers['Content-Type'] = 'application/json'
         headers['Authorization'] = ('Basic %s'
-                                    % (base64.b64encode('%s:%s'
+                                    % (base64.b64encode(b('%s:%s'
                                                         % (self.user_id,
-                                                           self.key))))
+                                                           self.key)))))
         return headers
 
 
@@ -182,7 +184,7 @@ class ElasticStackBaseNodeDriver(NodeDri
     def list_images(self, location=None):
         # Returns a list of available pre-installed system drive images
         images = []
-        for key, value in self._standard_drives.iteritems():
+        for key, value in self._standard_drives.items():
             image = NodeImage(
                 id=value['uuid'],
                 name=value['description'],
@@ -197,7 +199,7 @@ class ElasticStackBaseNodeDriver(NodeDri
 
     def list_sizes(self, location=None):
         sizes = []
-        for key, value in INSTANCE_TYPES.iteritems():
+        for key, value in INSTANCE_TYPES.items():
             size = ElasticStackNodeSize(
                 id=value['id'],
                 name=value['name'], cpu=value['cpu'], ram=value['memory'],
@@ -331,7 +333,8 @@ class ElasticStackBaseNodeDriver(NodeDri
                       '^scsi:0:[0-7](:media)?$', '^block:[0-7](:media)?$')
 
         invalid_keys = []
-        for key in kwargs.keys():
+        keys = list(kwargs.keys())
+        for key in keys:
             matches = False
             for regex in valid_keys:
                 if re.match(regex, key):

Modified: libcloud/trunk/libcloud/compute/drivers/gandi.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/gandi.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/gandi.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/gandi.py Sat Dec  3 21:38:59 2011
@@ -54,7 +54,8 @@ class GandiNodeDriver(BaseGandiDriver, N
         try:
             obj = self.connection.request('vm.info', int(id))
             return obj
-        except Exception, e:
+        except Exception:
+            e = sys.exc_info()[1]
             raise GandiException(1003, e)
         return None
 
@@ -213,7 +214,8 @@ class GandiNodeDriver(BaseGandiDriver, N
                 filtering = {}
             images = self.connection.request('image.list', filtering)
             return [self._to_image(i) for i in images]
-        except Exception, e:
+        except Exception:
+            e = sys.exc_info()[1]
             raise GandiException(1011, e)
 
     def _to_size(self, id, size):
@@ -305,7 +307,7 @@ class GandiNodeDriver(BaseGandiDriver, N
         ifaces = self.connection.request('iface.list')
         ips = self.connection.request('ip.list')
         for iface in ifaces:
-            iface['ips'] = filter(lambda i: i['iface_id'] == iface['id'], ips)
+            iface['ips'] = list(filter(lambda i: i['iface_id'] == iface['id'], ips))
         return self._to_ifaces(ifaces)
 
     def _to_disk(self, element):

Modified: libcloud/trunk/libcloud/compute/drivers/gogrid.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/gogrid.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/gogrid.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/gogrid.py Sat Dec  3 21:38:59 2011
@@ -19,6 +19,8 @@ import time
 import hashlib
 import copy
 
+from libcloud.py3 import b
+
 from libcloud.common.types import InvalidCredsError, LibcloudError
 from libcloud.common.gogrid import GoGridConnection, BaseGoGridDriver
 from libcloud.compute.providers import Provider
@@ -83,7 +85,7 @@ class GoGridNode(Node):
     # so uuid of node should not change after add is completed
     def get_uuid(self):
         return hashlib.sha1(
-            "%s:%d" % (self.public_ips,self.driver.type)
+            b("%s:%d" % (self.public_ips,self.driver.type))
         ).hexdigest()
 
 class GoGridNodeDriver(BaseGoGridDriver, NodeDriver):
@@ -218,7 +220,7 @@ class GoGridNodeDriver(BaseGoGridDriver,
 
     def list_sizes(self, location=None):
         sizes = []
-        for key, values in self._instance_types.iteritems():
+        for key, values in self._instance_types.items():
             attributes = copy.deepcopy(values)
             attributes.update({ 'price': self._get_size_price(size_id=key) })
             sizes.append(NodeSize(driver=self.connection.driver, **attributes))

Modified: libcloud/trunk/libcloud/compute/drivers/ibm_sbc.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/ibm_sbc.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/ibm_sbc.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/ibm_sbc.py Sat Dec  3 21:38:59 2011
@@ -17,6 +17,9 @@ Driver for the IBM Developer Cloud.
 """
 import base64, urllib
 
+from libcloud.py3 import urlencode
+from libcloud.py3 import b
+
 from libcloud.common.base import XmlResponse, ConnectionUserAndKey
 from libcloud.common.types import InvalidCredsError
 from libcloud.compute.types import NodeState, Provider
@@ -47,13 +50,14 @@ class IBMConnection(ConnectionUserAndKey
 
     def add_default_headers(self, headers):
         headers['Accept'] = 'text/xml'
-        headers['Authorization'] = ('Basic %s' % (base64.b64encode('%s:%s' % (self.user_id, self.key))))
+        headers['Authorization'] = ('Basic %s' % (base64.b64encode(b('%s:%s' %
+                                                 (self.user_id, self.key)))))
         if not 'Content-Type' in headers:
             headers['Content-Type'] = 'text/xml'
         return headers
 
     def encode_data(self, data):
-        return urllib.urlencode(data)
+        return urlencode(data)
 
 class IBMNodeDriver(NodeDriver):
     """

Modified: libcloud/trunk/libcloud/compute/drivers/linode.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/linode.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/linode.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/linode.py Sat Dec  3 21:38:59 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/trunk/libcloud/compute/drivers/opennebula.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/opennebula.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/opennebula.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/opennebula.py Sat Dec  3 21:38:59 2011
@@ -30,7 +30,10 @@ except ImportError:
 from xml.etree import ElementTree as ET
 from base64 import b64encode
 import hashlib
-import httplib
+
+from libcloud.py3 import httplib
+from libcloud.py3 import next
+from libcloud.py3 import b
 
 from libcloud.compute.base import NodeState, NodeDriver, Node, NodeLocation
 from libcloud.common.base import ConnectionUserAndKey, XmlResponse
@@ -113,9 +116,9 @@ class OpenNebulaConnection(ConnectionUse
         @rtype:  C{dict}
         @return: Dictionary containing updated headers.
         """
-        pass_sha1 = hashlib.sha1(self.key).hexdigest()
-        headers['Authorization'] = ('Basic %s' % b64encode('%s:%s' %
-                                                (self.user_id, pass_sha1)))
+        pass_sha1 = hashlib.sha1(b(self.key)).hexdigest()
+        headers['Authorization'] = ('Basic %s' % b64encode(b('%s:%s' %
+                                                (self.user_id, pass_sha1))))
         return headers
 
 
@@ -194,7 +197,7 @@ class OpenNebulaNetwork(object):
         @rtype:  C{string}
         @return: Unique identifier for this instance.
         """
-        return hashlib.sha1("%s:%d" % (self.id, self.driver.type)).hexdigest()
+        return hashlib.sha1(b("%s:%d" % (self.id, self.driver.type))).hexdigest()
 
     def destroy(self):
         """
@@ -859,8 +862,8 @@ class OpenNebula_2_0_NodeDriver(OpenNebu
         instance_type = compute.find('INSTANCE_TYPE')
 
         try:
-            return (node_size for node_size in self.list_sizes()
-                    if node_size.name == instance_type.text).next()
+            return next((node_size for node_size in self.list_sizes()
+                    if node_size.name == instance_type.text))
         except StopIteration:
             return None
 

Modified: libcloud/trunk/libcloud/compute/drivers/openstack.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/openstack.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/openstack.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/openstack.py Sat Dec  3 21:38:59 2011
@@ -16,6 +16,8 @@
 OpenStack driver
 """
 
+import binascii
+
 try:
     import simplejson as json
 except ImportError:
@@ -24,7 +26,11 @@ except ImportError:
 import os
 
 import warnings
-import httplib
+
+from libcloud.py3 import httplib
+from libcloud.py3 import b
+from libcloud.py3 import next
+
 import base64
 
 from xml.etree import ElementTree as ET
@@ -125,7 +131,7 @@ class OpenStackComputeConnection(OpenSta
             headers = {'Content-Type': self.default_content_type}
 
         if method == "GET":
-            params['cache-busting'] = os.urandom(8).encode('hex')
+            params['cache-busting'] = binascii.hexlify(os.urandom(8))
 
         return super(OpenStackComputeConnection, self).request(
             action=action,
@@ -562,7 +568,7 @@ class OpenStack_1_0_NodeDriver(OpenStack
             file_elm = ET.SubElement(personality_elm,
                                      'file',
                                      {'path': str(k)})
-            file_elm.text = base64.b64encode(v)
+            file_elm.text = base64.b64encode(b(v))
 
         return personality_elm
 
@@ -872,7 +878,7 @@ class OpenStack_1_1_NodeDriver(OpenStack
         rv = []
 
         for k, v in files.items():
-            rv.append({'path': k, 'contents': base64.b64encode(v)})
+            rv.append({'path': k, 'contents': base64.b64encode(b(v))})
 
         return rv
 
@@ -1033,8 +1039,8 @@ class OpenStack_1_1_NodeDriver(OpenStack
                 tenantId=api_node.get('tenant_id') or api_node['tenantId'],
                 imageId=api_node['image']['id'],
                 flavorId=api_node['flavor']['id'],
-                uri=(link['href'] for link in api_node['links'] if
-                     link['rel'] == 'self').next(),
+                uri=next(link['href'] for link in api_node['links'] if
+                     link['rel'] == 'self'),
                 metadata=api_node['metadata'],
                 password=api_node.get('adminPass'),
             ),

Modified: libcloud/trunk/libcloud/compute/drivers/opsource.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/opsource.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/opsource.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/opsource.py Sat Dec  3 21:38:59 2011
@@ -17,7 +17,9 @@ Opsource Driver
 """
 from xml.etree import ElementTree as ET
 from base64 import b64encode
-import httplib
+
+from libcloud.py3 import httplib
+from libcloud.py3 import b
 
 from libcloud.compute.base import NodeDriver, Node, NodeAuthPassword
 from libcloud.compute.base import NodeSize, NodeImage, NodeLocation
@@ -133,8 +135,8 @@ class OpsourceConnection(ConnectionUserA
     responseCls = OpsourceResponse
 
     def add_default_headers(self, headers):
-        headers['Authorization'] = ('Basic %s' % b64encode('%s:%s' %
-                                                (self.user_id, self.key)))
+        headers['Authorization'] = ('Basic %s' % b64encode(b('%s:%s' %
+                                                (self.user_id, self.key))))
         return headers
 
     def request(self, action, params=None, data='',
@@ -316,7 +318,7 @@ class OpsourceNodeDriver(NodeDriver):
         # XXX: return the last node in the list that has a matching name.  this
         #      is likely but not guaranteed to be the node we just created
         #      because opsource allows multiple nodes to have the same name
-        return filter(lambda x: x.name == name, self.list_nodes())[-1]
+        return list(filter(lambda x: x.name == name, self.list_nodes()))[-1]
 
     def destroy_node(self, node):
         body = self.connection.request_with_orgId('server/%s?delete' %
@@ -458,7 +460,7 @@ class OpsourceNodeDriver(NodeDriver):
     def ex_get_location_by_id(self, id):
         location = None
         if id is not None:
-            location = filter(lambda x: x.id == id, self.list_locations())[0]
+            location = list(filter(lambda x: x.id == id, self.list_locations()))[0]
         return location
 
     def _to_networks(self, object):

Modified: libcloud/trunk/libcloud/compute/drivers/rimuhosting.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/rimuhosting.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/rimuhosting.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/rimuhosting.py Sat Dec  3 21:38:59 2011
@@ -59,11 +59,12 @@ class RimuHostingResponse(JsonResponse):
     def parse_body(self):
         try:
             js = super(RimuHostingResponse, self).parse_body()
-            if js[js.keys()[0]]['response_type'] == "ERROR":
+            keys = list(js.keys())
+            if js[keys[0]]['response_type'] == "ERROR":
                 raise RimuHostingException(
-                    js[js.keys()[0]]['human_readable_message']
+                    js[keys[0]]['human_readable_message']
                 )
-            return js[js.keys()[0]]
+            return js[keys[0]]
         except KeyError:
             raise RimuHostingException('Could not parse body: %s'
                                        % (self.body))
@@ -167,20 +168,20 @@ class RimuHostingNodeDriver(NodeDriver):
             location = ";dc_location=%s" % (location.id)
 
         res = self.connection.request('/pricing-plans;server-type=VPS%s' % (location)).object
-        return map(lambda x : self._to_size(x), res['pricing_plan_infos'])
+        return list(map(lambda x : self._to_size(x), res['pricing_plan_infos']))
 
     def list_nodes(self):
         # Returns a list of Nodes
         # Will only include active ones.
         res = self.connection.request('/orders;include_inactive=N').object
-        return map(lambda x : self._to_node(x), res['about_orders'])
+        return list(map(lambda x : self._to_node(x), res['about_orders']))
 
     def list_images(self, location=None):
         # Get all base images.
         # TODO: add other image sources. (Such as a backup of a VPS)
         # All Images are available for use at all locations
         res = self.connection.request('/distributions').object
-        return map(lambda x : self._to_image(x), res['distro_infos'])
+        return list(map(lambda x : self._to_image(x), res['distro_infos']))
 
     def reboot_node(self, node):
         # Reboot
@@ -247,46 +248,46 @@ class RimuHostingNodeDriver(NodeDriver):
             'pricing_plan_code': size.id,
         }
 
-        if kwargs.has_key('ex_control_panel'):
+        if 'ex_control_panel' in kwargs:
             data['instantiation_options']['control_panel'] = kwargs['ex_control_panel']
 
-        if kwargs.has_key('auth'):
+        if 'auth' in kwargs:
             auth = kwargs['auth']
             if not isinstance(auth, NodeAuthPassword):
                 raise ValueError('auth must be of NodeAuthPassword type')
             data['instantiation_options']['password'] = auth.password
 
-        if kwargs.has_key('ex_billing_oid'):
+        if 'ex_billing_oid' in kwargs:
             #TODO check for valid oid.
             data['billing_oid'] = kwargs['ex_billing_oid']
 
-        if kwargs.has_key('ex_host_server_oid'):
+        if 'ex_host_server_oid' in kwargs:
             data['host_server_oid'] = kwargs['ex_host_server_oid']
 
-        if kwargs.has_key('ex_vps_order_oid_to_clone'):
+        if 'ex_vps_order_oid_to_clone' in kwargs:
             data['vps_order_oid_to_clone'] = kwargs['ex_vps_order_oid_to_clone']
 
-        if kwargs.has_key('ex_num_ips') and int(kwargs['ex_num_ips']) > 1:
-            if not kwargs.has_key('ex_extra_ip_reason'):
+        if 'ex_num_ips' in kwargs and int(kwargs['ex_num_ips']) > 1:
+            if not 'ex_extra_ip_reason' in kwargs:
                 raise RimuHostingException('Need an reason for having an extra IP')
             else:
-                if not data.has_key('ip_request'):
+                if not 'ip_request' in data:
                     data['ip_request'] = {}
                 data['ip_request']['num_ips'] = int(kwargs['ex_num_ips'])
                 data['ip_request']['extra_ip_reason'] = kwargs['ex_extra_ip_reason']
 
-        if kwargs.has_key('ex_memory_mb'):
-            if not data.has_key('vps_parameters'):
+        if 'ex_memory_mb' in kwargs:
+            if not 'vps_parameters' in data:
                 data['vps_parameters'] = {}
             data['vps_parameters']['memory_mb'] = kwargs['ex_memory_mb']
 
-        if kwargs.has_key('ex_disk_space_mb'):
-            if not data.has_key('ex_vps_parameters'):
+        if 'ex_disk_space_mb' in kwargs:
+            if not 'ex_vps_parameters' in data:
                 data['vps_parameters'] = {}
             data['vps_parameters']['disk_space_mb'] = kwargs['ex_disk_space_mb']
 
-        if kwargs.has_key('ex_disk_space_2_mb'):
-            if not data.has_key('vps_parameters'):
+        if 'ex_disk_space_2_mb' in kwargs:
+            if not 'vps_parameters' in data:
                 data['vps_parameters'] = {}
             data['vps_parameters']['disk_space_2_mb'] = kwargs['ex_disk_space_2_mb']
 

Modified: libcloud/trunk/libcloud/compute/drivers/slicehost.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/slicehost.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/slicehost.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/slicehost.py Sat Dec  3 21:38:59 2011
@@ -21,6 +21,8 @@ import socket
 from xml.etree import ElementTree as ET
 from xml.parsers.expat import ExpatError
 
+from libcloud.py3 import b
+
 from libcloud.common.base import ConnectionKey, XmlResponse
 from libcloud.compute.types import NodeState, Provider, InvalidCredsError
 from libcloud.compute.base import NodeSize, NodeDriver, NodeImage, NodeLocation
@@ -50,7 +52,7 @@ class SlicehostConnection(ConnectionKey)
 
     def add_default_headers(self, headers):
         headers['Authorization'] = ('Basic %s'
-                              % (base64.b64encode('%s:' % self.key)))
+                              % (base64.b64encode(b('%s:' % self.key))))
         return headers
 
 
@@ -191,7 +193,7 @@ class SlicehostNodeDriver(NodeDriver):
         # for consistency with other drivers, we put this in two places.
         node_attrs['password'] = node_attrs['root-password']
         extra = {}
-        for k in node_attrs.keys():
+        for k in list(node_attrs.keys()):
             ek = k.replace("-", "_")
             extra[ek] = node_attrs[k]
         n = Node(id=element.findtext('id'),

Modified: libcloud/trunk/libcloud/compute/drivers/softlayer.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/softlayer.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/softlayer.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/softlayer.py Sat Dec  3 21:38:59 2011
@@ -17,10 +17,11 @@ Softlayer driver
 """
 
 import time
-import xmlrpclib
 
 import libcloud
 
+from libcloud.py3 import xmlrpclib
+
 from libcloud.common.types import InvalidCredsError, LibcloudError
 from libcloud.compute.types import Provider, NodeState
 from libcloud.compute.base import NodeDriver, Node, NodeLocation, NodeSize, NodeImage
@@ -187,7 +188,8 @@ class SoftLayerConnection(object):
 
         try:
             return getattr(sl, method)(*params)
-        except xmlrpclib.Fault, e:
+        except xmlrpclib.Fault:
+            e = sys.exc_info()[1]
             if e.faultCode == "SoftLayer_Account":
                 raise InvalidCredsError(e.faultString)
             raise SoftLayerException(e)
@@ -396,7 +398,7 @@ class SoftLayerNodeDriver(NodeDriver):
         )
 
     def list_sizes(self, location=None):
-        return [self._to_size(id, s['imagedata']) for id, s in SL_TEMPLATES.iteritems()]
+        return [self._to_size(id, s['imagedata']) for id, s in SL_TEMPLATES.items()]
 
     def _to_loc(self, loc):
         return NodeLocation(

Modified: libcloud/trunk/libcloud/compute/drivers/vcloud.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/vcloud.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/vcloud.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/vcloud.py Sat Dec  3 21:38:59 2011
@@ -16,10 +16,14 @@
 VMware vCloud driver.
 """
 import base64
-import httplib
+from libcloud.py3 import httplib
+from libcloud.py3 import urlparse
+from libcloud.py3 import b
+
+urlparse = urlparse.urlparse
+
 import time
 
-from urlparse import urlparse
 from xml.etree import ElementTree as ET
 from xml.parsers.expat import ExpatError
 
@@ -226,7 +230,7 @@ class VCloudConnection(ConnectionUserAnd
         return {
             'Authorization':
                 "Basic %s"
-                % base64.b64encode('%s:%s' % (self.user_id, self.key)),
+                % base64.b64encode(b('%s:%s' % (self.user_id, self.key))),
             'Content-Length': 0
         }
 
@@ -525,7 +529,7 @@ class VCloudNodeDriver(NodeDriver):
             network = ''
 
         password = None
-        if kwargs.has_key('auth'):
+        if 'auth' in kwargs:
             auth = kwargs['auth']
             if isinstance(auth, NodeAuthPassword):
                 password = auth.password
@@ -585,7 +589,7 @@ class HostingComConnection(VCloudConnect
         """hosting.com doesn't follow the standard vCloud authentication API"""
         return {
             'Authentication':
-                base64.b64encode('%s:%s' % (self.user_id, self.key)),
+                base64.b64encode(b('%s:%s' % (self.user_id, self.key))),
             'Content-Length': 0
         }
 

Modified: libcloud/trunk/libcloud/compute/drivers/voxel.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/voxel.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/voxel.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/voxel.py Sat Dec  3 21:38:59 2011
@@ -19,6 +19,8 @@ Voxel VoxCloud driver
 import datetime
 import hashlib
 
+from libcloud.py3 import b
+
 from libcloud.common.base import XmlResponse, ConnectionUserAndKey
 from libcloud.common.types import InvalidCredsError
 from libcloud.compute.providers import Provider
@@ -77,24 +79,21 @@ class VoxelConnection(ConnectionUserAndK
     responseCls = VoxelResponse
 
     def add_default_params(self, params):
+        params = dict([(k, v) for k, v in params.items() if v is not None])
         params["key"] = self.user_id
         params["timestamp"] = datetime.datetime.utcnow().isoformat()+"+0000"
 
-        for param in params.keys():
-            if params[param] is None:
-                del params[param]
-
-        keys = params.keys()
+        keys = list(params.keys())
         keys.sort()
 
         md5 = hashlib.md5()
-        md5.update(self.key)
+        md5.update(b(self.key))
         for key in keys:
             if params[key]:
                 if not params[key] is None:
-                    md5.update("%s%s"% (key, params[key]))
+                    md5.update(b("%s%s"% (key, params[key])))
                 else:
-                    md5.update(key)
+                    md5.update(b(key))
         params['api_sig'] = md5.hexdigest()
         return params
 

Modified: libcloud/trunk/libcloud/compute/drivers/vpsnet.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/vpsnet.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/vpsnet.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/vpsnet.py Sat Dec  3 21:38:59 2011
@@ -22,6 +22,8 @@ try:
 except ImportError:
     import json
 
+from libcloud.py3 import b
+
 from libcloud.common.base import ConnectionUserAndKey, JsonResponse
 from libcloud.common.types import InvalidCredsError, MalformedResponseError
 from libcloud.compute.providers import Provider
@@ -68,7 +70,7 @@ class VPSNetConnection(ConnectionUserAnd
     responseCls = VPSNetResponse
 
     def add_default_headers(self, headers):
-        user_b64 = base64.b64encode('%s:%s' % (self.user_id, self.key))
+        user_b64 = base64.b64encode(b('%s:%s' % (self.user_id, self.key)))
         headers['Authorization'] = 'Basic %s' % (user_b64)
         return headers
 

Modified: libcloud/trunk/libcloud/compute/ssh.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/ssh.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/ssh.py (original)
+++ libcloud/trunk/libcloud/compute/ssh.py Sat Dec  3 21:38:59 2011
@@ -66,8 +66,8 @@ class BaseSSHClient(object):
 
         @return: C{bool}
         """
-        raise NotImplementedError, \
-            'connect not implemented for this ssh client'
+        raise NotImplementedError(
+            'connect not implemented for this ssh client')
 
     def put(self, path, contents=None, chmod=None):
         """
@@ -82,8 +82,8 @@ class BaseSSHClient(object):
         @type chmod: C{int}
         @keyword chmod: chmod file to this after creation.
         """
-        raise NotImplementedError, \
-            'put not implemented for this ssh client'
+        raise NotImplementedError(
+            'put not implemented for this ssh client')
 
     def delete(self, path):
         """
@@ -92,8 +92,8 @@ class BaseSSHClient(object):
         @type path: C{str}
         @keyword path: File path on the remote node.
         """
-        raise NotImplementedError, \
-            'delete not implemented for this ssh client'
+        raise NotImplementedError(
+            'delete not implemented for this ssh client')
 
     def run(self, cmd):
         """
@@ -104,15 +104,15 @@ class BaseSSHClient(object):
 
         @return C{list} of [stdout, stderr, exit_status]
         """
-        raise NotImplementedError, \
-            'run not implemented for this ssh client'
+        raise NotImplementedError(
+            'run not implemented for this ssh client')
 
     def close(self):
         """
         Shutdown connection to the remote node.
         """
-        raise NotImplementedError, \
-            'close not implemented for this ssh client'
+        raise NotImplementedError(
+            'close not implemented for this ssh client')
 
 class ParamikoSSHClient(BaseSSHClient):
     """

Propchange: libcloud/trunk/libcloud/data/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec  3 21:38:59 2011
@@ -0,0 +1 @@
+__pycache__

Propchange: libcloud/trunk/libcloud/dns/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec  3 21:38:59 2011
@@ -0,0 +1 @@
+__pycache__

Propchange: libcloud/trunk/libcloud/dns/drivers/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec  3 21:38:59 2011
@@ -0,0 +1 @@
+__pycache__

Modified: libcloud/trunk/libcloud/dns/drivers/linode.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/dns/drivers/linode.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/dns/drivers/linode.py (original)
+++ libcloud/trunk/libcloud/dns/drivers/linode.py Sat Dec  3 21:38:59 2011
@@ -73,7 +73,7 @@ class LinodeDNSDriver(DNSDriver):
     connectionCls = LinodeDNSConnection
 
     def list_record_types(self):
-        return RECORD_TYPE_MAP.keys()
+        return list(RECORD_TYPE_MAP.keys())
 
     def list_zones(self):
         params = {'api_action': 'domain.list'}

Modified: libcloud/trunk/libcloud/dns/drivers/rackspace.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/dns/drivers/rackspace.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/dns/drivers/rackspace.py (original)
+++ libcloud/trunk/libcloud/dns/drivers/rackspace.py Sat Dec  3 21:38:59 2011
@@ -18,7 +18,7 @@ __all__ = [
     'RackspaceUKDNSDriver'
 ]
 
-import httplib
+from libcloud.py3 import httplib
 import copy
 
 from libcloud.common.base import PollingConnection
@@ -112,7 +112,7 @@ class RackspaceUKDNSConnection(Rackspace
 
 class RackspaceDNSDriver(DNSDriver):
     def list_record_types(self):
-        return RECORD_TYPE_MAP.keys()
+        return list(RECORD_TYPE_MAP.keys())
 
     def list_zones(self):
         response = self.connection.request(action='/domains')

Modified: libcloud/trunk/libcloud/dns/drivers/zerigo.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/dns/drivers/zerigo.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/dns/drivers/zerigo.py (original)
+++ libcloud/trunk/libcloud/dns/drivers/zerigo.py Sat Dec  3 21:38:59 2011
@@ -20,7 +20,9 @@ __all__ = [
 
 import copy
 import base64
-import httplib
+
+from libcloud.py3 import httplib
+from libcloud.py3 import b
 
 from xml.etree import ElementTree as ET
 
@@ -114,7 +116,7 @@ class ZerigoDNSConnection(ConnectionUser
     responseCls = ZerigoDNSResponse
 
     def add_default_headers(self, headers):
-        auth_b64 = base64.b64encode('%s:%s' % (self.user_id, self.key))
+        auth_b64 = base64.b64encode(b('%s:%s' % (self.user_id, self.key)))
         headers['Authorization'] = 'Basic %s' % (auth_b64)
         return headers
 
@@ -140,7 +142,7 @@ class ZerigoDNSDriver(DNSDriver):
     connectionCls = ZerigoDNSConnection
 
     def list_record_types(self):
-        return RECORD_TYPE_MAP.keys()
+        return list(RECORD_TYPE_MAP.keys())
 
     def list_zones(self):
         value_dict = {'type': 'zones'}

Propchange: libcloud/trunk/libcloud/drivers/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec  3 21:38:59 2011
@@ -0,0 +1 @@
+__pycache__

Modified: libcloud/trunk/libcloud/httplib_ssl.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/httplib_ssl.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/httplib_ssl.py (original)
+++ libcloud/trunk/libcloud/httplib_ssl.py Sat Dec  3 21:38:59 2011
@@ -16,7 +16,6 @@
 Subclass for httplib.HTTPSConnection with optional certificate name
 verification, depending on libcloud.security settings.
 """
-import httplib
 import os
 import re
 import socket
@@ -24,6 +23,7 @@ import ssl
 import warnings
 
 import libcloud.security
+from libcloud.py3 import httplib
 
 class LibcloudHTTPSConnection(httplib.HTTPSConnection):
     """LibcloudHTTPSConnection

Propchange: libcloud/trunk/libcloud/loadbalancer/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec  3 21:38:59 2011
@@ -0,0 +1 @@
+__pycache__

Propchange: libcloud/trunk/libcloud/loadbalancer/drivers/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec  3 21:38:59 2011
@@ -0,0 +1 @@
+__pycache__

Modified: libcloud/trunk/libcloud/loadbalancer/drivers/gogrid.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/loadbalancer/drivers/gogrid.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/loadbalancer/drivers/gogrid.py (original)
+++ libcloud/trunk/libcloud/loadbalancer/drivers/gogrid.py Sat Dec  3 21:38:59 2011
@@ -14,7 +14,7 @@
 # limitations under the License.
 
 import time
-import httplib
+from libcloud.py3 import httplib
 
 try:
     import simplejson as json
@@ -112,8 +112,9 @@ class GoGridLBDriver(BaseGoGridDriver, D
         try:
             resp = self.connection.request('/api/grid/loadbalancer/delete',
                     method='POST', params={'id': balancer.id})
-        except Exception, err:
-            if "Update request for LoadBalancer" in str(err):
+        except Exception:
+            e = sys.exc_info()[1]
+            if "Update request for LoadBalancer" in str(e):
                 raise LibcloudLBImmutableError("Cannot delete immutable object",
                         GoGridLBDriver)
             else:
@@ -171,8 +172,9 @@ class GoGridLBDriver(BaseGoGridDriver, D
             return self.connection.request('/api/grid/loadbalancer/edit',
                     method='POST',
                     params=params)
-        except Exception, err:
-            if "Update already pending" in str(err):
+        except Exception:
+            e = sys.exc_info()[1]
+            if "Update already pending" in str(e):
                 raise LibcloudLBImmutableError("Balancer is immutable", GoGridLBDriver)
 
         raise LibcloudError(value='Exception: %s' % str(err), driver=self)

Modified: libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py (original)
+++ libcloud/trunk/libcloud/loadbalancer/drivers/rackspace.py Sat Dec  3 21:38:59 2011
@@ -14,6 +14,7 @@
 # limitations under the License.
 
 import os
+import binascii
 
 try:
     import simplejson as json
@@ -59,7 +60,7 @@ class RackspaceConnection(OpenStackBaseC
         if method in ('POST', 'PUT'):
             headers['Content-Type'] = 'application/json'
         if method == 'GET':
-            params['cache-busing'] = os.urandom(8).encode('hex')
+            params['cache-busing'] = binascii.hexlify(os.urandom(8))
 
         return super(RackspaceConnection, self).request(action=action,
                 params=params, data=data, method=method, headers=headers)

Propchange: libcloud/trunk/libcloud/storage/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec  3 21:38:59 2011
@@ -0,0 +1 @@
+__pycache__

Modified: libcloud/trunk/libcloud/storage/base.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/storage/base.py?rev=1210013&r1=1210012&r2=1210013&view=diff
==============================================================================
--- libcloud/trunk/libcloud/storage/base.py (original)
+++ libcloud/trunk/libcloud/storage/base.py Sat Dec  3 21:38:59 2011
@@ -20,11 +20,14 @@ Provides base classes for working with s
 # Backward compatibility for Python 2.5
 from __future__ import with_statement
 
-import httplib
 import os.path                          # pylint: disable-msg=W0404
 import hashlib
 from os.path import join as pjoin
 
+from libcloud.py3 import httplib
+from libcloud.py3 import next
+from libcloud.py3 import b
+
 from libcloud import utils
 from libcloud.common.types import LibcloudError
 from libcloud.common.base import ConnectionUserAndKey, BaseDriver
@@ -466,7 +469,7 @@ class StorageDriver(BaseDriver):
         stream = utils.read_in_chunks(response, chunk_size)
 
         try:
-            data_read = stream.next()
+            data_read = next(stream)
         except StopIteration:
             # Empty response?
             return False
@@ -475,11 +478,11 @@ class StorageDriver(BaseDriver):
 
         with open(file_path, 'wb') as file_handle:
             while len(data_read) > 0:
-                file_handle.write(data_read)
+                file_handle.write(b(data_read))
                 bytes_transferred += len(data_read)
 
                 try:
-                    data_read = stream.next()
+                    data_read = next(stream)
                 except StopIteration:
                     data_read = ''
 
@@ -505,9 +508,10 @@ class StorageDriver(BaseDriver):
         headers = headers or {}
 
         if file_path and not os.path.exists(file_path):
-          raise OSError('File %s does not exist' % (file_path))
+            raise OSError('File %s does not exist' % (file_path))
 
-        if iterator is not None and not hasattr(iterator, 'next'):
+        if iterator is not None and not hasattr(iterator, 'next') and not \
+           hasattr(iterator, '__next__'):
             raise AttributeError('iterator object must implement next() ' +
                                  'method.')
 
@@ -584,7 +588,7 @@ class StorageDriver(BaseDriver):
 
         if calculate_hash:
             data_hash = self._get_hash_function()
-            data_hash.update(data)
+            data_hash.update(b(data))
 
         try:
             response.connection.connection.send(data)
@@ -639,7 +643,7 @@ class StorageDriver(BaseDriver):
 
         bytes_transferred = 0
         try:
-            chunk = generator.next()
+            chunk = next(generator)
         except StopIteration:
             # Special case when StopIteration is thrown on the first iteration -
             # create a 0-byte long object
@@ -670,10 +674,10 @@ class StorageDriver(BaseDriver):
 
             bytes_transferred += len(chunk)
             if calculate_hash:
-                data_hash.update(chunk)
+                data_hash.update(b(chunk))
 
             try:
-                chunk = generator.next()
+                chunk = next(generator)
             except StopIteration:
                 chunk = ''
 

Propchange: libcloud/trunk/libcloud/storage/drivers/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec  3 21:38:59 2011
@@ -0,0 +1 @@
+__pycache__



Mime
View raw message