Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

container list_subdirs not working #342

Closed
andreabedini opened this issue Apr 7, 2014 · 0 comments
Closed

container list_subdirs not working #342

andreabedini opened this issue Apr 7, 2014 · 0 comments
Labels

Comments

@andreabedini
Copy link

Hi,

I am following this guide and I think container method list_subdirs is misbehaving. Perhaps it's related to #341

So I have the following

In [23]: cont.get_object_names()
Out[23]: 
['series_0',
 'series_1',
 'series_2',
 'series_3',
 'series_4',
 'stuff/aaaa',
 'stuff/bbbb',
 'stuff/cccc',
 'stuff/dddd',
 'stuff/eeee']

In [24]: cont.list_subdirs(delimiter='/')
Out[24]: []

where I would expect ['stuff'].

If I read the code properly it seems that list_container_subdirs expects content-type application/directory but the server responds with a different format {'subdir': 'stuff/'}

In [27]: cf.connection.get_container('my_objects', delimiter='/')

Out[27]: 
({'accept-ranges': 'bytes',
  'content-length': '867',
  'content-type': 'application/json; charset=utf-8',
  'date': 'Mon, 07 Apr 2014 09:31:46 GMT',
  'x-container-bytes-used': '90',
  'x-container-object-count': '10',
  'x-timestamp': '1396861333.97254',
  'x-trans-id': 'tx3b9a6176d84c4ecf8e013-0053427082syd2'},
 [{'bytes': 9,
   'content_type': 'application/octet-stream',
   'hash': '552e21cd4cd9918678e3c1a0df491bc3',
   'last_modified': '2014-04-07T09:03:18.162010',
   'name': 'series_0'},
  {'bytes': 9,
   'content_type': 'application/octet-stream',
   'hash': '552e21cd4cd9918678e3c1a0df491bc3',
   'last_modified': '2014-04-07T09:03:18.918770',
   'name': 'series_1'},
  {'bytes': 9,
   'content_type': 'application/octet-stream',
   'hash': '552e21cd4cd9918678e3c1a0df491bc3',
   'last_modified': '2014-04-07T09:03:19.725810',
   'name': 'series_2'},
  {'bytes': 9,
   'content_type': 'application/octet-stream',
   'hash': '552e21cd4cd9918678e3c1a0df491bc3',
   'last_modified': '2014-04-07T09:03:20.534650',
   'name': 'series_3'},
  {'bytes': 9,
   'content_type': 'application/octet-stream',
   'hash': '552e21cd4cd9918678e3c1a0df491bc3',
   'last_modified': '2014-04-07T09:03:21.082820',
   'name': 'series_4'},
  {'subdir': 'stuff/'}])

I also got the following exception, which might give a hint on where the problem is.

In [26]: cont.get_object_names(delimiter='/')
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
<ipython-input-26-ccb2c211b506> in <module>()
----> 1 cont.get_object_names(delimiter='/')

/usr/local/lib/python2.7/site-packages/pyrax/cf_wrapper/container.pyc in get_object_names(self, marker, limit, prefix, delimiter, full_listing)
    124         return self.client.get_container_object_names(self.name, marker=marker,
    125                 limit=limit, prefix=prefix, delimiter=delimiter,
--> 126                 full_listing=full_listing)
    127 
    128 

/usr/local/lib/python2.7/site-packages/pyrax/cf_wrapper/client.pyc in _wrapped(self, *args, **kwargs)
     71             try:
     72                 _close_swiftclient_conn(self.connection)
---> 73                 ret = fnc(self, *args, **kwargs)
     74                 return ret
     75             except _swift_client.ClientException as e:

/usr/local/lib/python2.7/site-packages/pyrax/cf_wrapper/client.pyc in get_container_object_names(self, container, marker, limit, prefix, delimiter, full_listing)
   1156                 full_listing=full_listing)
   1157         cont = self.get_container(cname)
-> 1158         return [obj["name"] for obj in objs]
   1159 
   1160 

KeyError: 'name'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants