libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r1210046 - in /libcloud/trunk: demos/ libcloud/common/ libcloud/compute/ libcloud/compute/drivers/ libcloud/dns/ libcloud/dns/drivers/ libcloud/storage/drivers/ libcloud/utils/ test/ test/compute/ test/storage/
Date Sun, 04 Dec 2011 02:25:11 GMT
Author: tomaz
Date: Sun Dec  4 02:25:10 2011
New Revision: 1210046

URL: http://svn.apache.org/viewvc?rev=1210046&view=rev
Log:
Some more Python 3 compatibility changes recommended by 2to3. Most of them are
not needed, but still adding them so it won't cause any surprises in the future.

Modified:
    libcloud/trunk/demos/compute_demo.py
    libcloud/trunk/libcloud/common/base.py
    libcloud/trunk/libcloud/common/cloudstack.py
    libcloud/trunk/libcloud/compute/base.py
    libcloud/trunk/libcloud/compute/drivers/bluebox.py
    libcloud/trunk/libcloud/compute/drivers/opennebula.py
    libcloud/trunk/libcloud/compute/drivers/openstack.py
    libcloud/trunk/libcloud/compute/drivers/softlayer.py
    libcloud/trunk/libcloud/compute/drivers/voxel.py
    libcloud/trunk/libcloud/dns/drivers/dummy.py
    libcloud/trunk/libcloud/dns/types.py
    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/misc.py
    libcloud/trunk/test/__init__.py
    libcloud/trunk/test/compute/test_elasticstack.py
    libcloud/trunk/test/compute/test_openstack.py
    libcloud/trunk/test/storage/test_atmos.py

