GithubHelp home page GithubHelp logo

Comments (14)

bwbeach avatar bwbeach commented on June 20, 2024 1

This test case exhibits the problem on Mac:

PYTHONIOENCODING=ascii python -m b2 ls <bucketName>

from b2_command_line_tool.

bwbeach avatar bwbeach commented on June 20, 2024

Thanks for the bug report. I'll be working on sync this week, and will get this fixed.

from b2_command_line_tool.

bwbeach avatar bwbeach commented on June 20, 2024

Python uses sys.stdout.encoding to decide how to translate unicode to bytes when printing to stdout. My guess is that your encoding is set to 'ascii', which means that it won't be able to print unicode.

My environment has 'utf-8' as the default encoding for sys.stdout, and it works for me.

I'm not sure what the right thing to do is. When the encoding is unicode-capable, things should work. When it's not, what should the code do?

from b2_command_line_tool.

bwbeach avatar bwbeach commented on June 20, 2024

@jcalonso - I think that you could get around this by setting LANG to use an encoding that can print the characters in your file names. Here's a quick experiment I ran:

$ echo $LANG
en_US.UTF-8
$ python
Python 2.7.11 (default, Mar  7 2016, 13:29:38) 
>>> import sys ; sys.stdout.encoding
'UTF-8'
>>> print u'\u81ea'
自
>>> 
$ export LANG=en_US.ASCII
$ python
Python 2.7.11 (default, Mar  7 2016, 13:29:38) 
>>> import sys ; sys.stdout.encoding
'US-ASCII'
>>> print u'\u81ea'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\u81ea' in position 0: ordinal not in range(128)

Any suggestions for what the b2 command should do when it can't print the file names?

from b2_command_line_tool.

ppolewicz avatar ppolewicz commented on June 20, 2024

We should catch this and return an appropriate error message, like "your terminal cannot output Unicode in its current configuration. You can fix it by..."

from b2_command_line_tool.

jcalonso avatar jcalonso commented on June 20, 2024

Just to complement the information, my terminal LANG is set to en_GB.UTF-8

from b2_command_line_tool.

bwbeach avatar bwbeach commented on June 20, 2024

That's interesting. I wonder what your sys.stdin.encoding is.

from b2_command_line_tool.

ppolewicz avatar ppolewicz commented on June 20, 2024

@jcalonso please tell us what happens when you start python and type this in:

import sys
print sys.stdin.encoding

from b2_command_line_tool.

jcalonso avatar jcalonso commented on June 20, 2024
$ python
Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.stdin.encoding
UTF-8
>>>

from b2_command_line_tool.

bwbeach avatar bwbeach commented on June 20, 2024

When I test on Windows, I get this:

>>> import sys
>>> sys.stdout.encoding
'cp437'

Apparently this is normal on Windows.

from b2_command_line_tool.

seb2411 avatar seb2411 commented on June 20, 2024

I have the same problem it seem with the version 0.5.6.

b2 sync /backup b2://mybucket/path
Traceback (most recent call last):
  File "/usr/local/bin/b2", line 9, in <module>
    load_entry_point('b2==0.5.6', 'console_scripts', 'b2')()
  File "/usr/local/lib/python2.7/dist-packages/b2/console_tool.py", line 873, in main
    exit_status = ct.run_command(decoded_argv)
  File "/usr/local/lib/python2.7/dist-packages/b2/console_tool.py", line 806, in run_command
    self._print_stderr('ERROR: %s' % (str(e),))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2011' in position 25: ordinal not in range(128)

print sys.stdin.encoding:

Python 2.7.11+ (default, Apr 17 2016, 14:00:29) 
[GCC 5.3.1 20160413] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print sys.stdin.encoding
UTF-8

from b2_command_line_tool.

abeusher avatar abeusher commented on June 20, 2024

I experienced this and solved the problem by removing dashes/hyphens from my bucket names. Try doing this with a bucket name that is 100% alpha numeric.

from b2_command_line_tool.

RX14 avatar RX14 commented on June 20, 2024

I'm on backblaze-b2 version 0.6.2.

$ locale
LANG=en_GB.UTF-8
LC_CTYPE=en_GB.UTF-8
LC_NUMERIC=en_GB.UTF-8
LC_TIME=en_GB.UTF-8
LC_COLLATE=en_GB.UTF-8
LC_MONETARY=en_GB.UTF-8
LC_MESSAGES=en_GB.UTF-8
LC_PAPER=en_GB.UTF-8
LC_NAME=en_GB.UTF-8
LC_ADDRESS=en_GB.UTF-8
LC_TELEPHONE=en_GB.UTF-8
LC_MEASUREMENT=en_GB.UTF-8
LC_IDENTIFICATION=en_GB.UTF-8
LC_ALL=
$ backblaze-b2 sync --delete --replaceNewer /foo b2://bucket-with-dashes/
Traceback (most recent call last):
  File "/usr/bin/backblaze-b2", line 11, in <module>
    load_entry_point('b2==0.6.2', 'console_scripts', 'b2')()
  File "/usr/lib/python2.7/site-packages/b2/console_tool.py", line 879, in main
    exit_status = ct.run_command(decoded_argv)
  File "/usr/lib/python2.7/site-packages/b2/console_tool.py", line 811, in run_command
    self._print_stderr('ERROR: %s' % (str(e),))
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2011' in position 23: ordinal not in range(128)

Removing the hyphens fixes the error, but this isn't an acceptable workaround, please reopen.

from b2_command_line_tool.

ppolewicz avatar ppolewicz commented on June 20, 2024

Ok this is actually #266: user copied the bucket name from web interface, where it was displayed in a malformed manner. No actual hypens were used - instead \u2011 (NON-BREAKING HYPHEN) was passed to the CLI. We've fixed the exceptions and we requested the cloud team to stop using NON-BREAKING HYPHEN in their UI.

from b2_command_line_tool.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.