Unicode support in results
authorStavros Sachtouris <saxtouri@admin.grnet.gr>
Mon, 2 Jul 2012 15:16:56 +0000 (18:16 +0300)
committerStavros Sachtouris <saxtouri@admin.grnet.gr>
Tue, 10 Jul 2012 14:09:27 +0000 (17:09 +0300)
Replaced str() with unicode() in kamaki/utils

kamaki/cli.py
kamaki/clients/storage.py
kamaki/utils.py

index 9c43e4c..2b8bd48 100755 (executable)
@@ -747,8 +747,6 @@ class store_list(_store_container_command):
             size = self.format_size(object['bytes'])
             print('%6s %s' % (size, object['name']))
 
-
-
 @command(api='storage')
 class store_upload(_store_container_command):
     """Upload a file"""
@@ -808,7 +806,6 @@ class store_purge(_store_account_command):
         super(store_purge, self).main()
         self.client.purge_container(container)
 
-
 @command(api='astakos')
 class astakos_authenticate(object):
     """Authenticate a user"""
index 030fe27..5b6a09d 100644 (file)
@@ -74,6 +74,13 @@ class StorageClient(Client):
 
         return reply
 
+    def list_containers(self):
+        self.assert_account()
+        path = '/%s' % (self.account) 
+        params = dict(format='json')
+        r = self.get(path, params = params, success = (200, 204))
+        return r.json
+
     def create_object(self, object, f, size=None, hash_cb=None,
                       upload_cb=None):
         # This is a naive implementation, it loads the whole file in memory
@@ -98,18 +105,7 @@ class StorageClient(Client):
         self.assert_container()
         path = '/%s/%s/%s' % (self.account, self.container, object)
         self.delete(path, success=204)
-
-
-    #list methods
-    
-    def list_containers(self):
-        self.assert_container()
-        path = '/%s' % (self.account) 
-        params = dict(format='json')
-        r = self.get(path, params = params, success = (200, 204))
-        return r.json
         
-
     def list_objects(self, path=''):
         self.assert_container()
         path = '/%s/%s' % (self.account, self.container)
index bb4f5ae..34a97d9 100644 (file)
@@ -67,7 +67,7 @@ def print_dict(d, exclude=()):
             print_addresses(val.get('values', []), margin)
             continue
         elif key == 'servers':
-            val = ', '.join(str(x) for x in val['values'])
+            val = ', '.join(unicode(x) for x in val['values'])
         elif isinstance(val, dict):
             if val.keys() == ['values']:
                 val = val['values']
@@ -81,7 +81,7 @@ def print_dict(d, exclude=()):
 
 def print_items(items, title=('id', 'name')):
     for item in items:
-        print ' '.join(str(item.pop(key)) for key in title if key in item)
+        print ' '.join(unicode(item.pop(key)) for key in title if key in item)
         if item:
             print_dict(item)
             print