libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1209943 - in /libcloud/branches/py3k: libcloud/ libcloud/common/ libcloud/compute/drivers/ test/compute/
Date Sat, 03 Dec 2011 16:27:11 GMT
Author: tomaz
Date: Sat Dec  3 16:27:10 2011
New Revision: 1209943

URL: http://svn.apache.org/viewvc?rev=1209943&view=rev
Log:
More progress. All the common + compute tests with the exception if OpenStack
ones now pass.

Modified:
    libcloud/branches/py3k/libcloud/common/gandi.py
    libcloud/branches/py3k/libcloud/common/gogrid.py
    libcloud/branches/py3k/libcloud/compute/drivers/gandi.py
    libcloud/branches/py3k/libcloud/compute/drivers/gogrid.py
    libcloud/branches/py3k/libcloud/compute/drivers/opsource.py
    libcloud/branches/py3k/libcloud/compute/drivers/softlayer.py
    libcloud/branches/py3k/libcloud/compute/drivers/voxel.py
    libcloud/branches/py3k/libcloud/py3.py
    libcloud/branches/py3k/test/compute/test_gandi.py
    libcloud/branches/py3k/test/compute/test_gogrid.py
    libcloud/branches/py3k/test/compute/test_ibm_sbc.py
    libcloud/branches/py3k/test/compute/test_openstack.py
    libcloud/branches/py3k/test/compute/test_slicehost.py
    libcloud/branches/py3k/test/compute/test_softlayer.py
    libcloud/branches/py3k/test/compute/test_ssh_client.py
    libcloud/branches/py3k/test/compute/test_voxel.py
    libcloud/branches/py3k/test/compute/test_vpsnet.py

Modified: libcloud/branches/py3k/libcloud/common/gandi.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/libcloud/common/gandi.py?rev=1209943&r1=1209942&r2=1209943&view=diff
==============================================================================
--- libcloud/branches/py3k/libcloud/common/gandi.py (original)
+++ libcloud/branches/py3k/libcloud/common/gandi.py Sat Dec  3 16:27:10 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/branches/py3k/libcloud/common/gogrid.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/libcloud/common/gogrid.py?rev=1209943&r1=1209942&r2=1209943&view=diff
==============================================================================
--- libcloud/branches/py3k/libcloud/common/gogrid.py (original)
+++ libcloud/branches/py3k/libcloud/common/gogrid.py Sat Dec  3 16:27:10 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/branches/py3k/libcloud/compute/drivers/gandi.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/libcloud/compute/drivers/gandi.py?rev=1209943&r1=1209942&r2=1209943&view=diff
==============================================================================
--- libcloud/branches/py3k/libcloud/compute/drivers/gandi.py (original)
+++ libcloud/branches/py3k/libcloud/compute/drivers/gandi.py Sat Dec  3 16:27:10 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/branches/py3k/libcloud/compute/drivers/gogrid.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/libcloud/compute/drivers/gogrid.py?rev=1209943&r1=1209942&r2=1209943&view=diff
==============================================================================
--- libcloud/branches/py3k/libcloud/compute/drivers/gogrid.py (original)
+++ libcloud/branches/py3k/libcloud/compute/drivers/gogrid.py Sat Dec  3 16:27:10 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):

Modified: libcloud/branches/py3k/libcloud/compute/drivers/opsource.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/libcloud/compute/drivers/opsource.py?rev=1209943&r1=1209942&r2=1209943&view=diff
==============================================================================
--- libcloud/branches/py3k/libcloud/compute/drivers/opsource.py (original)
+++ libcloud/branches/py3k/libcloud/compute/drivers/opsource.py Sat Dec  3 16:27:10 2011
@@ -318,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' %
@@ -460,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/branches/py3k/libcloud/compute/drivers/softlayer.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/libcloud/compute/drivers/softlayer.py?rev=1209943&r1=1209942&r2=1209943&view=diff
==============================================================================
--- libcloud/branches/py3k/libcloud/compute/drivers/softlayer.py (original)
+++ libcloud/branches/py3k/libcloud/compute/drivers/softlayer.py Sat Dec  3 16:27:10 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)

