Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Container with unicode file names #94

Open
nmorenor opened this issue Jul 22, 2015 · 11 comments
Open

Container with unicode file names #94

nmorenor opened this issue Jul 22, 2015 · 11 comments
Assignees

Comments

@nmorenor
Copy link

Hi,

Hi I'm trying to download a container that contains files with unicode characters in the name and I'm getting these errors.

Using a command like:

turbolift -u ${user} -a ${api_key} --os-rax-auth ord download -c ${container name}

File "/usr/local/lib/python2.7/urllib.py", line 1294, in quote
return ''.join(map(quoter, s))
KeyError: u'\u0301'
Processing - [ / ] - Number of Jobs in Queue = 0 Processing workload... Done.
Processing - [ \ ] - Number of Jobs in Queue = 0 Processing workload... Done.
Processing - [ / ] - Number of Jobs in Queue = 8 Processing workload... Process Process-241864:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
Processing - [ - ] - Number of Jobs in Queue = 8 Processing workload... self.run()
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(_self._args, *_self._kwargs)
File "build/bdist.linux-x86_64/egg/turbolift/methods/init.py", line 323, in _process_func
func(**queue.get(timeout=.5))
File "build/bdist.linux-x86_64/egg/turbolift/methods/init.py", line 136, in _get
local_object=local_object
File "build/bdist.linux-x86_64/egg/turbolift/clouderator/utils.py", line 41, in f_retry
return f(_args, *_kwargs)
File "build/bdist.linux-x86_64/egg/turbolift/clouderator/actions.py", line 618, in get_items
container_object=container_object
File "build/bdist.linux-x86_64/egg/turbolift/clouderator/actions.py", line 69, in _return_base_data
_container_uri, cloud_utils.quoter(container_object)
File "build/bdist.linux-x86_64/egg/turbolift/clouderator/utils.py", line 144, in quoter
return urllib.quote(obj)
File "/usr/local/lib/python2.7/urllib.py", line 1294, in quote
return ''.join(map(quoter, s))
KeyError: u'\u0301'

Awesome client, keep up the work :)

@cloudnull
Copy link
Owner

@nmorenor Thanks for reporting this issue. It seems that this is a problem in Python 2.7 and not for python 3.4. I am working on a fix and will hopefully have that up soon.

cloudnull added a commit that referenced this issue Jul 23, 2015
The quoter function was not able to deal with a unicode encoded
unicode string when running on Python2.7. When something like this
was passed it would result in a KeyError. To fix this a "try/Except"
was added to the system such that it allows the origial value to be
passed back from the method in such a case. This was done because
we can safely assume that a unicode encoded unicode string is already
in a state that has been quoted for use both remotely and locally.

This also fixed a typo as urlparse was miss-spelled.

Closes-Bug: #94

Signed-off-by: Kevin Carter <[email protected]>
cloudnull added a commit that referenced this issue Jul 23, 2015
The quoter function was not able to deal with a unicode encoded
unicode string when running on Python2.7. When something like this
was passed it would result in a KeyError. To fix this a "try/Except"
was added to the system such that it allows the origial value to be
passed back from the method in such a case. This was done because
we can safely assume that a unicode encoded unicode string is already
in a state that has been quoted for use both remotely and locally.

Closes-Bug: #94

Signed-off-by: Kevin Carter <[email protected]>
@cloudnull
Copy link
Owner

I pushed a change to master which should fix this please let me know if there continues to be an issue of if this is resolved.

@nmorenor
Copy link
Author

Now it is not throwing the same error however, it is printing:

/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib.py:1294: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
return ''.join(map(quoter, s))

Hopefully this is just a warning, and it will do the right thing.

Thanks

@cloudnull
Copy link
Owner

yea the warning is expected however with the previous commit it should pass the original data through the function. That said let me know if its not working as expected.

@nmorenor
Copy link
Author

Hi,

I just get in to this, seems it is concerning this same issue, with the new code from master

Process Process-13:
Traceback (most recent call last):
File "/home/user/.pythonbrew/pythons/Python-2.7.9/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/home/user/.pythonbrew/pythons/Python-2.7.9/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(_self._args, *_self._kwargs)
File "build/bdist.linux-x86_64/egg/turbolift/methods/init.py", line 323, in _process_func
func(**queue.get(timeout=.5))
File "build/bdist.linux-x86_64/egg/turbolift/methods/init.py", line 136, in _get
local_object=local_object
File "build/bdist.linux-x86_64/egg/turbolift/clouderator/utils.py", line 41, in f_retry
return f(_args, *_kwargs)
File "build/bdist.linux-x86_64/egg/turbolift/clouderator/actions.py", line 625, in get_items
local_object=local_object
File "build/bdist.linux-x86_64/egg/turbolift/clouderator/utils.py", line 46, in f_retry
return f(_args, *_kwargs)
File "build/bdist.linux-x86_64/egg/turbolift/clouderator/actions.py", line 221, in _getter
with open(local_object, 'wb') as f_name:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf1' in position 58: ordinal not in range(128)

@nmorenor
Copy link
Author

Seems that this is related to that python brew install of python, I just tried to compile install the python 2.7.9 on that same box, it seems to be working now

Cheers
Ignacio

@nmorenor
Copy link
Author

