Re: [mh] Weather and Weather_Chance_Of_Rain

Stephen Switzer <[email protected]>
Newsgroups gmane.comp.misc.misterhouse.user
Message-ID <CALSXUc3fFFEq5mx_VP2m6e+S8goQuzJLRhzu0f0F7MyG4M1prA@mail.gmail.com>
Brian,
  Given that this is a known limitation of "use lib" and that I wasn't
missing something like I thought I was, I guess I'm pretty much at the end.
As I stated below, I tried this:

eval "push @INC, '$Pgm_Path/../lib/fallback'";

But I missed the \ at almost 1 AM. Honestly,  I probably would have missed
it at 1 PM too! LOL

I'll try the \ and see what happens.

Much appreciated!

Steve


On Wed, Dec 9, 2020, 7:01 PM Brian M <[email protected]>
wrote:

> All,
>
> The only way I can see to place a directory at the *end* of @INC, is to
> push it there manually.  There doesn't seem to be any mechanism to do that
> via "use lib" or similar.  Pushing it isn't hard -- it just seems kludgy
> and loses some of the additional functionality of "use lib" (compiled
> modules, architecture-specific versions, etc.). I'd love to hear of a
> better way if anybody has one.
>
> Stephen,
>
> Meanwhile, would you please test the following change to get_weather for
> me?  It works on my system, but I'd like to have you try it before I start
> issuing pull requests:
>
> In line 86, please replace:
>
>     eval "use lib '$Pgm_Path/../lib', '$Pgm_Path/../lib/site',
> '$Pgm_Path/../lib/fallback'";
>
> with:
>      eval "use lib '$Pgm_Path/../lib', '$Pgm_Path/../lib/site';";
>      eval "push \@INC, '$Pgm_Path/../lib/fallback';";
>
> This should solve the issue you discovered. If your interested, you can
> check %INC afterwards, and I bet you don't find very many routines loaded
> from fallback anymore. I didn't find any on my system, but I may have more
> Perl modules installed than you do.
>
> By the way ... you didn't discover a problem. You discovered an entire
> class of problems. The patch I offered up last Spring that was incorporated
> into MH master on June 5 was good as far as it went, but it was only
> partially successful in achieving its objective. Your observations and
> diagnosis should let me take it the rest of the way. Good job, and thank
> you.
>
>                            -Brian M.
>
> On 12/9/20 9:27 AM, Brian M wrote:
>
> There's the problem!  Fallback is listed third, when it's whole purpose is
> to *always* be listed last.
>
> You would have had the same problem if you'd tried this before we
> implemented the fallback library.  All fallback did was relocate a bunch of
> modules out of ./../lib and into fallback, so they still would have
> preempted your system libraries even in the old location.
>
> I'll look into why fallback doesn't appear last like it should. In the
> mean time, if you want to fiddle @INC so that fallback appears last, I
> think you'll find the code works properly.
>
> I wouldn't commit any changes to remove fallback, as that's really
> band-aiding the problem rather than fixing it.  It might work for you but
> not other people, because you are filling some module need through what's
> installed in your system libraries that they don't have but could get
> successfully from fallback if it were listed. Instead, I recommend you hold
> tight for a bit while I figure out what is mucking up @INC and putting
> fallback in the wrong position. Getting fallback to land naturally at the
> end of @INC is the right solution, and that doesn't appear get_weather.pl's
> fault.
>
>                 -Brian M
>
> On 12/9/20 7:28 AM, Stephen Switzer wrote:
>
> Revisiting this again, I reverted all the changes that I made in my
> internet_weather_fix commit and ONLY removed the fallback directory from
> get_weather... all good. So, everything else I did was unnecessary and
> probably created a regression somewhere. I fixed my running code and await
> the advice from someone more experienced.
>
> Steve
>
> On Wed, Dec 9, 2020 at 12:59 AM Stephen Switzer <[email protected]>
> wrote:
>
>> I very much appreciate your reply. I have a moment to dig in to this
>> before bed, so I change print Dumper(%INC); to print Dumper(@INC); and ran
>> it:
>>
>> @INC = (
>>          './../lib',
>>          './../lib/site',
>>          './../lib/fallback',
>>          '/etc/perl',
>>          '/usr/local/lib/x86_64-linux-gnu/perl/5.30.0',
>>          '/usr/local/share/perl/5.30.0',
>>          '/usr/lib/x86_64-linux-gnu/perl5/5.30',
>>          '/usr/share/perl5',
>>          '/usr/lib/x86_64-linux-gnu/perl/5.30',
>>          '/usr/share/perl/5.30',
>>          '/usr/local/lib/site_perl',
>>          '/usr/lib/x86_64-linux-gnu/perl-base'
>>        );
>> Interestingly, when I placed the Dumper line at the beginning of the
>> file, it didn't change. When I place it inside the BEGIN section:
>> BEGIN {
>>     print Dumper(@INC);
>>     eval "use lib '$Pgm_Path/../lib', '$Pgm_Path/../lib/site',
>> '$Pgm_Path/../lib/fallback'";
>> }
>>
>> Then, I saw the library directories listed without any MisterHouse
>> directories, then the modified list after it, even though it was physically
>> after the other in the file:
>>
>> @INC = (
>>          '/etc/perl',
>>          '/usr/local/lib/x86_64-linux-gnu/perl/5.30.0',
>>          '/usr/local/share/perl/5.30.0',
>>          '/usr/lib/x86_64-linux-gnu/perl5/5.30',
>>          '/usr/share/perl5',
>>          '/usr/lib/x86_64-linux-gnu/perl/5.30',
>>          '/usr/share/perl/5.30',
>>          '/usr/local/lib/site_perl',
>>          '/usr/lib/x86_64-linux-gnu/perl-base'
>>        );
>> @INC = (
>>          './../lib',
>>          './../lib/site',
>>          './../lib/fallback',
>>          '/etc/perl',
>>          '/usr/local/lib/x86_64-linux-gnu/perl/5.30.0',
>>          '/usr/local/share/perl/5.30.0',
>>          '/usr/lib/x86_64-linux-gnu/perl5/5.30',
>>          '/usr/share/perl5',
>>          '/usr/lib/x86_64-linux-gnu/perl/5.30',
>>          '/usr/share/perl/5.30',
>>          '/usr/local/lib/site_perl',
>>          '/usr/lib/x86_64-linux-gnu/perl-base'
>>        );
>>
>> However, I can accept that since "BEGIN" implies that execution will
>> BEGIN there. :)
>>
>> This makes whole problem is starting to make sense, since this reference
>> says that the directories provided in "use lib" are *prepended* to @INC:
>> https://docstore.mik.ua/orelly/perl2/prog/ch31_13.htm
>>
>> I can't find any documentation on how to append directories to @INC, but
>> I tried this:
>>
>> BEGIN {
>>     print Dumper(@INC);
>>     #eval "use lib '$Pgm_Path/../lib', '$Pgm_Path/../lib/site',
>> '$Pgm_Path/../lib/fallback'";
>>     eval "push @INC, '$Pgm_Path/../lib'";
>>     eval "push @INC, '$Pgm_Path/../lib/site'";
>>     eval "push @INC, '$Pgm_Path/../lib/fallback'";
>>     print Dumper(@INC);
>> }
>>
>> ...which didn't add to the array at all, nor did it give any error... so
>> I tried this:
>>
>> BEGIN {
>>     print Dumper(@INC);
>>     #eval "use lib '$Pgm_Path/../lib', '$Pgm_Path/../lib/site',
>> '$Pgm_Path/../lib/fallback'";
>>     push @INC, "$Pgm_Path/../lib";
>>     push @INC, "$Pgm_Path/../lib/site";
>>     push @INC, "$Pgm_Path/../lib/fallback";
>>     print Dumper(@INC);
>> }
>>
>> THAT WORKED... but according to the comment "perl2exe" won't be happy
>> with this approach.
>>
>> I think this explains it, but I have no further sense of direction on
>> this matter. It appeared that adding fallback to this list was the issue,
>> but then I remembered that the modules were moved at the same time, so the
>> old module would have been found in site, and @INC was prepended at that
>> time, too.
>>
>> I'm not sure what the right approach should be here.
>>
>> Steve
>>
>>
>>
>> On Mon, Dec 7, 2020 at 5:21 PM Brian M <[email protected]>
>> wrote:
>>
>>> Good work.  You're right, that doesn't make sense, but I think we'll
>>> figure it out.
>>>
>>> Instead of dumping %INC, would you please dump the contents of @INC
>>> while get_weather is in it's broken configuration? @INC is the list of
>>> library directories Perl is using to find modules, in descending order of
>>> preference. I'd like to see what it looks like from inside get_weather. I
>>> want to know what's actually getting used, rather than what we're
>>> configuring, in case something is monkeying with it along the way. Fallback
>>> should be at the very end, since we only want to use fallback if all other
>>> sources have been exhausted. If it's not last, we need to find out why and
>>> fix that.
>>>
>>> Also, did  you "See note in lib/mh_perl2exe.pl for lib -> my_lib
>>> explaination" as mentioned in the get_weather comments.  I haven't, and
>>> given what you're experiencing, maybe my_lib is the monkey fiddling @INC.
>>>
>>> And no, you're not out of your league. You're just diagnosing an issue
>>> in a big, complex project that's been fiddled with by many people over
>>> time. I've been dabbling with MH for over 15 years, and I still find it
>>> arcane. Amazingly flexible and effective, but arcane. No fault to HPlato
>>> and all the other big players in the MH world, they've done great stuff. I
>>> value their contributions and dedication, and they've been great helping me
>>> figure stuff out. There's just a lot going on in MH, and that makes it
>>> complex.
>>>
>>>            -Brian M.
>>>
>>> On 12/7/20 1:43 PM, Stephen Switzer wrote:
>>>
>>> I'm starting to feel like a perl novice here. I'm not familiar with %INC
>>> and diagnosing this is confusing... but there's one thing here that's
>>> REALLY confusing me. I deleted URI, HTTP, LWP, etc, etc until there were NO
>>> fallback entries in %INC and it still didn't work. So, I removed the
>>> fallback directory from the list and it worked????
>>>
>>> Below is the entire list of diagnostic steps I performed:
>>>
>>> This is my baseline %INC before doing anything:
>>> %INC = (
>>>          'Exporter/Heavy.pm' => '/usr/share/perl/5.30/Exporter/Heavy.pm',
>>>          'lib.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.30/lib.pm',
>>>          'Tie/IxHash.pm' => '../lib/fallback/Tie/IxHash.pm',
>>>          'Tie/Hash.pm' => '../lib/fallback/Tie/Hash.pm',
>>>          'HTTP/Response.pm' => '../lib/fallback/HTTP/Response.pm',
>>>          'LWP/Simple.pm' => '../lib/fallback/LWP/Simple.pm',
>>>          'Text/Balanced.pm' => '/usr/share/perl/5.30/Text/Balanced.pm',
>>>          'IO.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.30/IO.pm',
>>>          'Fcntl.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.30/Fcntl.pm',
>>>          'URI/Escape.pm' => '../lib/fallback/URI/Escape.pm',
>>>          'strict.pm' => '/usr/share/perl/5.30/strict.pm',
>>>          'Text/Tabs.pm' => '/usr/share/perl/5.30/Text/Tabs.pm',
>>>          'warnings/register.pm' => '/usr/share/perl/5.30/warnings/
>>> register.pm',
>>>          'Data/Dumper.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/Data/Dumper.pm',
>>>          'Exporter.pm' => '/usr/share/perl/5.30/Exporter.pm',
>>>          'parent.pm' => '/usr/share/perl/5.30/parent.pm',
>>>          'constant.pm' => '/usr/share/perl/5.30/constant.pm',
>>>          'URI.pm' => '../lib/fallback/URI.pm',
>>>          'vars.pm' => '/usr/share/perl/5.30/vars.pm',
>>>          'Storable.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/Storable.pm',
>>>          'HTTP/Headers.pm' => '../lib/fallback/HTTP/Headers.pm',
>>>          'Filter/Util/Call.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/Filter/Util/Call.pm',
>>>          'bytes.pm' => '/usr/share/perl/5.30/bytes.pm',
>>>          'Config.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.30/Config.pm',
>>>          're.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.30/re.pm',
>>>          'integer.pm' => '/usr/share/perl/5.30/integer.pm',
>>>          'Geo/WeatherNOAA.pm' => '../lib/site/Geo/WeatherNOAA.pm',
>>>          'LWP/UserAgent.pm' => '../lib/fallback/LWP/UserAgent.pm',
>>>          'LWP/Debug.pm' => '../lib/fallback/LWP/Debug.pm',
>>>          'Carp.pm' => '/usr/share/perl/5.30/Carp.pm',
>>>          'Getopt/Long.pm' => '/usr/share/perl/5.30/Getopt/Long.pm',
>>>          'Data/Dumper/Simple.pm' =>
>>> '/usr/share/perl5/Data/Dumper/Simple.pm',
>>>          'LWP/MemberMixin.pm' => '../lib/fallback/LWP/MemberMixin.pm',
>>>          'overload.pm' => '/usr/share/perl/5.30/overload.pm',
>>>          'HTTP/Request.pm' => '../lib/fallback/HTTP/Request.pm',
>>>          'HTTP/Message.pm' => '../lib/fallback/HTTP/Message.pm',
>>>          'HTTP/Status.pm' => '../lib/fallback/HTTP/Status.pm',
>>>          'LWP/Protocol.pm' => '../lib/fallback/LWP/Protocol.pm',
>>>          'overloading.pm' => '/usr/share/perl/5.30/overloading.pm',
>>>          'Symbol.pm' => '/usr/share/perl/5.30/Symbol.pm',
>>>          'IO/Handle.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/IO/Handle.pm',
>>>          'XSLoader.pm' => '/usr/share/perl/5.30/XSLoader.pm',
>>>          'SelectSaver.pm' => '/usr/share/perl/5.30/SelectSaver.pm',
>>>          'Filter/Simple.pm' => '/usr/share/perl/5.30/Filter/Simple.pm',
>>>          'Time/Local.pm' => '/usr/share/perl/5.30/Time/Local.pm',
>>>          'warnings.pm' => '/usr/share/perl/5.30/warnings.pm',
>>>          'LWP.pm' => '../lib/fallback/LWP.pm',
>>>          'handy_utilities.pl' => '../lib/handy_utilities.pl',
>>>          'HTTP/Date.pm' => '../lib/fallback/HTTP/Date.pm',
>>>          'SelfLoader.pm' => '/usr/share/perl/5.30/SelfLoader.pm',
>>>          'Text/Wrap.pm' => '/usr/share/perl/5.30/Text/Wrap.pm'
>>>        );
>>>
>>> This is what I had after removing Tie, HTTP, URL & LWP from fallback
>>> (actually deleting the directories):
>>> %INC = (
>>>          'Fcntl.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.30/Fcntl.pm',
>>>          'LWP.pm' => '/usr/share/perl5/LWP.pm',
>>>          'URI.pm' => '/usr/share/perl5/URI.pm',
>>>          'Data/Dumper/Simple.pm' =>
>>> '/usr/share/perl5/Data/Dumper/Simple.pm',
>>>          'LWP/Simple.pm' => '/usr/share/perl5/LWP/Simple.pm',
>>>          'LWP/MemberMixin.pm' => '/usr/share/perl5/LWP/MemberMixin.pm',
>>>          'HTTP/Config.pm' => '/usr/share/perl5/HTTP/Config.pm',
>>>          'Tie/IxHash.pm' => '/usr/share/perl5/Tie/IxHash.pm',
>>>          'HTTP/Headers.pm' => '/usr/share/perl5/HTTP/Headers.pm',
>>>          'lib.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.30/lib.pm',
>>>          'Encode/Locale.pm' => '/usr/share/perl5/Encode/Locale.pm',
>>>          'Encode.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.30/Encode.pm',
>>>          'Encode/Encoding.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/Encode/Encoding.pm',
>>>          'HTTP/Date.pm' => '/usr/share/perl5/HTTP/Date.pm',
>>>          'Sub/Util.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/Sub/Util.pm',
>>>          'Try/Tiny.pm' => '/usr/share/perl5/Try/Tiny.pm',
>>>          'URI/Escape.pm' => '/usr/share/perl5/URI/Escape.pm',
>>>          'HTTP/Response.pm' => '/usr/share/perl5/HTTP/Response.pm',
>>>          'Symbol.pm' => '/usr/share/perl/5.30/Symbol.pm',
>>>          'LWP/UserAgent.pm' => '/usr/share/perl5/LWP/UserAgent.pm',
>>>          'Filter/Simple.pm' => '/usr/share/perl/5.30/Filter/Simple.pm',
>>>          'Encode/Config.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/Encode/Config.pm',
>>>          'integer.pm' => '/usr/share/perl/5.30/integer.pm',
>>>          'strict.pm' => '/usr/share/perl/5.30/strict.pm',
>>>          'Carp.pm' => '/usr/share/perl/5.30/Carp.pm',
>>>          'warnings/register.pm' => '/usr/share/perl/5.30/warnings/
>>> register.pm',
>>>          'Scalar/Util.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/Scalar/Util.pm',
>>>          'vars.pm' => '/usr/share/perl/5.30/vars.pm',
>>>          'parent.pm' => '/usr/share/perl/5.30/parent.pm',
>>>          'IO.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.30/IO.pm',
>>>          'Exporter.pm' => '/usr/share/perl/5.30/Exporter.pm',
>>>          'I18N/Langinfo.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/I18N/Langinfo.pm',
>>>          'XSLoader.pm' => '/usr/share/perl/5.30/XSLoader.pm',
>>>          'Text/Wrap.pm' => '/usr/share/perl/5.30/Text/Wrap.pm',
>>>          're.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.30/re.pm',
>>>          'Exporter/Heavy.pm' => '/usr/share/perl/5.30/Exporter/Heavy.pm',
>>>          'SelectSaver.pm' => '/usr/share/perl/5.30/SelectSaver.pm',
>>>          'Encode/MIME/Name.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/Encode/MIME/Name.pm',
>>>          'List/Util.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/List/Util.pm',
>>>          'Config.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.30/Config.pm',
>>>          'bytes.pm' => '/usr/share/perl/5.30/bytes.pm',
>>>          'Encode/Alias.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/Encode/Alias.pm',
>>>          'handy_utilities.pl' => '../lib/handy_utilities.pl',
>>>          'Getopt/Long.pm' => '/usr/share/perl/5.30/Getopt/Long.pm',
>>>          'HTTP/Status.pm' => '/usr/share/perl5/HTTP/Status.pm',
>>>          'SelfLoader.pm' => '/usr/share/perl/5.30/SelfLoader.pm',
>>>          'HTTP/Message.pm' => '/usr/share/perl5/HTTP/Message.pm',
>>>          'overload.pm' => '/usr/share/perl/5.30/overload.pm',
>>>          'IO/Handle.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/IO/Handle.pm',
>>>          'Tie/Hash.pm' => '/usr/share/perl/5.30/Tie/Hash.pm',
>>>          'Storable.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/Storable.pm',
>>>          'Filter/Util/Call.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/Filter/Util/Call.pm',
>>>          'base.pm' => '/usr/share/perl/5.30/base.pm',
>>>          'Time/Local.pm' => '/usr/share/perl/5.30/Time/Local.pm',
>>>          'warnings.pm' => '/usr/share/perl/5.30/warnings.pm',
>>>          'Geo/WeatherNOAA.pm' => '../lib/site/Geo/WeatherNOAA.pm',
>>>          'constant.pm' => '/usr/share/perl/5.30/constant.pm',
>>>          'Text/Tabs.pm' => '/usr/share/perl/5.30/Text/Tabs.pm',
>>>          'overloading.pm' => '/usr/share/perl/5.30/overloading.pm',
>>>          'HTTP/Request.pm' => '/usr/share/perl5/HTTP/Request.pm',
>>>          'Data/Dumper.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/Data/Dumper.pm',
>>>          'LWP/Protocol.pm' => '/usr/share/perl5/LWP/Protocol.pm',
>>>          'Text/Balanced.pm' => '/usr/share/perl/5.30/Text/Balanced.pm'
>>>        );
>>> Getting the forecast for Rochester, NY
>>>
>>> The forecast is As of :
>>>
>>> So, the *fallback directory is somehow prioritized above my local
>>> installed modules*.
>>>
>>> I decided to try removing the fallback directory from the path, and
>>> running it again. This is my edit in get_weather:
>>> ...
>>> #use my_lib "$Pgm_Path/../lib/site", "$Pgm_Path/../lib/fallback"; # See
>>> note in lib/mh_perl2exe.pl for lib -> my_lib explaination
>>> BEGIN {
>>>     eval "use lib '$Pgm_Path/../lib', '$Pgm_Path/../lib/site'"*;#, *
>>> '$Pgm_Path/../lib/fallback'";
>>> }                         # Use BEGIN eval to keep perl2exe happy
>>>
>>> require 'handy_utilities.pl';    # For read_mh_opts funcion
>>> &main::read_mh_opts( \%config_parms, $Pgm_Path );
>>>
>>> use Geo::WeatherNOAA;
>>>
>>> $Geo::WeatherNOAA::proxy_from_env = 1;
>>>
>>>
>>> *use Data::Dumper::Simple; print Dumper(%INC);*
>>>
>>>
>>> if ( $data{conditions} ) {
>>> ...
>>>
>>> ...then ran it again:
>>>
>>> %INC = (
>>>          'Tie/Hash.pm' => '/usr/share/perl/5.30/Tie/Hash.pm',
>>>          'Storable.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/Storable.pm',
>>>          'handy_utilities.pl' => '../lib/handy_utilities.pl',
>>>          'overloading.pm' => '/usr/share/perl/5.30/overloading.pm',
>>>          'vars.pm' => '/usr/share/perl/5.30/vars.pm',
>>>          'LWP/UserAgent.pm' => '/usr/share/perl5/LWP/UserAgent.pm',
>>>          'Data/Dumper.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/Data/Dumper.pm',
>>>          'Symbol.pm' => '/usr/share/perl/5.30/Symbol.pm',
>>>          'constant.pm' => '/usr/share/perl/5.30/constant.pm',
>>>          'Encode/MIME/Name.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/Encode/MIME/Name.pm',
>>>          'I18N/Langinfo.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/I18N/Langinfo.pm',
>>>          'warnings/register.pm' => '/usr/share/perl/5.30/warnings/
>>> register.pm',
>>>          'LWP/MemberMixin.pm' => '/usr/share/perl5/LWP/MemberMixin.pm',
>>>          'parent.pm' => '/usr/share/perl/5.30/parent.pm',
>>>          'Filter/Util/Call.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/Filter/Util/Call.pm',
>>>          'Getopt/Long.pm' => '/usr/share/perl/5.30/Getopt/Long.pm',
>>>          'Exporter/Heavy.pm' => '/usr/share/perl/5.30/Exporter/Heavy.pm',
>>>          'HTTP/Date.pm' => '/usr/share/perl5/HTTP/Date.pm',
>>>          'Filter/Simple.pm' => '/usr/share/perl/5.30/Filter/Simple.pm',
>>>          'integer.pm' => '/usr/share/perl/5.30/integer.pm',
>>>          'LWP/Protocol.pm' => '/usr/share/perl5/LWP/Protocol.pm',
>>>          'LWP.pm' => '/usr/share/perl5/LWP.pm',
>>>          're.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.30/re.pm',
>>>          'Text/Balanced.pm' => '/usr/share/perl/5.30/Text/Balanced.pm',
>>>          'Encode/Config.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/Encode/Config.pm',
>>>          'Config.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.30/Config.pm',
>>>          'List/Util.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/List/Util.pm',
>>>          'IO.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.30/IO.pm',
>>>          'HTTP/Config.pm' => '/usr/share/perl5/HTTP/Config.pm',
>>>          'Carp.pm' => '/usr/share/perl/5.30/Carp.pm',
>>>          'HTTP/Message.pm' => '/usr/share/perl5/HTTP/Message.pm',
>>>          'SelfLoader.pm' => '/usr/share/perl/5.30/SelfLoader.pm',
>>>          'Try/Tiny.pm' => '/usr/share/perl5/Try/Tiny.pm',
>>>          'Encode/Locale.pm' => '/usr/share/perl5/Encode/Locale.pm',
>>>          'URI/Escape.pm' => '/usr/share/perl5/URI/Escape.pm',
>>>          'Exporter.pm' => '/usr/share/perl/5.30/Exporter.pm',
>>>          'base.pm' => '/usr/share/perl/5.30/base.pm',
>>>          'SelectSaver.pm' => '/usr/share/perl/5.30/SelectSaver.pm',
>>>          'Data/Dumper/Simple.pm' =>
>>> '/usr/share/perl5/Data/Dumper/Simple.pm',
>>>          'Sub/Util.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/Sub/Util.pm',
>>>          'Tie/IxHash.pm' => '/usr/share/perl5/Tie/IxHash.pm',
>>>          'overload.pm' => '/usr/share/perl/5.30/overload.pm',
>>>          'LWP/Simple.pm' => '/usr/share/perl5/LWP/Simple.pm',
>>>          'URI.pm' => '/usr/share/perl5/URI.pm',
>>>          'HTTP/Response.pm' => '/usr/share/perl5/HTTP/Response.pm',
>>>          'Encode/Alias.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/Encode/Alias.pm',
>>>          'Geo/WeatherNOAA.pm' => '../lib/site/Geo/WeatherNOAA.pm',
>>>          'XSLoader.pm' => '/usr/share/perl/5.30/XSLoader.pm',
>>>          'Scalar/Util.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/Scalar/Util.pm',
>>>          'Fcntl.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.30/Fcntl.pm',
>>>          'warnings.pm' => '/usr/share/perl/5.30/warnings.pm',
>>>          'bytes.pm' => '/usr/share/perl/5.30/bytes.pm',
>>>          'Encode/Encoding.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/Encode/Encoding.pm',
>>>          'lib.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.30/lib.pm',
>>>          'HTTP/Request.pm' => '/usr/share/perl5/HTTP/Request.pm',
>>>          'Text/Tabs.pm' => '/usr/share/perl/5.30/Text/Tabs.pm',
>>>          'Time/Local.pm' => '/usr/share/perl/5.30/Time/Local.pm',
>>>          'Text/Wrap.pm' => '/usr/share/perl/5.30/Text/Wrap.pm',
>>>          'Encode.pm' => '/usr/lib/x86_64-linux-gnu/perl/5.30/Encode.pm',
>>>          'IO/Handle.pm' =>
>>> '/usr/lib/x86_64-linux-gnu/perl/5.30/IO/Handle.pm',
>>>          'HTTP/Status.pm' => '/usr/share/perl5/HTTP/Status.pm',
>>>          'strict.pm' => '/usr/share/perl/5.30/strict.pm',
>>>          'HTTP/Headers.pm' => '/usr/share/perl5/HTTP/Headers.pm'
>>>        );
>>> Getting the forecast for Rochester, NY
>>>
>>> The forecast is As of 3:46pm Mon Dec 7, 2020:
>>> Tonight: Becoming mostly cloudy.
>>>
>>> It worked!
>>>
>>> I tried to see what would happen if I put the fallback path back into
>>> get_weather, but removed the actual fallback directory, and got this:
>>>
>>> Error in loading module=Device::SerialPort:
>>>   Can't locate Device/SerialPort.pm in @INC (you may need to install the
>>> Device::SerialPort module) (@INC contains: /opt/mh/local/code
>>> ./../code/common /opt/mh/misterhouse/bin/../lib
>>> /opt/mh/misterhouse/bin/../lib/site . /etc/perl
>>> /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0
>>> /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5
>>> /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30
>>> /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base
>>> /opt/mh/misterhouse/bin/../lib/fallback) at (eval 32) line 1.
>>> BEGIN failed--compilation aborted at (eval 32) line 1.
>>>
>>>  - See install.html for instructions on how to install perl module
>>> Device::SerialPort
>>>
>>> At least you can see my @INC paths now. :)
>>> I took this one step further and put fallback back into lib, started MH
>>> and ran "Get the Internet weather forecast", which failed. Then with MH
>>> still running, I renamed fallback to __fallback and ran it again.... it
>>> worked. It doesn't like SOMETHING in fallback, but it's not reporting it in
>>> %INC.
>>>
>>> Big questions:
>>>
>>>    1. Why is fallback prioritized ahead of my local directories?
>>>    2. Why when there are no modules used from fallback does get_weather
>>>    fail unless I remove the reference to fallback?
>>>
>>> I think I'm out of my league...
>>>
>>> Thanks!
>>>
>>> Steve
>>>
>>> On Mon, Dec 7, 2020 at 9:46 AM Brian M <[email protected]>
>>> wrote:
>>>
>>>> Stephen,
>>>>
>>>> You get credit for reading all the way through an overly long post. I
>>>> really have to learn to say things in fewer words, or at least add a
>>>> "TL;DR".
>>>>
>>>> I suggest you add back fallback, and then add some temporary diagnostic
>>>> code to get_weather.pl to dump %INC. That will show you every module
>>>> that it loaded and where they came from. Just look for the fallback
>>>> directory in the %INC values, and you should find which modules are being
>>>> pulled from that folder. That should give you a pretty short list of
>>>> suspects. Then you can rename them one by one (or in small batches), and
>>>> find the culprit.
>>>>
>>>> I've dabbled in similar areas. NOAA has changed their API format once
>>>> or twice. I suspect there's an old module in fallback that doesn't know
>>>> about that, but that's just a guess. I wish we could just update or delete
>>>> everything in fallback, but I think the MH carnage would probably be huge.
>>>> Luckily for me, it's not my call.
>>>>
>>>>                                         -Brian M.
>>>>
>>>>
>>>>
>>>> On 12/7/20 6:20 AM, Stephen Switzer wrote:
>>>>
>>>> Brian,
>>>>    Thank you for the effort to explain the fallback directory. I'm
>>>> sorry I may not have been clear enough on my thought process. I read the
>>>> fallback conversations on the list and saw the hplato commit that added
>>>> this to the external /bin files, so I knew what was happening... but I have
>>>> yet to figure out which module was causing the issue. I tried deleting
>>>> every module that WeatherNOAA depended on but there was still an error
>>>> (blank forecast).
>>>>
>>>>    I thought that I was on the right path a few different times by
>>>> changing code, updating the weatherNOAA module, changing {zone} to {state},
>>>> etc, etc... but I recognized that I may need to take a step back and begin
>>>> again, since I have have drawn some false conclusions about what fixed it -
>>>> especially when I discovered that removing fallback had a positive effect.
>>>> I offered my code as a talking point, but realized it wasn't the "right"
>>>> fix.
>>>>
>>>>    My question should be closer to something like this: Does anyone
>>>> have it working with the fallback directory in the library list? I deleted
>>>> LWP::* and restarted MH without any success, and moved on to Tie::IxHash,
>>>> then some Text module that I forgot the specifics on. I suppose I could
>>>> continue deleting modules and testing, but I was growing weary of the
>>>> process.
>>>>
>>>>    Perhaps a better question is this: Who's running hplato/master with
>>>> internet_weather successfully? What did you modify?
>>>>
>>>> Steve
>>>>
>>>>
>>>> On Mon, Dec 7, 2020 at 12:40 AM Brian M <
>>>> [email protected]> wrote:
>>>>
>>>>> Stephen,
>>>>>
>>>>> I can clarify about fallback, and hopefully put you on the path to the
>>>>> right solution.
>>>>>
>>>>> MH has a long standing philosophy of having it "just work out of the
>>>>> box".  (Others can probably represent this perspective better than I can as
>>>>> it's not mine, but I'll give it a shot and trust others to correct me where
>>>>> necessary.)  What that meant was that they didn't want to have a lot of
>>>>> Perl pre-requisite modules.  So instead, they packaged the commonly needed
>>>>> modules in with MH, so that when you unpack it, you get them too.
>>>>>
>>>>> The problem lies in that no one ever wanted to keep the packaged
>>>>> CPAN/distro modules embedded in MH up-to-date, so that for example the
>>>>> version of LWP::UserAgent (for interfacing with web-sites) provided with MH
>>>>> was so old it didn't support SSL, even though the version you or I would
>>>>> install via CPAN or our distro has supported SSL for years.
>>>>>
>>>>> To make things worse, MH explicitly set the Perl library path, so that
>>>>> the supplied versions preempted system versions (e.g. /usr/lib/perl or
>>>>> whatever from your distro or CPAN), so that the only way to update the MH
>>>>> version was to make and maintain a local mod to MH yourself.  In my case,
>>>>> finding this out that meant many hours of trying to figure out why a piece
>>>>> of my code worked perfectly outside of MH (because it used the CPAN
>>>>> LWP::UserAgent), but not in MH (because it used a really old version that
>>>>> didn't support SSL).  That's my perspective, at least.
>>>>>
>>>>> I wanted a solution that would be acceptable to those with the "just
>>>>> work out of the box/provide modules" perspective, while still allowing
>>>>> people that needed a newer version of a module to install it without
>>>>> hacking MH every time it updates. What I implemented to please everyone was
>>>>> to identify all the external Perl modules that MH packaged into it's
>>>>> distribution but wasn't maintaining.  It's a long list.  I then moved all
>>>>> of these that I could from MH's normal library into the newly created
>>>>> "fallback" library, which I listed at the end of the Perl5 library list.
>>>>> That way, if you have a newer version in the system libraries, your code
>>>>> could find it.  If you didn't, the out-dated versions in fallback libraries
>>>>> would still get picked up and used.  Essentially, the fallback libraries
>>>>> become the library of last resort instead of preempting the system
>>>>> libraries.
>>>>>
>>>>> That code went in in April (I think), and this is the first incident
>>>>> I've heard of where it broke something.  What that tells me is that
>>>>> get_weather calls on a module that exists broken in fallback.  By removing
>>>>> fallback, you've removed access to broken code, and it works again.  How it
>>>>> works without the module it found in fallback is beyond me since there are
>>>>> no libraries to search after fallback.  It may have some "if I can't find
>>>>> module X, use Y instead" logic in it, and you deleted access to X.
>>>>>
>>>>> Removing fallback is the wrong solution, however.  The best and
>>>>> easiest solution is to identify the outdated, broken module get_weather is
>>>>> using out of the fallback library, and install a newer one via CPAN or your
>>>>> distro.  get_weather will automatically pick up the newer one instead and I
>>>>> think you should be in good shape.  Or find just delete the reference to
>>>>> the broken module so get_weather doesn't use it, since get_weather isn't
>>>>> using it when you removed fallback and appears to work fine.
>>>>>
>>>>> In any case, moving the outdated CPAN modules into fallback gives you
>>>>> options. If we hadn't implemented that change, get_weather would still
>>>>> break (because it would still find bad module X, just in lib instead of
>>>>> fallback/lib), but then you wouldn't be able to fix it by just installing a
>>>>> newer version of X.  Moving the module from lib to fallback didn't break
>>>>> get_weather, it just made some other breakage you discovered easier to fix.
>>>>>
>>>>>                                             -Brian M
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On 12/6/20 7:45 PM, Stephen Switzer wrote:
>>>>>
>>>>> A month later I was able to piece together a commit that seems to have
>>>>> all the needed changes from master.
>>>>>
>>>>>
>>>>> https://github.com/pmatis/misterhouse/commit/bbd8f73942cbe304403d953f7c614268c3783fde
>>>>>
>>>>> There are still some significant unanswered questions in my mind, but
>>>>> first...
>>>>>
>>>>>    1. I discovered that the Geo:WeatherNOAA module that I received
>>>>>    was older than what was in master.
>>>>>       1. I only added a line for gracefully failing a little early,
>>>>>       since continuing on is wasted cycles.
>>>>>       2. The get_weather script was out of date in master, lacking a
>>>>>    change from 08/17/16 by Rick, but contained a nws_rwr_zone
>>>>>    parameter that seems to be ignored in this file.
>>>>>    3. internet_weather.pl was calling "print_current( $parms{city},
>>>>>    $parms{zone}..." instead of "print_current( $parms{city}, $parms{
>>>>>    state}..." in one copy of that file I had. I can't seem to put my
>>>>>    eye on it right now, though.
>>>>>
>>>>> The main thing that I'm questioning is the addition of '$Pgm_Path/../lib/fallback'
>>>>> in get_weather. While comparing versions of files that I had, I finally
>>>>> stumbled upon this difference and noticed that when I removed this from the
>>>>> path, the forecast was retrieved successfully. I went into the fallback
>>>>> directory and tried to determine what was in there that was seemingly too
>>>>> old. I looked into WeatherNOAA.pm to see what it depended on and removed
>>>>> the 2 LWP modules, then tried again with the entire LWP directory. I moved
>>>>> on Tie::IxHash, then the entire Tie directory, Text... I was removing huge
>>>>> chunks of these files and nothing changed the results except removing the
>>>>> fallback directory from the path.
>>>>>
>>>>> I have a sneaking suspicion that I missed something. At least for now
>>>>> I have something that makes master work for me. There's a bunch of commits
>>>>> that I can cherry pick into my running code and have it work. Anyone else
>>>>> care to peek at this?
>>>>>
>>>>> Thanks!
>>>>> Steve
>>>>>
>>>>> On Tue, Nov 3, 2020 at 4:40 PM Rick Steeves via misterhouse-users <
>>>>> [email protected]> wrote:
>>>>>
>>>>>> D'oh, I had also updated the internet_weather page - I should have
>>>>>> sent
>>>>>> that to you as well! sprry...
>>>>>>
>>>>>> Rick
>>>>>>
>>>>>>
>>>>>> On 11/3/2020 11:14 AM, Stephen Switzer wrote:
>>>>>> > An update to everyone, I incorporated these two files, experimented
>>>>>> and
>>>>>> > modified them along with internet_weather.pl
>>>>>> > <http://internet_weather.pl> and finally have it working. I'll
>>>>>> have to
>>>>>> > diff thin
>>>>>
>>>>>

________________________________________________________
To unsubscribe from this list, go to: https://lists.sourceforge.net/lists/listinfo/misterhouse-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.