Attn Tom: Simple Case to Repro the weeutil.config.deep_copy issue

35 views
Skip to first unread message

John Kline

unread,
Jul 14, 2020, 12:15:56 PM7/14/20
to weewx-development
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

John Kline

unread,
Jul 14, 2020, 12:23:45 PM7/14/20
to weewx-development
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 <jo...@johnkline.com> wrote:
>
> Hi Tom,

Tom Keffer

unread,
Jul 14, 2020, 8:27:53 PM7/14/20
to John Kline, weewx-development
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. 

--
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 weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/CA049183-2575-4062-AC9C-A8C96C81A1D5%40johnkline.com.

John Kline

unread,
Jul 14, 2020, 8:31:05 PM7/14/20
to Tom Keffer, weewx-development
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 <tke...@gmail.com> wrote:



Tom Keffer

unread,
Jul 14, 2020, 8:40:50 PM7/14/20
to John Kline, weewx-development
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!

John Kline

unread,
Jul 14, 2020, 8:46:36 PM7/14/20
to Tom Keffer, weewx-development
You had me worried there!

On Jul 14, 2020, at 5:40 PM, Tom Keffer <tke...@gmail.com> wrote:



John Kline

unread,
Jul 14, 2020, 9:04:33 PM7/14/20
to Tom Keffer, weewx-development
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.
config_obj_1594742128.134154

Tom Keffer

unread,
Jul 15, 2020, 11:30:41 AM7/15/20
to weewx-development
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


On Jul 14, 2020, at 5:46 PM, John Kline <jo...@johnkline.com> wrote:


You had me worried there!

On Jul 14, 2020, at 5:40 PM, Tom Keffer <tke...@gmail.com> 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 <jo...@johnkline.com> 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 <tke...@gmail.com> 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 <jo...@johnkline.com> 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 <jo...@johnkline.com> 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
>

John Kline

unread,
Jul 15, 2020, 12:01:50 PM7/15/20
to Tom Keffer, weewx-development
Works like a charm.

Thank you!

On Jul 15, 2020, at 8:30 AM, Tom Keffer <tke...@gmail.com> wrote:


Reply all
Reply to author
Forward
0 new messages