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

CLI crashing on Unicode characters #30

Open
ghost opened this issue Mar 11, 2019 · 5 comments
Open

CLI crashing on Unicode characters #30

ghost opened this issue Mar 11, 2019 · 5 comments

Comments

@ghost
Copy link

ghost commented Mar 11, 2019

Well I guess this one's on Dropbox side and not this image, but you may shed some light:
The CLI often crashes with an error such as this:

root@nfs-server-5f96bd9d5c-xn7n8:/dbox/Dropbox# dropbox status
Traceback (most recent call last):
  File "/usr/bin/dropbox-cli", line 1535, in <module>
    ret = main(sys.argv)
  File "/usr/bin/dropbox-cli", line 1524, in main
    result = commands[argv[i]](argv[i+1:])
  File "/usr/bin/dropbox-cli", line 719, in newmeth
    return meth(*n, **kw)
  File "/usr/bin/dropbox-cli", line 1187, in status
    console_print(line)
  File "/usr/bin/dropbox-cli", line 127, in console_print
    f.write(st.encode(enc))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2022' in position 20: ordinal not in range(128)

It doesn't seem to be bothering the daemon process and other than not being able to run some commands, the sync is working fine, but it makes working with it a but more difficult.
Obviously I suspect this happens when encountering files with non-ASCII filenames.

@Wildcarde
Copy link

Wildcarde commented Apr 8, 2019

I'm seeing the same behavior, it seems to be some sort of change in the dropbox_cli package + python's behavior when writing to a file or terminal and failing to translate the encoding based on issue tickets posted elsewhere. Running the command dropbox filestatus at the top level of your tree at least gives you a course view of what is and isn't synced in the mean time.

@bandtank
Copy link

FWIW, this is one way to apply a quick fix in /usr/bin/dropbox-cli:

def console_print(st=u"", f=sys.stdout, linebreak=True):
    global enc
    assert type(st) is unicode
    st = st.replace(u"\u2022", u"-") <-------
    f.write(st.encode(enc))
    if linebreak: f.write(os.linesep)

@Jorixine
Copy link

Hello!
Just installed this image and I am getting the same issues when running dropbox-cli... Was anyone able to fix this ?

There is no command running fine. Syncing anyway works as expected.

Thanks!

@ghost
Copy link
Author

ghost commented Aug 27, 2019 via email

@mundo1979
Copy link

The issue is caused because the Debian VM does not have a locale set so Python does not know what char encoding to use. Dropbox just updated the dropbox-cli file so the mod in this thread will no longer work.

A more permanent fix:

  • Add "locales locales-all" to the apt-get install in Dockerfile
  • Add an additional line "&& sed --in-place '/en_US.UTF-8/s/^# //' /etc/locale.gen " below to uncomment the correct locale
  • Add three more lines to Dockerfile:
    ENV LANG en_US.UTF-8
    ENV LANGUAGE en_US:en
    ENV LC_ALL en_US.UTF-8

Now Python has no character encoding issues as it will use UTF-8

tkunstek added a commit to tkunstek/docker-dropbox that referenced this issue Mar 17, 2020
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

4 participants