Modified: libcloud/trunk/demos/compute_demo.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/demos/compute_demo.py?rev=1210046&r1=1210045&r2=1210046&view=diff
==============================================================================
--- libcloud/trunk/demos/compute_demo.py (original)
+++ libcloud/trunk/demos/compute_demo.py Sun Dec  4 02:25:10 2011
@@ -93,8 +93,9 @@ def main(argv):
     """
     try:
         driver = get_demo_driver()
-    except InvalidCredsError as ex:
-        print("Invalid Credentials: %s" % (ex.value,))
+    except InvalidCredsError:
+        e = sys.exc_info()[1]
+        print("Invalid Credentials: " + e.value)
         return 1
 
     try:
@@ -106,8 +107,9 @@ def main(argv):
 
         print(">> Loading sizes... (showing up to 10)")
         pprint(driver.list_sizes()[:10])
-    except Exception as ex:
-        print("A fatal error occurred: %s" % (ex,))
+    except Exception:
+        e = sys.exc_info()[1]
+        print("A fatal error occurred: " + e)
         return 1
 
 if __name__ == '__main__':

Modified: libcloud/trunk/libcloud/common/base.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/common/base.py?rev=1210046&r1=1210045&r2=1210046&view=diff
==============================================================================
--- libcloud/trunk/libcloud/common/base.py (original)
+++ libcloud/trunk/libcloud/common/base.py Sun Dec  4 02:25:10 2011
@@ -482,7 +482,7 @@ class Connection(object):
             if raw:
                 self.connection.putrequest(method, url)
 
-                for key, value in headers.items():
+                for key, value in list(headers.items()):
                     self.connection.putheader(key, str(value))
 
                 self.connection.endheaders()

Modified: libcloud/trunk/libcloud/common/cloudstack.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/common/cloudstack.py?rev=1210046&r1=1210045&r2=1210046&view=diff
==============================================================================
--- libcloud/trunk/libcloud/common/cloudstack.py (original)
+++ libcloud/trunk/libcloud/common/cloudstack.py Sun Dec  4 02:25:10 2011
@@ -37,7 +37,7 @@ class CloudStackConnection(ConnectionUse
     ASYNC_FAILURE = 2
 
     def _make_signature(self, params):
-        signature = [(k.lower(), v) for k, v in params.items()]
+        signature = [(k.lower(), v) for k, v in list(params.items())]
         signature.sort(key=lambda x: x[0])
         signature = urlencode(signature)
         signature = signature.lower().replace('+', '%20')

Modified: libcloud/trunk/libcloud/compute/base.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/base.py?rev=1210046&r1=1210045&r2=1210046&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/base.py (original)
+++ libcloud/trunk/libcloud/compute/base.py Sun Dec  4 02:25:10 2011
@@ -591,7 +591,7 @@ class NodeDriver(BaseDriver):
 
         while time.time() < end:
             nodes = self.list_nodes()
-            nodes = list(filter(lambda n: n.uuid == node.uuid, nodes))
+            nodes = list([n for n in nodes if n.uuid == node.uuid])
 
             if len(nodes) == 0:
                 raise LibcloudError(value=('Booted node[%s] ' % node

Modified: libcloud/trunk/libcloud/compute/drivers/bluebox.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/bluebox.py?rev=1210046&r1=1210045&r2=1210046&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/bluebox.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/bluebox.py Sun Dec  4 02:25:10 2011
@@ -135,7 +135,7 @@ class BlueboxNodeDriver(NodeDriver):
 
     def list_sizes(self, location=None):
         sizes = []
-        for key, values in BLUEBOX_INSTANCE_TYPES.items():
+        for key, values in list(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,

Modified: libcloud/trunk/libcloud/compute/drivers/opennebula.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/opennebula.py?rev=1210046&r1=1210045&r2=1210046&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/opennebula.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/opennebula.py Sun Dec  4 02:25:10 2011
@@ -653,7 +653,7 @@ class OpenNebula_2_0_NodeDriver(OpenNebu
         if 'context' in kwargs:
             if isinstance(kwargs['context'], dict):
                 contextGroup = ET.SubElement(compute, 'CONTEXT')
-                for key, value in kwargs['context'].items():
+                for key, value in list(kwargs['context'].items()):
                     context = ET.SubElement(contextGroup, key.upper())
                     context.text = value
 

Modified: libcloud/trunk/libcloud/compute/drivers/openstack.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/openstack.py?rev=1210046&r1=1210045&r2=1210046&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/openstack.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/openstack.py Sun Dec  4 02:25:10 2011
@@ -553,7 +553,7 @@ class OpenStack_1_0_NodeDriver(OpenStack
             return None
 
         metadata_elm = ET.Element('metadata')
-        for k, v in metadata.items():
+        for k, v in list(metadata.items()):
             meta_elm = ET.SubElement(metadata_elm, 'meta', {'key': str(k)})
             meta_elm.text = str(v)
 
@@ -564,7 +564,7 @@ class OpenStack_1_0_NodeDriver(OpenStack
             return None
 
         personality_elm = ET.Element('personality')
-        for k, v in files.items():
+        for k, v in list(files.items()):
             file_elm = ET.SubElement(personality_elm,
                                      'file',
                                      {'path': str(k)})
@@ -656,7 +656,7 @@ class OpenStack_1_0_NodeDriver(OpenStack
 
         def _to_rate(el):
             rate = {}
-            for item in el.items():
+            for item in list(el.items()):
                 rate[item[0]] = item[1]
 
             return rate
@@ -877,7 +877,7 @@ class OpenStack_1_1_NodeDriver(OpenStack
     def _files_to_personality(self, files):
         rv = []
 
-        for k, v in files.items():
+        for k, v in list(files.items()):
             rv.append({'path': k, 'contents': base64.b64encode(b(v))})
 
         return rv

Modified: libcloud/trunk/libcloud/compute/drivers/softlayer.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/softlayer.py?rev=1210046&r1=1210045&r2=1210046&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/softlayer.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/softlayer.py Sun Dec  4 02:25:10 2011
@@ -398,7 +398,8 @@ class SoftLayerNodeDriver(NodeDriver):
         )
 
     def list_sizes(self, location=None):
-        return [self._to_size(id, s['imagedata']) for id, s in SL_TEMPLATES.items()]
+        return [self._to_size(id, s['imagedata']) for id, s in 
+                list(SL_TEMPLATES.items())]
 
     def _to_loc(self, loc):
         return NodeLocation(

Modified: libcloud/trunk/libcloud/compute/drivers/voxel.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/compute/drivers/voxel.py?rev=1210046&r1=1210045&r2=1210046&view=diff
==============================================================================
--- libcloud/trunk/libcloud/compute/drivers/voxel.py (original)
+++ libcloud/trunk/libcloud/compute/drivers/voxel.py Sun Dec  4 02:25:10 2011
@@ -79,7 +79,8 @@ 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 = dict([(k, v) for k, v in list(params.items())
+                       if v is not None])
         params["key"] = self.user_id
         params["timestamp"] = datetime.datetime.utcnow().isoformat()+"+0000"
 
@@ -147,7 +148,7 @@ class VoxelNodeDriver(NodeDriver):
 
     def list_sizes(self, location=None):
         return [ NodeSize(driver=self.connection.driver, **i)
-                 for i in VOXEL_INSTANCE_TYPES.values() ]
+                 for i in list(VOXEL_INSTANCE_TYPES.values()) ]
 
     def list_images(self, location=None):
         params = {"method": "voxel.images.list"}

Modified: libcloud/trunk/libcloud/dns/drivers/dummy.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/dns/drivers/dummy.py?rev=1210046&r1=1210045&r2=1210046&view=diff
==============================================================================
--- libcloud/trunk/libcloud/dns/drivers/dummy.py (original)
+++ libcloud/trunk/libcloud/dns/drivers/dummy.py Sun Dec  4 02:25:10 2011
@@ -50,7 +50,7 @@ class DummyDNSDriver(DNSDriver):
         []
         """
 
