From 8a787a03214d7df646b41057b4ce393432c4cb12 Mon Sep 17 00:00:00 2001 From: waynieack Date: Fri, 11 Nov 2016 08:44:32 -0600 Subject: [PATCH 1/4] Merge WeatherNOAA --- lib/site/Geo/WeatherNOAA.pm | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/site/Geo/WeatherNOAA.pm b/lib/site/Geo/WeatherNOAA.pm index cdb1f66c9..e5ccd2c01 100644 --- a/lib/site/Geo/WeatherNOAA.pm +++ b/lib/site/Geo/WeatherNOAA.pm @@ -169,7 +169,7 @@ sub process_city_zone { foreach my $key ( keys %forecast ) { $forecast{$key} =~ tr/\012//d; # Remove newlines - #$forecast{$key} = lc($forecast{$key}); # No all CAPS + #$forecast{$key} = lc($forecast{$key}); # No all CAPS $forecast{$key} =~ s/\s+/ /g; # Rid of multi-spaces $forecast{$key} = sent_caps( $forecast{$key} ); # Proper sentance caps } @@ -503,6 +503,17 @@ sub get_city_hourly { #print STDERR "Getting data from $URL\n"; my $data = get_data( $URL, $filename, $fileopt, $UA ); my $datalength = length($data); + if ( $data =~ /None issued/ ) { + $URL = + $URL_BASE + . $zone + . '&issuedby=' + . $state + . '&product=RWR&format=txt&version=1&glossary=0'; + + $data = get_data( $URL, $filename, $fileopt, $UA ); + $datalength = length($data); + } #print STDERR "Got data ($datalength)\n"; @@ -569,7 +580,7 @@ sub get_city_hourly { #print STDERR "$line\n"; #'@0 A15 @15 A9 @24 A5 @29 A5 @34 A4 @39 A8 @47 A8 @55 A8', $line; - return {} if $values[3] eq 'NOT AVBL'; # Return ref to empty hash + return {} if $values[3] eq 'NOT AVBL'; # Return ref to empty hash my %retValue; foreach my $i ( 0 .. $#fields ) { @@ -854,3 +865,4 @@ http://www.seva.net/~msolomon/ perl(1), Tie::IxHash(3), LWP::Simple(3), LWP::UserAgent(3). =cut + From 9f56b6328d200f5acadd0511a45779752860002f Mon Sep 17 00:00:00 2001 From: waynieack Date: Thu, 15 Dec 2016 22:10:03 -0600 Subject: [PATCH 2/4] Fix for rrd file path not being pulled from rrd_dir and weather_data_rrd ini params by default. Also fixed an issue which can cause a crash. --- lib/site/Geo/WeatherNOAA.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/site/Geo/WeatherNOAA.pm b/lib/site/Geo/WeatherNOAA.pm index e5ccd2c01..9bbb6dfcf 100644 --- a/lib/site/Geo/WeatherNOAA.pm +++ b/lib/site/Geo/WeatherNOAA.pm @@ -169,7 +169,7 @@ sub process_city_zone { foreach my $key ( keys %forecast ) { $forecast{$key} =~ tr/\012//d; # Remove newlines - #$forecast{$key} = lc($forecast{$key}); # No all CAPS + #$forecast{$key} = lc($forecast{$key}); # No all CAPS $forecast{$key} =~ s/\s+/ /g; # Rid of multi-spaces $forecast{$key} = sent_caps( $forecast{$key} ); # Proper sentance caps } @@ -580,7 +580,7 @@ sub get_city_hourly { #print STDERR "$line\n"; #'@0 A15 @15 A9 @24 A5 @29 A5 @34 A4 @39 A8 @47 A8 @55 A8', $line; - return {} if $values[3] eq 'NOT AVBL'; # Return ref to empty hash + return {} if $values[3] eq 'NOT AVBL'; # Return ref to empty hash my %retValue; foreach my $i ( 0 .. $#fields ) { From 2bc322ad9fb8e7eca922a7e1294ab2cd282534e4 Mon Sep 17 00:00:00 2001 From: waynieack Date: Thu, 15 Dec 2016 22:15:29 -0600 Subject: [PATCH 3/4] Fix Space --- lib/site/Geo/WeatherNOAA.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/site/Geo/WeatherNOAA.pm b/lib/site/Geo/WeatherNOAA.pm index 9bbb6dfcf..57d29170f 100644 --- a/lib/site/Geo/WeatherNOAA.pm +++ b/lib/site/Geo/WeatherNOAA.pm @@ -580,7 +580,7 @@ sub get_city_hourly { #print STDERR "$line\n"; #'@0 A15 @15 A9 @24 A5 @29 A5 @34 A4 @39 A8 @47 A8 @55 A8', $line; - return {} if $values[3] eq 'NOT AVBL'; # Return ref to empty hash + return {} if $values[3] eq 'NOT AVBL'; # Return ref to empty hash my %retValue; foreach my $i ( 0 .. $#fields ) { From 095c9eb8569b9d7bb91a8f36fcda707b875741b0 Mon Sep 17 00:00:00 2001 From: waynieack Date: Thu, 15 Dec 2016 22:19:09 -0600 Subject: [PATCH 4/4] Updated json_server.pl --- lib/json_server.pl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) mode change 100644 => 100755 lib/json_server.pl diff --git a/lib/json_server.pl b/lib/json_server.pl old mode 100644 new mode 100755 index b4cf561a1..0d3021290 --- a/lib/json_server.pl +++ b/lib/json_server.pl @@ -1,4 +1,3 @@ - =head1 B =head2 SYNOPSIS @@ -254,9 +253,16 @@ sub json_get { # RRD data routines if ( $path[0] eq 'rrd' || $path[0] eq '' ) { my $path = "$config_parms{data_dir}/rrd"; + $path = "$config_parms{rrd_dir}" + if ( defined $config_parms{rrd_dir} ); $path = $json_data{'rrd_config'}->{'prefs'}->{'path'} if ( defined $json_data{'rrd_config'}->{'prefs'}->{'path'} ); - my $rrd_file = "weather.rrd"; + my $rrd_file = "weather_data.rrd"; + $rrd_file = $config_parms{weather_data_rrd} + if ( defined $config_parms{weather_data_rrd} ); + if ( $rrd_file =~ m/.*\/(.*\.rrd)/ ) { + $rrd_file = $1; + } $rrd_file = $json_data{'rrd_config'}->{'prefs'}->{'default_rrd'} if ( defined $json_data{'rrd_config'}->{'prefs'}->{'default_rrd'} ); my $default_cf = "AVERAGE"; @@ -410,7 +416,7 @@ sub json_get { $data{'periods'} = $json_data{'rrd_config'}->{'periods'} if ( defined $json_data{'rrd_config'}->{'periods'} ); $data{'last_update'} = $xml_info->{'last_update'} * 1000 - if ( defined $xml_info->{'last_update'} ); + if ( ref($xml_info) eq 'HASH' && defined $xml_info->{'last_update'} ); $json_data{'rrd'} = \%data; }