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

can't ls the root of a bucket? #52

Open
alexhuth opened this issue Nov 12, 2017 · 4 comments
Open

can't ls the root of a bucket? #52

alexhuth opened this issue Nov 12, 2017 · 4 comments

Comments

@alexhuth
Copy link
Contributor

I'm having trouble ls'ing the root of a bucket. might be a boto/botocore issue. the problem is that os.path.normpath turns '' into '.', and then botocore barfs.

for ref, boto is version 2.42.0, botocore is version 1.7.43. python 3.

In [37]: cci.ls('')
---------------------------------------------------------------------------
ClientError                               Traceback (most recent call last)
<ipython-input-37-cc8e9f569287> in <module>()
----> 1 cci.ls('')

/home/huth/anaconda3/lib/python3.5/site-packages/cottoncandy/utils.py in iremove_root(self, object_name, *args, **kwargs)
    264             object_name = object_name[1:]
    265 
--> 266         return input_function(self, object_name, *args, **kwargs)
    267     return iremove_root
    268 

/home/huth/anaconda3/lib/python3.5/site-packages/cottoncandy/interfaces.py in ls(self, pattern, page_size, limit, verbose)
    981         # get objects that match common prefix
    982         if not has_real_magic(pattern):
--> 983             object_names = self.lsdir(prefix, limit = limit)
    984         else:
    985             object_list = self.get_objects(filter = dict(Prefix = prefix),

/home/huth/anaconda3/lib/python3.5/site-packages/cottoncandy/interfaces.py in lsdir(self, path, limit)
    946             The children of the path.
    947         """
--> 948         return self.backend_interface.list_directory(path, limit)
    949 
    950     @clean_object_name

/home/huth/anaconda3/lib/python3.5/site-packages/cottoncandy/s3client.py in list_directory(self, path, limit)
    502                                                               Delimiter = SEPARATOR,
    503                                                               Prefix = path,
--> 504                                                               MaxKeys = limit)
    505         object_names = []
    506         if 'CommonPrefixes' in response:

/home/huth/anaconda3/lib/python3.5/site-packages/botocore/client.py in _api_call(self, *args, **kwargs)
    310                     "%s() only accepts keyword arguments." % py_operation_name)
    311             # The "self" in this scope is referring to the BaseClient.
--> 312             return self._make_api_call(operation_name, kwargs)
    313 
    314         _api_call.__name__ = str(py_operation_name)

/home/huth/anaconda3/lib/python3.5/site-packages/botocore/client.py in _make_api_call(self, operation_name, api_params)
    603             error_code = parsed_response.get("Error", {}).get("Code")
    604             error_class = self.exceptions.from_code(error_code)
--> 605             raise error_class(parsed_response, operation_name)
    606         else:
    607             return parsed_response

ClientError: An error occurred (XMinioInvalidResourceName) when calling the ListObjects operation: Resource name contains bad components such as ".." or ".".

also, related, running cci.ls with no arguments, which seems like it should ls the bucket root, just barfs because the decorator expects an argument:

In [40]: cci.ls()
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-40-ff42535b08a1> in <module>()
----> 1 cci.ls()

TypeError: iremove_root() missing 1 required positional argument: 'object_name'

if that's intended behavior, fine.

@anwarnunez
Copy link
Contributor

Yeah, the behavior of ls() lsdir() and glob() are a bit all over the place unfortunately.

For what you're trying to do, lsdir() works perfectly fine. I agree ls() should also behave without args or with ls('/').

@alexhuth
Copy link
Contributor Author

ah but with whateverthefuck version of boto/botocore i'm on, lsdir is lame:

In [41]: cci.lsdir()
Out[41]: <map at 0x7f311a943f28>

although, fortunately:

In [45]: list(cci.lsdir())
Out[45]: ['stuff.tar.gz', 'script.py']

and cci.glob works as expected.

@anwarnunez
Copy link
Contributor

oh that's annoying.
we can add a little isinstance check to the return object of lsdir() as a temporary hack.

they bigger issue of the ls() behavior remains. i probably won't get to this anytime soon though.

@anwarnunez
Copy link
Contributor

ok the behavior of lsdir is now to convert to list (see f1cacda). the remaining issue is behavior of ls() which is issue #37.

gonna leave this open so that we remember to fix the root path behavior.

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

No branches or pull requests

2 participants