-        return [zone['zone'] for zone in self._zones.values()]
+        return [zone['zone'] for zone in list(self._zones.values())]
 
     def list_records(self, zone):
         return self.get_zone(zone_id=zone.id).records

Modified: libcloud/trunk/libcloud/dns/types.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/dns/types.py?rev=1210046&r1=1210045&r2=1210046&view=diff
==============================================================================
--- libcloud/trunk/libcloud/dns/types.py (original)
+++ libcloud/trunk/libcloud/dns/types.py Sun Dec  4 02:25:10 2011
@@ -56,7 +56,7 @@ class RecordType(object):
 
     @classmethod
     def __repr__(self, value):
-        reverse = dict((v, k) for k, v in RecordType.__dict__.items())
+        reverse = dict((v, k) for k, v in list(RecordType.__dict__.items()))
         return reverse[value]
 
 

Modified: libcloud/trunk/libcloud/storage/drivers/atmos.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/storage/drivers/atmos.py?rev=1210046&r1=1210045&r2=1210046&view=diff
==============================================================================
--- libcloud/trunk/libcloud/storage/drivers/atmos.py (original)
+++ libcloud/trunk/libcloud/storage/drivers/atmos.py Sun Dec  4 02:25:10 2011
@@ -90,11 +90,12 @@ class AtmosConnection(ConnectionUserAndK
             pathstring = pathstring[len(self.driver.path):]
         if params:
             if type(params) is dict:
-                params = params.items()
+                params = list(params.items())
             pathstring += '?' + urlencode(params)
         pathstring = pathstring.lower()
 
-        xhdrs = [(k, v) for k, v in headers.items() if k.startswith('x-emc-')]
+        xhdrs = [(k, v) for k, v in list(headers.items()) if
+                 k.startswith('x-emc-')]
         xhdrs.sort(key=lambda x: x[0])
 
         signature = [
@@ -237,7 +238,8 @@ class AtmosDriver(StorageDriver):
         else:
             meta_data = extra.get('meta_data', {})
         meta_data['md5'] = result_dict['data_hash']
-        user_meta = ', '.join([k + '=' + str(v) for k, v in meta_data.items()])
+        user_meta = ', '.join([k + '=' + str(v) for k, v in
+                               list(meta_data.items())])
         self.connection.request(request_path + '?metadata/user', method='POST',
                                 headers={'x-emc-meta': user_meta})
         result = self.connection.request(request_path + '?metadata/system')
@@ -292,7 +294,8 @@ class AtmosDriver(StorageDriver):
         else:
             meta_data = extra.get('meta_data', {})
         meta_data['md5'] = data_hash
-        user_meta = ', '.join([k + '=' + str(v) for k, v in meta_data.items()])
+        user_meta = ', '.join([k + '=' + str(v) for k, v in
+                               list(meta_data.items())])
         self.connection.request(path + '?metadata/user', method='POST',
                                 headers={'x-emc-meta': user_meta})
 

Modified: libcloud/trunk/libcloud/storage/drivers/cloudfiles.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/storage/drivers/cloudfiles.py?rev=1210046&r1=1210045&r2=1210046&view=diff
==============================================================================
--- libcloud/trunk/libcloud/storage/drivers/cloudfiles.py (original)
+++ libcloud/trunk/libcloud/storage/drivers/cloudfiles.py Sun Dec  4 02:25:10 2011
@@ -389,7 +389,7 @@ class CloudFilesStorageDriver(StorageDri
 
         headers = {}
         if meta_data:
-            for key, value in meta_data.items():
+            for key, value in list(meta_data.items()):
                 key = 'X-Object-Meta-%s' % (key)
                 headers[key] = value
 
@@ -498,7 +498,7 @@ class CloudFilesStorageDriver(StorageDri
         content_type = headers.pop('content-type', None)
 
         meta_data = {}
-        for key, value in headers.items():
+        for key, value in list(headers.items()):
             if key.find('x-object-meta-') != -1:
                 key = key.replace('x-object-meta-', '')
                 meta_data[key] = value

Modified: libcloud/trunk/libcloud/storage/drivers/dummy.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/storage/drivers/dummy.py?rev=1210046&r1=1210045&r2=1210046&view=diff
==============================================================================
--- libcloud/trunk/libcloud/storage/drivers/dummy.py (original)
+++ libcloud/trunk/libcloud/storage/drivers/dummy.py Sun Dec  4 02:25:10 2011
@@ -145,7 +145,7 @@ class DummyStorageDriver(StorageDriver):
         """
 
         return [container['container'] for container in
-                self._containers.values()]
+                list(self._containers.values())]
 
     def list_container_objects(self, container):
         container = self.get_container(container.name)

Modified: libcloud/trunk/libcloud/storage/drivers/google_storage.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/storage/drivers/google_storage.py?rev=1210046&r1=1210045&r2=1210046&view=diff
==============================================================================
--- libcloud/trunk/libcloud/storage/drivers/google_storage.py (original)
+++ libcloud/trunk/libcloud/storage/drivers/google_storage.py Sun Dec  4 02:25:10 2011
@@ -81,7 +81,7 @@ class GoogleStorageConnection(Connection
         extension_header_values = {}
 
         headers_copy = copy.deepcopy(headers)
-        for key, value in headers_copy.items():
+        for key, value in list(headers_copy.items()):
             if key.lower() in special_header_keys:
                 if key.lower() == 'date':
                     value = value.strip()

Modified: libcloud/trunk/libcloud/storage/drivers/s3.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/storage/drivers/s3.py?rev=1210046&r1=1210045&r2=1210046&view=diff
==============================================================================
--- libcloud/trunk/libcloud/storage/drivers/s3.py (original)
+++ libcloud/trunk/libcloud/storage/drivers/s3.py Sun Dec  4 02:25:10 2011
@@ -117,7 +117,7 @@ class S3Connection(ConnectionUserAndKey)
         amz_header_values = {}
 
         headers_copy = copy.deepcopy(headers)
-        for key, value in headers_copy.items():
+        for key, value in list(headers_copy.items()):
             if key.lower() in special_header_keys:
                 special_header_values[key.lower()] = value.lower().strip()
             elif key.lower().startswith('x-amz-'):
@@ -383,7 +383,7 @@ class S3StorageDriver(StorageDriver):
         meta_data = extra.get('meta_data', None)
 
         if meta_data:
-            for key, value in meta_data.items():
+            for key, value in list(meta_data.items()):
                 key = 'x-amz-meta-%s' % (key)
                 headers[key] = value
 

Modified: libcloud/trunk/libcloud/utils/misc.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/libcloud/utils/misc.py?rev=1210046&r1=1210045&r2=1210046&view=diff
==============================================================================
--- libcloud/trunk/libcloud/utils/misc.py (original)
+++ libcloud/trunk/libcloud/utils/misc.py Sun Dec  4 02:25:10 2011
@@ -57,7 +57,7 @@ def get_new_obj(obj, klass, attributes):
     constructor if they are not None.
     """
     kwargs = {}
-    for key, value in obj.__dict__.items():
+    for key, value in list(obj.__dict__.items()):
         if isinstance(value, dict):
             kwargs[key] = value.copy()
         elif isinstance(value, (tuple, list)):
@@ -65,13 +65,13 @@ def get_new_obj(obj, klass, attributes):
         else:
             kwargs[key] = value
 
-    for key, value in attributes.items():
+    for key, value in list(attributes.items()):
         if value is None:
             continue
 
         if isinstance(value, dict):
             kwargs_value = kwargs.get(key, {})
-            for key1, value2 in value.items():
+            for key1, value2 in list(value.items()):
                 if value2 is None:
                     continue
 
@@ -183,4 +183,4 @@ def dict2str(data):
 
 
 def reverse_dict(dictionary):
-    return dict([(value, key) for key, value in dictionary.items()])
+    return dict([(value, key) for key, value in list(dictionary.items())])

Modified: libcloud/trunk/test/__init__.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/__init__.py?rev=1210046&r1=1210045&r2=1210046&view=diff
==============================================================================
--- libcloud/trunk/test/__init__.py (original)
+++ libcloud/trunk/test/__init__.py Sun Dec  4 02:25:10 2011
@@ -89,7 +89,7 @@ class MockResponse(object):
         return self.headers.get(name, *args, **kwargs)
 
     def getheaders(self):
-        return self.headers.items()
+        return list(self.headers.items())
 
     def msg(self):
         raise NotImplemented

Modified: libcloud/trunk/test/compute/test_elasticstack.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_elasticstack.py?rev=1210046&r1=1210045&r2=1210046&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_elasticstack.py (original)
+++ libcloud/trunk/test/compute/test_elasticstack.py Sun Dec  4 02:25:10 2011
@@ -121,7 +121,7 @@ class ElasticStackTestCase(object):
         images = self.driver.list_images()
         self.assertEqual(len(images), len(self.driver._standard_drives))
 
-        for uuid, values in self.driver._standard_drives.items():
+        for uuid, values in list(self.driver._standard_drives.items()):
             self.assertEqual(len([image for image in images if image.id == uuid]), 1)
 
     def test_reboot_node(self):

Modified: libcloud/trunk/test/compute/test_openstack.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/compute/test_openstack.py?rev=1210046&r1=1210045&r2=1210046&view=diff
==============================================================================
--- libcloud/trunk/test/compute/test_openstack.py (original)
+++ libcloud/trunk/test/compute/test_openstack.py Sun Dec  4 02:25:10 2011
@@ -151,8 +151,8 @@ class OpenStack_1_0_Tests(unittest.TestC
                          'created': '2009-11-29T20:22:09-06:00',
                          'updated': '2009-11-29T20:24:08-06:00',
                          'progress': '100'}}
-        for ret_idx, extra in expected.items():
-            for key, value in extra.items():
+        for ret_idx, extra in list(expected.items()):
+            for key, value in list(extra.items()):
                 self.assertEqual(ret[ret_idx].extra[key], value)
 
     def test_create_node(self):

Modified: libcloud/trunk/test/storage/test_atmos.py
URL: http://svn.apache.org/viewvc/libcloud/trunk/test/storage/test_atmos.py?rev=1210046&r1=1210045&r2=1210046&view=diff
==============================================================================
--- libcloud/trunk/test/storage/test_atmos.py (original)
+++ libcloud/trunk/test/storage/test_atmos.py Sun Dec  4 02:25:10 2011
@@ -468,7 +468,7 @@ class AtmosMockHttp(StorageMockHttp, uni
             'mtime': '2011-01-25T22:01:49Z'
         }
         headers = {
-            'x-emc-meta': ', '.join([k + '=' + v for k, v in meta.items()])
+            'x-emc-meta': ', '.join([k + '=' + v for k, v in list(meta.items())])
         }
         return (httplib.OK, '', headers, httplib.responses[httplib.OK])
 
@@ -481,7 +481,7 @@ class AtmosMockHttp(StorageMockHttp, uni
             'bar-foo': 'test 2',
         }
         headers = {
-            'x-emc-meta': ', '.join([k + '=' + v for k, v in meta.items()])
+            'x-emc-meta': ', '.join([k + '=' + v for k, v in list(meta.items())])
         }
         return (httplib.OK, '', headers, httplib.responses[httplib.OK])
 
@@ -518,7 +518,7 @@ class AtmosMockHttp(StorageMockHttp, uni
             'mtime': '2011-01-25T22:01:49Z'
         }
         headers = {
-            'x-emc-meta': ', '.join([k + '=' + v for k, v in meta.items()])
+            'x-emc-meta': ', '.join([k + '=' + v for k, v in list(meta.items())])
         }
         return (httplib.OK, '', headers, httplib.responses[httplib.OK])
 
@@ -543,7 +543,7 @@ class AtmosMockHttp(StorageMockHttp, uni
             'mtime': '2011-01-25T22:01:49Z'
         }
         headers = {
-            'x-emc-meta': ', '.join([k + '=' + v for k, v in meta.items()])
+            'x-emc-meta': ', '.join([k + '=' + v for k, v in list(meta.items())])
         }
         return (httplib.OK, '', headers, httplib.responses[httplib.OK])
 



Mime
View raw message