changeset 172:2c89e47739e8

weather: Change weather data loading to not discard current data if data file can't be opened.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 03 Jun 2014 12:59:53 +0300
parents 5434903331df
children 3ea14355e2d4
files weather.tcl
diffstat 1 files changed, 11 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/weather.tcl	Tue Jun 03 12:59:24 2014 +0300
+++ b/weather.tcl	Tue Jun 03 12:59:53 2014 +0300
@@ -204,17 +204,18 @@
 proc weather_update {} {
   global weather_datafile weather_data
 
-  # Create dict
-  array unset weather_data
-  array set weather_data {}
+  # Check if we can open the weather data file
+  if {![catch {set ufile [open $weather_datafile r 0600]} uerrmsg]} {
+    # Create dict
+    array unset weather_data
+    array set weather_data {}
 
-  set wtemp_min_val 500000
-  set wtemp_max_val -500000
-  set wtemp_min_key ""
-  set wtemp_max_key ""
-  
-  # Read datafile
-  if {![catch {set ufile [open $weather_datafile r 0600]} uerrmsg]} {
+    set wtemp_min_val 500000
+    set wtemp_max_val -500000
+    set wtemp_min_key ""
+    set wtemp_max_key ""
+
+    # Read in the data
     while {![eof $ufile]} {
       gets $ufile uline
       set udata [split $uline "|"]