To start, take a look at my Python 3 transition document
<https://github.com/weewx/weewx/wiki/Python-3-strategy>.

If you do not understand the difference between byte strings and unicode,
don't do anything before reading this old, but still very useful, article
<https://www.joelonsoftware.com/2003/10/08/the-absolute-minimum-every-software-developer-absolutely-positively-must-know-about-unicode-and-character-sets-no-excuses/>
.

-tk

On Mon, Mar 25, 2019 at 6:23 PM Pat <[email protected]> wrote:

> I missed this one, but just caught it. Thanks for the tips.
>
> #1. Yes, it's a hack. So much so that in the comment above it I gave
> credit to the original source. :) For Python3, do you have an example I
> could look at? I'm not familiar with reading the byte strings as you've
> mentioned. TBH, locale is a newer topic for me to work with.
> #2. Ok, thanks I'll update that
>
>
>
> On Saturday, March 23, 2019 at 9:51:32 PM UTC-4, Thomas Keffer wrote:
>>
>> I suspect one of your "LC" settings is missing. Run the command "locale"
>> (without the -a flag). You should see something like:
>> LANG=en_US.UTF-8
>> LANGUAGE=
>> LC_CTYPE="en_US.UTF-8"
>> LC_NUMERIC="en_US.UTF-8"
>> LC_TIME="en_US.UTF-8"
>> LC_COLLATE="en_US.UTF-8"
>> LC_MONETARY="en_US.UTF-8"
>> LC_MESSAGES="en_US.UTF-8"
>> LC_PAPER="en_US.UTF-8"
>> LC_NAME="en_US.UTF-8"
>> LC_ADDRESS="en_US.UTF-8"
>> LC_TELEPHONE="en_US.UTF-8"
>> LC_MEASUREMENT="en_US.UTF-8"
>> LC_IDENTIFICATION="en_US.UTF-8"
>> LC_ALL=
>>
>> Having said this, Pat, if you're listening, two issues:
>>
>>    1. The Belchertown skins sets a default encoding by reloading sys,
>>    then making use of the otherwise hidden function
>>    sys.setdefaultencoding(). This is a hack, and won't work under Python
>>    3. Instead, you need to read byte strings in and explicitly decode them
>>    (instead of relying on a default encoding).
>>    2. The line locale.setlocale(locale.LC_ALL, "") should not be
>>    necessary. This is already done in user/extensions.py.
>>
>> -tk
>>
>>
>>
>>
>>
>> On Sat, Mar 23, 2019 at 11:00 AM G400 <[email protected]> wrote:
>>
>>> reportengine: Caught unrecoverable exception in generator
>>> 'weewx.cheetahgenerator.CheetahGenerator'
>>> Mar 23 18:54:54 aad-raspberry-01 weewx[10423]:         ****  unsupported
>>> locale setting
>>> Mar 23 18:54:54 aad-raspberry-01 weewx[10423]:         ****  Traceback
>>> (most recent call last):
>>> Mar 23 18:54:54 aad-raspberry-01 weewx[10423]:         ****    File
>>> "/home/weewx/bin/weewx/reportengine.py", line 204, in run
>>> Mar 23 18:54:54 aad-raspberry-01 weewx[10423]:         ****
>>> obj.start()
>>> Mar 23 18:54:54 aad-raspberry-01 weewx[10423]:         ****    File
>>> "/home/weewx/bin/weewx/reportengine.py", line 300, in start
>>> Mar 23 18:54:54 aad-raspberry-01 weewx[10423]:         ****
>>> self.run()
>>> Mar 23 18:54:54 aad-raspberry-01 weewx[10423]:         ****    File
>>> "/home/weewx/bin/weewx/cheetahgenerator.py", line 157, in run
>>> Mar 23 18:54:54 aad-raspberry-01 weewx[10423]:         ****
>>> self.initExtensions(gen_dict[section_name])
>>> Mar 23 18:54:54 aad-raspberry-01 weewx[10423]:         ****    File
>>> "/home/weewx/bin/weewx/cheetahgenerator.py", line 199, in initExtensions
>>> Mar 23 18:54:54 aad-raspberry-01 weewx[10423]:         ****      class_
>>> = weeutil.weeutil._get_object(x)
>>> Mar 23 18:54:54 aad-raspberry-01 weewx[10423]:         ****    File
>>> "/home/weewx/bin/weeutil/weeutil.py", line 1130, in _get_object
>>> Mar 23 18:54:54 aad-raspberry-01 weewx[10423]:         ****      mod =
>>> __import__(module)
>>> Mar 23 18:54:54 aad-raspberry-01 weewx[10423]:         ****    File
>>> "/home/weewx/bin/user/belchertown.py", line 26, in <module>
>>> Mar 23 18:54:54 aad-raspberry-01 weewx[10423]:         ****
>>> locale.setlocale(locale.LC_ALL, "")
>>> Mar 23 18:54:54 aad-raspberry-01 weewx[10423]:         ****    File
>>> "/usr/lib/python2.7/locale.py", line 581, in setlocale
>>> Mar 23 18:54:54 aad-raspberry-01 weewx[10423]:         ****      return
>>> _setlocale(category, locale)
>>> Mar 23 18:54:54 aad-raspberry-01 weewx[10423]:         ****  Error:
>>> unsupported locale setting
>>> Mar 23 18:54:54 aad-raspberry-01 weewx[10423]:         ****  Generator
>>> terminated
>>>
>>> My locale settings are as follows:
>>> locale -a
>>> C
>>> C.UTF-8
>>> en_US.utf8
>>> POSIX
>>>
>>> Content of /etc/default/locale
>>> #  File generated by update-locale
>>> LANG=en_US.UTF-8
>>>
>>> What else do I need to check to fix this error?
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "weewx-user" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "weewx-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to