Mercurial > hg > egg-tcls
changeset 375:c303ddc0a683 rel-0_2_0
fetch_weather: Don't die() in case of bad XML from FMI, just skip parsing
the rest.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 03 Feb 2016 16:59:32 +0200 |
parents | 26b7963e7fbd |
children | a30283d1f050 |
files | fetch_weather.pl |
diffstat | 1 files changed, 10 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/fetch_weather.pl Mon Feb 01 15:34:34 2016 +0200 +++ b/fetch_weather.pl Wed Feb 03 16:59:32 2016 +0200 @@ -431,8 +431,12 @@ my @fmatches = ($fline =~ /\s*([\+\-]?\d+\.\d*|NaN)\s*/ig); if (scalar(@fmatches) > 0) { - die("Not enough items in scalar line (".scalar(@fmatches). " vs ".scalar(@fmitems). - "): ".$fline."\n") if (scalar(@fmatches) != scalar(@fmitems)); + if (scalar(@fmatches) != scalar(@fmitems)) + { + print STDERR "Not enough items in scalar line (". + scalar(@fmatches). " vs ".scalar(@fmitems)."): ".$fline."\n"; + goto skip_it; + } for (my $fni = 0; $fni < scalar(@fmitems); $fni++) { $farray[$findex]{$fmitems[$fni]} = $fmatches[$fni] if (lc($fmatches[$fni]) ne "nan"); @@ -488,6 +492,10 @@ } +### Skip here if the FMI shit fails due to broken data +skip_it: + + ### ### Purge very old entries, default to 60 minutes ###