Mercurial > hg > egg-tcls
comparison fetch_weather.pl @ 446:ba559d5d44db
fetch_weather: Rename the Tiehallinto static metadata cache filename setting.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 28 Sep 2017 15:17:39 +0300 |
parents | dbe9e233f564 |
children | 11124f9bf994 |
comparison
equal
deleted
inserted
replaced
445:dbe9e233f564 | 446:ba559d5d44db |
---|---|
40 "opt_fmi" => 0, | 40 "opt_fmi" => 0, |
41 "opt_tiehallinto" => 0, | 41 "opt_tiehallinto" => 0, |
42 "purge_threshold" => 60, | 42 "purge_threshold" => 60, |
43 "fmi_api_key" => "", | 43 "fmi_api_key" => "", |
44 "outfile" => "", | 44 "outfile" => "", |
45 "tiehallinto_static_meta" => "tiehallinto.meta", | |
46 "http_user_agent" => "Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 6.0) Opera 10.63 [en]", | 45 "http_user_agent" => "Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 6.0) Opera 10.63 [en]", |
47 "tiehallinto_rw_url" => "http://tie.digitraffic.fi/sujuvuus/ws/roadWeather", | 46 "tiehallinto_rw_url" => "http://tie.digitraffic.fi/sujuvuus/ws/roadWeather", |
47 "tiehallinto_meta" => "tiehallinto.meta", | |
48 "tiehallinto_meta_url" => "http://tie.digitraffic.fi/api/v1/metadata/weather-stations", | 48 "tiehallinto_meta_url" => "http://tie.digitraffic.fi/api/v1/metadata/weather-stations", |
49 ); | 49 ); |
50 | 50 |
51 | 51 |
52 ### | 52 ### |
370 { | 370 { |
371 # Parse the XML | 371 # Parse the XML |
372 my $data = $xml->{"soap:Body"}{"RoadWeatherResponse"}; | 372 my $data = $xml->{"soap:Body"}{"RoadWeatherResponse"}; |
373 | 373 |
374 # Check if we need to update the static meta data | 374 # Check if we need to update the static meta data |
375 my $meta_file = opt_get("tiehallinto_static_meta"); | |
376 my $fetch_meta = (-e $meta_file) ? 0 : 1; | 375 my $fetch_meta = (-e $meta_file) ? 0 : 1; |
377 | 376 |
378 if (defined($data->{"laststaticdataupdate"})) | 377 if (defined($data->{"laststaticdataupdate"})) |
379 { | 378 { |
380 # Compare metadata cache file modification timestamp to info in XML | 379 # Compare metadata cache file modification timestamp to info in XML |
381 my $tmp1 = str2time($data->{"laststaticdataupdate"}); | 380 my $tmp1 = str2time($data->{"laststaticdataupdate"}); |
382 my $tmp2 = (-e $meta_file) ? (stat($meta_file))[9] : -1; | 381 my $tmp2 = (-e $meta_file) ? (stat($meta_file))[9] : -1; |
383 $fetch_meta = 1 unless ($tmp1 < $tmp2); | 382 $fetch_meta = 1 unless ($tmp1 < $tmp2); |
384 } | 383 } |
384 my $meta_file = opt_get("tiehallinto_meta"); | |
385 | 385 |
386 # Fetch or read the cache | 386 # Fetch or read the cache |
387 my $meta_str; | 387 my $meta_str; |
388 if ($fetch_meta || opt_chk_bool("force_update")) | 388 if ($fetch_meta || opt_chk_bool("force_update")) |
389 { | 389 { |