Try it now.

I ended rewriting deep_copy() by using recursion. The trick is to bypass
the version of __getitem__ supplied by ConfigObj in order to avoid
interpolation.

Commit b6905e5
<https://github.com/weewx/weewx/commit/b6905e5ac76f2cc8128172b75854a69c0d6a9dfd>

On Tue, Jul 14, 2020 at 6:04 PM John Kline <[email protected]> wrote:

> BTW, to save you from adding in my change to write the confobj.write()
> output to a file, the attached file is what output.
>
> Foo/Bar/Baz is at the bottom.
>
> Foo and Bar both have two too many brackets.
>
> [[[Foo]]]
>             [[[[Bar]]]]
>                 baz = foobarabaz
>
>
>
> On Jul 14, 2020, at 5:46 PM, John Kline <[email protected]> wrote:
>
> 
> You had me worried there!
>
> On Jul 14, 2020, at 5:40 PM, Tom Keffer <[email protected]> wrote:
>
> 
> No, I did not enable it. Once I did, then I got the error message. Nice to
> know it's reproducible on a stock WeeWX install!
>
> On Tue, Jul 14, 2020 at 5:31 PM John Kline <[email protected]> wrote:
>
>> I’m assuming you enabled StandardReport.  If so, that is remarkable; but
>> I know what to do on my end to make the skins work.  Thanks for trying it.
>>
>> On Jul 14, 2020, at 5:27 PM, Tom Keffer <[email protected]> wrote:
>>
>> 
>> I added the section [[[Foo]]] to [[StandardReport]] as you directed, and
>> it worked fine on my system, using configobj v5.0.6 and Python v3.5.9,
>> v3.7.3, and v3.8.2.
>>
>> On Tue, Jul 14, 2020 at 9:23 AM John Kline <[email protected]> wrote:
>>
>>> Oh, I forgot to add, if you add the following to
>>> skins/Standard/skins.conf, the problem goes away:
>>> [Foo]
>>>     [[Bar]]
>>>         x = 1
>>>
>>> It appears the introduction of new sections is a problem when using
>>> configobj.write
>>>
>>> Cheers,
>>> John
>>>
>>> > On Jul 14, 2020, at 9:15 AM, John Kline <[email protected]> wrote:
>>> >
>>> > Hi Tom,
>>> >
>>> > I had a chance to dig deeper into the issues I am seeing at head,
>>> specifically the weeutil.config.deep_copy function.
>>> >
>>> > I would appreciate it if you could could try to reproduce the problem
>>> with this StandardReport.  Just run wee_reports (there’s no need to restart
>>> WeeWX):
>>> >
>>> >    [[StandardReport]]
>>> >        # This is the old "Standard" skin. By default, it is not
>>> enabled.
>>> >        skin = Standard
>>> >        enable = true
>>> >        [[[Foo]]]
>>> >           [[[[Bar]]]]
>>> >                baz = foobarabaz
>>> >
>>> > If it fails for you, and iff this is legal to have in the weewx.conf
>>> file, you can instrument the function to see why it happens by adding this
>>> to the code below to the beginning.  You see it fail when running
>>> wee_reports and know which tmp file to look in.  Again, just run
>>> wee_reports.
>>> >
>>> >    import time
>>>
>>>
>>> >    fname = '/tmp/config_obj_%f' % time.time()
>>>                                                      print('writing %s' %
>>> fname)
>>>                                      fd = open(fname, 'wb')
>>>
>>>                      old_dict.write(fd)
>>>
>>>            fd.close()
>>>
>>>        print('done writing %s' % fname)
>>>                                                              print('reading
>>> %s' % fname)
>>>                                          fd = open(fname, 'rb')
>>>
>>>                            new_dict = configobj.ConfigObj(fd,
>>>
>>>                                   encoding='utf8',
>>>
>>>                       default_encoding=old_dict.default_encoding,
>>>
>>> interpolation=old_dict.interpolation)
>>>                      fd.close()
>>>
>>>                  print('done reading %s' % fname)
>>>                                                                      return
>>> new_dict
>>> >
>>> > If this isn’t legal, I’ll need to change [my copy] of forecast as I
>>> believe this is a typical report entry for reports that include a forecast:
>>> >
>>> >        [[[Extras]]]
>>> >            [[[[forecast_iconic_settings]]]]
>>> >                source = NWS
>>> >                orientation = horizontal
>>> >                num_days = 7
>>> >                bar_size = 150
>>> >                show_date = 0
>>> >                show_pop = 0
>>> >                show_precip = 1
>>> >                show_obvis = 1
>>> >
>>> > The above causes the same issue.
>>> >
>>> > If you add the instrumentation code and look at the temp file, you’ll
>>> see that the sections have the wrong number of brackets.
>>> >
>>> > Cheers,
>>> > John
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "weewx-development" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/weewx-development/CA049183-2575-4062-AC9C-A8C96C81A1D5%40johnkline.com
>>> .
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-development/CAPq0zEC89qvjGNDasrz%2Btrak8b3AFhDahOzckbc6%2B%2B0e9B9Zbg%40mail.gmail.com.

Reply via email to