[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Fab-user] remote host output encoding
From: |
Mike Miller |
Subject: |
Re: [Fab-user] remote host output encoding |
Date: |
Tue, 01 Oct 2013 20:30:22 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.0 |
Hi,
I've been searching for information on character encoding and fabric but coming
up empty. I've got a command printing an occasional Unicode char and so when
using the result object I get a UnicodeDecodeError:
output = run('unicode_printer')
'returned: ' + output # kaboom
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0:
ordinal not in range(128)
What should I do about this? I could hard-code it to decode with utf8, but
can't guarantee it will be utf8. I can imagine running a command earlier to get
the encoding and then decoding it. For example:
encoding = run("python2 -c 'import locale; " +
"print locale.getdefaultlocale()[1]'")
output = run('unicode_printer')
'returned: ' + output.decode(encoding)
Wondering if there was a parameter or easier way that I'm missing.
Thanks,
- Re: [Fab-user] remote host output encoding,
Mike Miller <=