Modified: libcloud/branches/py3k/libcloud/compute/drivers/voxel.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/libcloud/compute/drivers/voxel.py?rev=1209943&r1=1209942&r2=1209943&view=diff
==============================================================================
--- libcloud/branches/py3k/libcloud/compute/drivers/voxel.py (original)
+++ libcloud/branches/py3k/libcloud/compute/drivers/voxel.py Sat Dec  3 16:27:10 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 = 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/branches/py3k/libcloud/py3.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/libcloud/py3.py?rev=1209943&r1=1209942&r2=1209943&view=diff
==============================================================================
--- libcloud/branches/py3k/libcloud/py3.py (original)
+++ libcloud/branches/py3k/libcloud/py3.py Sat Dec  3 16:27:10 2011
@@ -26,6 +26,7 @@ if sys.version_info >= (3, 0):
     from io import StringIO
     import urllib as urllib2
     import urllib.parse as urlparse
+    import xmlrpc.client as xmlrpclib
 
     import urllib
     urllib.quote = urlparse.quote
@@ -55,6 +56,7 @@ else:
     import urllib
     import urllib2
     import urlparse
+    import xmlrpclib
 
     basestring = unicode = str
 

Modified: libcloud/branches/py3k/test/compute/test_gandi.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/test/compute/test_gandi.py?rev=1209943&r1=1209942&r2=1209943&view=diff
==============================================================================
--- libcloud/branches/py3k/test/compute/test_gandi.py (original)
+++ libcloud/branches/py3k/test/compute/test_gandi.py Sat Dec  3 16:27:10 2011
@@ -17,8 +17,9 @@ import unittest
 import sys
 import random
 import string
+
 from libcloud.py3 import httplib
-import xmlrpclib
+from libcloud.py3 import xmlrpclib
 
 from libcloud.compute.drivers.gandi import GandiNodeDriver as Gandi
 from libcloud.common.gandi import GandiException
@@ -60,13 +61,13 @@ class GandiTests(unittest.TestCase):
         self.assertTrue(len(nodes) > 0)
 
     def test_list_locations(self):
-        loc = filter(lambda x: 'france' in x.country.lower(),
-            self.driver.list_locations())[0]
+        loc = list(filter(lambda x: 'france' in x.country.lower(),
+            self.driver.list_locations()))[0]
         self.assertEqual(loc.country, 'France')
 
     def test_list_images(self):
-        loc = filter(lambda x: 'france' in x.country.lower(),
-            self.driver.list_locations())[0]
+        loc = list(filter(lambda x: 'france' in x.country.lower(),
+            self.driver.list_locations()))[0]
         images = self.driver.list_images(loc)
         self.assertTrue(len(images) > 2)
 
@@ -76,30 +77,31 @@ class GandiTests(unittest.TestCase):
 
     def test_destroy_node_running(self):
         nodes = self.driver.list_nodes()
-        test_node = filter(lambda x: x.state == NodeState.RUNNING, nodes)[0]
+        test_node = list(filter(lambda x: x.state == NodeState.RUNNING, nodes))[0]
         self.assertTrue(self.driver.destroy_node(test_node))
 
     def test_destroy_node_halted(self):
         nodes = self.driver.list_nodes()
-        test_node = filter(lambda x: x.state == NodeState.TERMINATED, nodes)[0]
+        test_node = list(filter(lambda x: x.state == NodeState.TERMINATED,
+                                nodes))[0]
         self.assertTrue(self.driver.destroy_node(test_node))
 
     def test_reboot_node(self):
         nodes = self.driver.list_nodes()
-        test_node = filter(lambda x: x.state == NodeState.RUNNING, nodes)[0]
+        test_node = list(filter(lambda x: x.state == NodeState.RUNNING, nodes))[0]
         self.assertTrue(self.driver.reboot_node(test_node))
 
     def test_create_node(self):
         login = 'libcloud'
-        passwd = ''.join(random.choice(string.letters + string.digits)
-            for i in xrange(10))
+        passwd = ''.join(random.choice(string.ascii_letters)
+            for i in range(10))
         # Get france datacenter
-        loc = filter(lambda x: 'france' in x.country.lower(),
-            self.driver.list_locations())[0]
+        loc = list(filter(lambda x: 'france' in x.country.lower(),
+            self.driver.list_locations()))[0]
         # Get a debian image
         images = self.driver.list_images(loc)
         images = [x for x in images if x.name.lower().startswith('debian')]
