Comments (14)
This test case exhibits the problem on Mac:
PYTHONIOENCODING=ascii python -m b2 ls <bucketName>
from b2_command_line_tool.
Thanks for the bug report. I'll be working on sync this week, and will get this fixed.
from b2_command_line_tool.
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.
@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.
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.
Just to complement the information, my terminal LANG is set to en_GB.UTF-8
from b2_command_line_tool.
That's interesting. I wonder what your sys.stdin.encoding is.
from b2_command_line_tool.
@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.
$ 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.
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.
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.
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.
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.
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)
- Install from source documentation section should be updated to PDM
- Prevent writing b2 file information to stdout when using download-file HOT 2
- Feature request: use b2 cli without saving plaintext credentials in `.b2_account_info` HOT 9
- Official Docker Image ? HOT 3
- delete_file_version needs bypassGovernance option HOT 1
- Can't upload FIFOs with upload-file HOT 6
- UnicodeEncodeError: 'ascii' codec can't encode character '\u2022' in position 1325: ordinal not in range(128) HOT 1
- [Question] Explain how sync between buckets work; slow overall speed HOT 8
- b2sdk.exception.InvalidAuthToken: Invalid authorization token. Server said: (bad_auth_token) HOT 2
- Error when resuming upload HOT 2
- switch to stable pypy version after new pypy is released HOT 2
- b2 ls --json destroys output structure with informational message HOT 1
- `Using https://api.backblazeb2.com` output to stderr causing problems for automation that only expects errors and warnings on stderr
- pip install breaks with setuptools 69.0.0 HOT 3
- b2 should respect the spec's default fallback for `XDG_CONFIG_HOME` HOT 4
- Feature request: Support transparent compression HOT 1
- error: the following arguments are required: command HOT 5
- Issue with b2 sync :: KeyError: 'content-length' HOT 11
- Package `b2` for Alpine Linux HOT 5
- Linux.Xor.DDoS false-positive from chkrootkit due PyInstaller use
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from b2_command_line_tool.