Mhmm... I just hit the same issue again.

UnicodeEncodeError: 'ascii' codec can't encode character u'\xf1' in position 58: ordinal not in range(128)
Processing - [ | ] - Number of Jobs in Queue = 0 Processing workload... Process Process-724:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(_self._args, *_self._kwargs)
File "build/bdist.linux-x86_64/egg/turbolift/methods/init.py", line 323, in _process_func
func(**queue.get(timeout=.5))
File "build/bdist.linux-x86_64/egg/turbolift/methods/init.py", line 136, in _get
local_object=local_object
File "build/bdist.linux-x86_64/egg/turbolift/clouderator/utils.py", line 41, in f_retry
return f(_args, *_kwargs)
File "build/bdist.linux-x86_64/egg/turbolift/clouderator/actions.py", line 625, in get_items
local_object=local_object
File "build/bdist.linux-x86_64/egg/turbolift/clouderator/utils.py", line 46, in f_retry
return f(_args, *_kwargs)
File "build/bdist.linux-x86_64/egg/turbolift/clouderator/actions.py", line 221, in _getter
with open(local_object, 'wb') as f_name:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 54: ordinal not in range(128)

@cloudnull
Copy link
Owner

do you know what versions of Python you're running? Also whats the base OS? I've not been able recreate this issue in Python 2.7.10 and 3.4.3

@nmorenor
Copy link
Author

I'm running turbolift in a linux debian 6 (squeeze) with python 2.7.9. I had to compile it to get that version of python, I also tried to use the 3.4.3 but it did not allow me to install turbolift.

In order to make progress I had to add something like:

with open(local_object.encode("utf-8"), 'wb') as f_name:

and do the same for all other places that reference to "local_object" in "turbolift/clouderator/actions.py" _getter function. But seems that I now need to set a smaller number of jobs because of a memory error. I guess "utf-8" is expensive

@nmorenor
Copy link
Author

This is the error I got about memory, note that I've modified some lines at "turbolift/clouderator/actions.py"

Processing - [ - ] - Number of Jobs in Queue = 68 Processing workload... /usr/local/lib/python2.7/urllib.py:1294: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
return ''.join(map(quoter, s))
Processing Process Process-68296:bs in Queue = 39 Processing workload...
Traceback (most recent call last):
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(_self._args, *_self._kwargs)
File "build/bdist.linux-x86_64/egg/turbolift/methods/init.py", line 323, in _process_func
load_entry_point('turbolift==3.0.0', 'console_scripts', 'turbolift')()
File "build/bdist.linux-x86_64/egg/turbolift/executable.py", line 59, in execute
Process Process-68295:
File "build/bdist.linux-x86_64/egg/turbolift/worker.py", line 130, in run_manager
File "build/bdist.linux-x86_64/egg/turbolift/methods/download.py", line 79, in start
Traceback (most recent call last):
File "build/bdist.linux-x86_64/egg/turbolift/methods/init.py", line 298, in _multi_processor
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
File "build/bdist.linux-x86_64/egg/cloudlib/indicator.py", line 64, in exit
File "build/bdist.linux-x86_64/egg/cloudlib/indicator.py", line 100, in stop
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 155, in is_alive
assert self._parent_pid == os.getpid(), 'can only test a child process'
AssertionError: can only test a child process
self.run()
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(_self._args, *_self._kwargs)
File "build/bdist.linux-x86_64/egg/turbolift/methods/init.py", line 323, in _process_func
Process Process-68303:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(_self._args, *_self._kwargs)
File "build/bdist.linux-x86_64/egg/turbolift/methods/init.py", line 323, in _process_func
Process Process-68305:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(_self._args, *_self._kwargs)
File "build/bdist.linux-x86_64/egg/turbolift/methods/init.py", line 323, in _process_func
Process Process-68300:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(_self._args, *_self._kwargs)
File "build/bdist.linux-x86_64/egg/turbolift/methods/init.py", line 323, in _process_func
Process Process-68304:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(_self._args, *_self._kwargs)
File "build/bdist.linux-x86_64/egg/turbolift/methods/init.py", line 323, in _process_func
Done.
Traceback (most recent call last):
File "/usr/local/bin/turbolift", line 9, in
load_entry_point('turbolift==3.0.0', 'console_scripts', 'turbolift')()
File "build/bdist.linux-x86_64/egg/turbolift/executable.py", line 59, in execute
File "build/bdist.linux-x86_64/egg/turbolift/worker.py", line 130, in run_manager
File "build/bdist.linux-x86_64/egg/turbolift/methods/download.py", line 79, in start
File "build/bdist.linux-x86_64/egg/turbolift/methods/init.py", line 289, in _multi_processor
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 130, in start
self._popen = Popen(self)
File "/usr/local/lib/python2.7/multiprocessing/forking.py", line 121, in init
self.pid = os.fork()
OSError: [Errno 12] Cannot allocate memory
Process Process-68301:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/usr/local/lib/python2.7/multiprocessing/process.py", line 114

@nmorenor
Copy link
Author

The memory thing was a local configuration thing, however I did had to make that change to encode on uff-8 and that just work: "open(local_object.encode("utf-8"), 'wb') as f_name:" It just worked for me.

Thanks
Ignacio

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

No branches or pull requests

2 participants