-        img = filter(lambda x: '5' in x.name, images)[0]
+        img = list(filter(lambda x: '5' in x.name, images))[0]
         # Get a configuration size
         size = self.driver.list_sizes()[0]
         node = self.driver.create_node(name=self.node_name, login=login,

Modified: libcloud/branches/py3k/test/compute/test_gogrid.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/test/compute/test_gogrid.py?rev=1209943&r1=1209942&r2=1209943&view=diff
==============================================================================
--- libcloud/branches/py3k/test/compute/test_gogrid.py (original)
+++ libcloud/branches/py3k/test/compute/test_gogrid.py Sat Dec  3 16:27:10 2011
@@ -12,10 +12,11 @@
 # 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.py3 import httplib
 import sys
 import unittest
-import urlparse
+
+from libcloud.py3 import httplib
+from libcloud.py3 import urlparse
 
 from libcloud.compute.base import NodeState, NodeLocation
 from libcloud.common.types import LibcloudError, InvalidCredsError
@@ -101,7 +102,8 @@ class GoGridTests(unittest.TestCase, Tes
         GoGridMockHttp.type = 'FAIL'
         try:
             self.driver.list_images()
-        except LibcloudError, e:
+        except LibcloudError:
+            e = sys.exc_info()[1]
             self.assertTrue(isinstance(e, LibcloudError))
         else:
             self.fail("test should have thrown")
@@ -110,7 +112,8 @@ class GoGridTests(unittest.TestCase, Tes
         GoGridMockHttp.type = 'FAIL'
         try:
             self.driver.list_nodes()
-        except InvalidCredsError, e:
+        except InvalidCredsError:
+            e = sys.exc_info()[1]
             self.assertTrue(e.driver is not None)
             self.assertEqual(e.driver.name, self.driver.name)
         else:
@@ -124,7 +127,8 @@ class GoGridTests(unittest.TestCase, Tes
                 name='test1',
                 image=image,
                 size=self._get_test_512Mb_node_size())
-        except LibcloudError, e:
+        except LibcloudError:
+            e = sys.exc_info()[1]
             self.assertTrue(isinstance(e, LibcloudError))
             self.assertTrue(e.driver is not None)
             self.assertEqual(e.driver.name, self.driver.name)

Modified: libcloud/branches/py3k/test/compute/test_ibm_sbc.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/test/compute/test_ibm_sbc.py?rev=1209943&r1=1209942&r2=1209943&view=diff
==============================================================================
--- libcloud/branches/py3k/test/compute/test_ibm_sbc.py (original)
+++ libcloud/branches/py3k/test/compute/test_ibm_sbc.py Sat Dec  3 16:27:10 2011
@@ -39,7 +39,8 @@ class IBMTests(unittest.TestCase, TestCa
 
         try:
             self.driver.list_nodes()
-        except InvalidCredsError, e:
+        except InvalidCredsError:
+            e = sys.exc_info()[1]
             self.assertTrue(isinstance(e, InvalidCredsError))
             self.assertEquals(e.value, '401: Unauthorized')
         else:
@@ -109,7 +110,8 @@ class IBMTests(unittest.TestCase, TestCa
                                                'insight_admin_password': 'myPassword1',
                                                'db2_admin_password': 'myPassword2',
                                                'report_user_password': 'myPassword3'})
-        except Exception, e:
+        except Exception:
+            e = sys.exc_info()[1]
             self.assertEquals(e.args[0], 'Error 412: No DataCenter with id: 3')
         else:
             self.fail('test should have thrown')
@@ -129,7 +131,8 @@ class IBMTests(unittest.TestCase, TestCa
         self.assertEquals(len(nodes), 2)
         try:
             self.driver.destroy_node(toDelete)      # delete non-existent node
-        except Exception, e:
+        except Exception:
+            e = sys.exc_info()[1]
             self.assertEquals(e.args[0], 'Error 404: Invalid Instance ID 28193')
         else:
             self.fail('test should have thrown')
@@ -146,7 +149,8 @@ class IBMTests(unittest.TestCase, TestCa
         # Reboot inactive node
         try:
             ret = self.driver.reboot_node(nodes[1])
-        except Exception, e:
+        except Exception:
+            e = sys.exc_info()[1]
             self.assertEquals(e.args[0], 'Error 412: Instance must be in the Active state')
         else:
             self.fail('test should have thrown')

Modified: libcloud/branches/py3k/test/compute/test_openstack.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/test/compute/test_openstack.py?rev=1209943&r1=1209942&r2=1209943&view=diff
==============================================================================
--- libcloud/branches/py3k/test/compute/test_openstack.py (original)
+++ libcloud/branches/py3k/test/compute/test_openstack.py Sat Dec  3 16:27:10 2011
@@ -84,7 +84,8 @@ class OpenStack_1_0_Tests(unittest.TestC
         OpenStackMockHttp.type = 'UNAUTHORIZED'
         try:
             self.driver = self.create_driver()
-        except InvalidCredsError, e:
+        except InvalidCredsError:
+            e = sys.exc_info()[1]
             self.assertEqual(True, isinstance(e, InvalidCredsError))
         else:
             self.fail('test should have thrown')
@@ -93,7 +94,8 @@ class OpenStack_1_0_Tests(unittest.TestC
         OpenStackMockHttp.type = 'UNAUTHORIZED_MISSING_KEY'
         try:
             self.driver = self.create_driver()
-        except MalformedResponseError, e:
+        except MalformedResponseError:
+            e = sys.exc_info()[1]
             self.assertEqual(True, isinstance(e, MalformedResponseError))
         else:
             self.fail('test should have thrown')
@@ -102,7 +104,8 @@ class OpenStack_1_0_Tests(unittest.TestC
         OpenStackMockHttp.type = 'INTERNAL_SERVER_ERROR'
         try:
             self.driver = self.create_driver()
-        except MalformedResponseError, e:
+        except MalformedResponseError:
+            e = sys.exc_info()[1]
             self.assertEqual(True, isinstance(e, MalformedResponseError))
         else:
             self.fail('test should have thrown')
@@ -564,14 +567,16 @@ class OpenStack_1_1_Tests(unittest.TestC
     def test_ex_set_password(self):
         try:
             self.driver.ex_set_password(self.node, 'New1&53jPass')
-        except Exception, e:
+        except Exception:
+            e = sys.exc_info()[1]
             self.fail('An error was raised: ' + repr(e))
 
     def test_ex_rebuild(self):
         image = NodeImage(id=11, name='Ubuntu 8.10 (intrepid)', driver=self.driver)
         try:
             self.driver.ex_rebuild(self.node, image=image)
-        except Exception, e:
+        except Exception:
+            e = sys.exc_info()[1]
             self.fail('An error was raised: ' + repr(e))
 
     def test_ex_resize(self):
@@ -579,19 +584,22 @@ class OpenStack_1_1_Tests(unittest.TestC
                         driver=self.driver)
         try:
             self.driver.ex_resize(self.node, size)
-        except Exception, e:
+        except Exception:
+            e = sys.exc_info()[1]
             self.fail('An error was raised: ' + repr(e))
 
     def test_ex_confirm_resize(self):
         try:
             self.driver.ex_confirm_resize(self.node)
-        except Exception, e:
+        except Exception:
+            e = sys.exc_info()[1]
             self.fail('An error was raised: ' + repr(e))
 
     def test_ex_revert_resize(self):
         try:
             self.driver.ex_revert_resize(self.node)
-        except Exception, e:
+        except Exception:
+            e = sys.exc_info()[1]
             self.fail('An error was raised: ' + repr(e))
 
     def test_ex_save_image(self):

Modified: libcloud/branches/py3k/test/compute/test_slicehost.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/test/compute/test_slicehost.py?rev=1209943&r1=1209942&r2=1209943&view=diff
==============================================================================
--- libcloud/branches/py3k/test/compute/test_slicehost.py (original)
+++ libcloud/branches/py3k/test/compute/test_slicehost.py Sat Dec  3 16:27:10 2011
@@ -46,7 +46,8 @@ class SlicehostTest(unittest.TestCase, T
         SlicehostMockHttp.type = 'UNAUTHORIZED'
         try:
             ret = self.driver.list_nodes()
-        except InvalidCredsError, e:
+        except InvalidCredsError:
+            e = sys.exc_info()[1]
             self.assertEqual(e.value, 'HTTP Basic: Access denied.')
         else:
             self.fail('test should have thrown')
@@ -77,7 +78,8 @@ class SlicehostTest(unittest.TestCase, T
         SlicehostMockHttp.type = 'FORBIDDEN'
         try:
             ret = self.driver.reboot_node(node)
-        except Exception, e:
+        except Exception:
+            e = sys.exc_info()[1]
             self.assertEqual(e.args[0], 'Permission denied')
         else:
             self.fail('test should have thrown')

Modified: libcloud/branches/py3k/test/compute/test_softlayer.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/test/compute/test_softlayer.py?rev=1209943&r1=1209942&r2=1209943&view=diff
==============================================================================
--- libcloud/branches/py3k/test/compute/test_softlayer.py (original)
+++ libcloud/branches/py3k/test/compute/test_softlayer.py Sat Dec  3 16:27:10 2011
@@ -13,12 +13,14 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from libcloud.py3 import httplib
 import unittest
 import sys
 
 from xml.etree import ElementTree as ET
-import xmlrpclib
+
+from libcloud.py3 import httplib
+from libcloud.py3 import xmlrpclib
+from libcloud.py3 import next
 
 from libcloud.compute.drivers.softlayer import SoftLayerNodeDriver as SoftLayer
 from libcloud.compute.types import NodeState
@@ -57,7 +59,7 @@ class SoftLayerTests(unittest.TestCase):
 
     def test_list_locations(self):
         locations = self.driver.list_locations()
-        seattle = (l for l in locations if l.name == 'sea01').next()
+        seattle = next(l for l in locations if l.name == 'sea01')
         self.assertEqual(seattle.country, 'US')
         self.assertEqual(seattle.id, '18171')
 

Modified: libcloud/branches/py3k/test/compute/test_ssh_client.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/test/compute/test_ssh_client.py?rev=1209943&r1=1209942&r2=1209943&view=diff
==============================================================================
--- libcloud/branches/py3k/test/compute/test_ssh_client.py (original)
+++ libcloud/branches/py3k/test/compute/test_ssh_client.py Sat Dec  3 16:27:10 2011
@@ -30,7 +30,8 @@ class ParamikoSSHClientTests(unittest.Te
 
         try:
             client.connect()
-        except Exception, e:
+        except Exception:
+            e = sys.exc_info()[1]
             self.assertTrue(str(e).find('must specify either password or')
                             != -1)
         else:

Modified: libcloud/branches/py3k/test/compute/test_voxel.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/test/compute/test_voxel.py?rev=1209943&r1=1209942&r2=1209943&view=diff
==============================================================================
--- libcloud/branches/py3k/test/compute/test_voxel.py (original)
+++ libcloud/branches/py3k/test/compute/test_voxel.py Sat Dec  3 16:27:10 2011
@@ -37,7 +37,8 @@ class VoxelTest(unittest.TestCase):
         VoxelMockHttp.type = 'UNAUTHORIZED'
         try:
             self.driver.list_nodes()
-        except Exception, e:
+        except Exception:
+            e = sys.exc_info()[1]
             self.assertTrue(isinstance(e, InvalidCredsError))
         else:
             self.fail('test should have thrown')

Modified: libcloud/branches/py3k/test/compute/test_vpsnet.py
URL: http://svn.apache.org/viewvc/libcloud/branches/py3k/test/compute/test_vpsnet.py?rev=1209943&r1=1209942&r2=1209943&view=diff
==============================================================================
--- libcloud/branches/py3k/test/compute/test_vpsnet.py (original)
+++ libcloud/branches/py3k/test/compute/test_vpsnet.py Sat Dec  3 16:27:10 2011
@@ -14,7 +14,6 @@
 # limitations under the License.
 import sys
 import unittest
-import exceptions
 from libcloud.py3 import httplib
 
 from libcloud.compute.drivers.vpsnet import VPSNetNodeDriver
@@ -60,7 +59,7 @@ class VPSNetTests(unittest.TestCase, Tes
         self.assertTrue(ret)
         VPSNetMockHttp.type = 'delete_fail'
         node = Node('2223', None, None, None, None, self.driver)
-        self.assertRaises(exceptions.Exception, self.driver.destroy_node, node)
+        self.assertRaises(Exception, self.driver.destroy_node, node)
 
     def test_list_images(self):
         VPSNetMockHttp.type = 'templates'



Mime
View raw message