janeczku / docker-dropbox

:whale: Dropbox in a Docker image. This works.
MIT License
150 stars 129 forks source link

CLI crashing on Unicode characters #30

Open ghost opened 5 years ago

ghost commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

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 commented 5 years ago

In my experience it just comes and goes, I guess just based on the filenames that the UI tries to display. I couldn't fix it but it doesn't affect the syncing process, it's just inconvenient. My solution was to leave Dropbox and move to my own Nextcloud server... :)

On Mon, Aug 26, 2019 at 10:03 PM Jorixine notifications@github.com wrote:

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!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/janeczku/docker-dropbox/issues/30?email_source=notifications&email_token=AAJHTAF6YWF7MXSM5UWU3ZTQGPWDJA5CNFSM4G47AD42YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD5EUUYA#issuecomment-524896864, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJHTABDCMA5UVONOQFYVT3QGPWDJANCNFSM4G47AD4Q .

mundo1979 commented 4 years ago

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:

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