yadayada / acd_cli

An unmaintained command line interface and FUSE filesystem for Amazon (Cloud) Drive
Other
1.35k stars 165 forks source link

Unicode and upload command #485

Open rubstew opened 7 years ago

rubstew commented 7 years ago

I have problems with upload command and files with some ascii characters like 'á'. How can I change utf-8 to ascii in python?

Arguments: ()
16-11-16 21:11:52.175 [ERROR] [acd_cli] - Traceback (most recent call last):
  File "/usr/local/bin/acd_cli.py", line 255, in wrapped
    ret_val = f(*args, **kwargs)
  File "/usr/local/bin/acd_cli.py", line 500, in upload_file
    deduplication=dedup)
  File "/usr/local/lib/python3.4/dist-packages/acdcli/api/content.py", line 132,            in upload_file
    (quote_plus(basename), f, mime_type))]))
  File "/usr/lib/python3.4/urllib/parse.py", line 705, in quote_plus
    return quote(string, safe, encoding, errors)
  File "/usr/lib/python3.4/urllib/parse.py", line 688, in quote
    string = string.encode(encoding, errors)
UnicodeEncodeError: 'utf-8' codec can't encode character '\udcc3' in position 6:            surrogates not allowed

Thanks.

yadayada commented 7 years ago

Please tell me some of the full filenames.

rubstew commented 7 years ago

33.Maná.&.Nicky.Jam.De.Pies.A.Cabeza-TDG.mp3 27.Imany.Don´t.Be.So.Shy.[Filtavo.&.Karas.Remix]-TDG.mp3 '23.Dani.Martín.Los.Charcos-TDG.mp3'

Thanks

rubstew commented 7 years ago

Any news? there is any solution for this topic?

Thanks.

Markwexx commented 7 years ago

I'm having a similar issue with uploading files containing non-english (international) characters.

'acd_cli upload' and 'acd_cli tree' from my Mac is fine. 'acd_cli --utf tree' from system B on same files also fine, incl. correctly displaying international characters, but 'acd_cli --utf upload' from system B causes: [lines deleted] File "/lib/python3.6/site-packages/acdcli/cache/query.py", line 237, in get_child c.execute(CHILD_OF_SQL, [child_name, folder_id]) UnicodeEncodeError: 'utf-8' codec can't encode characters in position 1-2: surrogates not allowed

Trying: for root, dirs, files in os.walk('.'): print(root)

on system B on same files displays international characters correctly, so I'm assuming it's not my Python.

Any ideas ?

yadayada commented 7 years ago

@rubstew Could you please give the latest commit a try?

Markwexx commented 7 years ago

Hi,

installing the latest commit produced no change to the problem I'm having (same error output). I have though now realized my problem description was not very accurate. The international characters are in fact in the path, and not the actual file name. I've now also tried an upload with the actual file (and only the file) name having international characters. This produces the following error messages:

Traceback (most recent call last): File "/mnt/HD_a2/ffp/bin/acd_cli.py", line 299, in wrapped ret_val = f(*args, **kwargs) File "/mnt/HD_a2/ffp/bin/acd_cli.py", line 522, in upload_file conflicting_node = cache.get_conflicting_node(short_nm, parent_id) File "/ffp/lib/python3.6/site-packages/acdcli/cache/query.py", line 156, in get_conflicting_node c.execute(CONFLICTING_NODE_SQL, [parent_id, name.lower()]) UnicodeEncodeError: 'utf-8' codec can't encode characters in position 5-6: surrogates not allowed

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/mnt/HD_a2/Python-3.6.0b3/Lib/logging/init.py", line 989, in emit stream.write(msg) ValueError: underlying buffer has been detached Call stack: File "/mnt/HD_a2/Python-3.6.0b3/Lib/threading.py", line 884, in _bootstrap self._bootstrap_inner() File "/mnt/HD_a2/Python-3.6.0b3/Lib/threading.py", line 916, in _bootstrap_inner self.run() File "/mnt/HD_a2/Python-3.6.0b3/Lib/threading.py", line 864, in run self._target(*self._args, *self._kwargs) File "/ffp/lib/python3.6/site-packages/acdcli/utils/threading.py", line 40, in _worker_task rr = f() File "/mnt/HD_a2/ffp/bin/acd_cli.py", line 302, in wrapped logger.error(traceback.format_exc()) Message: 'Traceback (most recent call last):\n File "/mnt/HD_a2/ffp/bin/acd_cli.py", line 299, in wrapped\n ret_val = f(args, **kwargs)\n File "/mnt/HD_a2/ffp/bin/acd_cli.py", line 522, in upload_file\n conflicting_node = cache.get_conflicting_node(short_nm, parent_id)\n File "/ffp/lib/python3.6/site-packages/acdcli/cache/query.py", line 156, in get_conflicting_node\n c.execute(CONFLICTING_NODE_SQL, [parent_id, name.lower()])\nUnicodeEncodeError: \'utf-8\' codec can\'t encode characters in position 5-6: surrogates not allowed\n' Arguments: ()

1 file(s) failed.

I'm out of ideas for the moment.

rubstew commented 7 years ago

I upgrade with the lastest commit and I still have errors

When te character is in the path: File "/usr/local/bin/acd_cli", line 9, in <module> load_entry_point('acdcli==0.3.2', 'console_scripts', 'acd_cli')() File "/usr/local/bin/acd_cli.py", line 1680, in main ret = args.func(args) File "/usr/local/bin/acd_cli.py", line 885, in upload_action excl_re, args.exclude_path, jobs) File "/usr/local/bin/acd_cli.py", line 444, in create_upload_jobs rsf, exclude, exclude_paths, jobs) File "/usr/local/bin/acd_cli.py", line 502, in traverse_ul_dir overwr, force, dedup, rsf, exclude, exclude_paths, jobs) File "/usr/local/bin/acd_cli.py", line 444, in create_upload_jobs rsf, exclude, exclude_paths, jobs) File "/usr/local/bin/acd_cli.py", line 473, in traverse_ul_dir curr_node = cache.get_child(parent_id, short_nm) File "/usr/local/lib/python3.4/dist-packages/acdcli/cache/query.py", line 244, in get_child c.execute(CHILD_OF_SQL, [child_name, folder_id]) UnicodeEncodeError: 'utf-8' codec can't encode character '\udcc3' in position 38: surrogates not allowed 17-01-22 12:02:48.450 [ERROR] [acd_cli] - Please set your locale or use the "--utf" flag. When the character is in the file: File "/usr/local/bin/acd_cli.py", line 299, in wrapped ret_val = f(*args, **kwargs) File "/usr/local/bin/acd_cli.py", line 522, in upload_file conflicting_node = cache.get_conflicting_node(short_nm, parent_id) File "/usr/local/lib/python3.4/dist-packages/acdcli/cache/query.py", line 156, in get_conflicting_node c.execute(CONFLICTING_NODE_SQL, [parent_id, name.lower()]) UnicodeEncodeError: 'utf-8' codec can't encode character '\udcc3' in position 29: surrogates not allowed

Thanks for your time.

rubstew commented 7 years ago

I set the locale to spanish and now it is uploading files... EXPORT LC_ALL= es_ES.UTF-8