@@ -155,16 +155,19 @@ def load_last_polled_times(self) -> Dict:
155
155
Returns:
156
156
Dict: The last polled times for each station and product.
157
157
"""
158
- if os .path .exists (self .last_polled_file ):
159
- with open (self .last_polled_file , 'r' , encoding = 'utf-8' ) as file :
160
- saved_times : Dict [str , Dict [str , str ]] = json .load (file )
161
- last_polled_times : Dict [str , Dict [str , datetime ]] = {}
162
- for product , stations in saved_times .items ():
163
- for station , timestamp in stations .items ():
164
- if product not in last_polled_times :
165
- last_polled_times [product ] = {}
166
- last_polled_times [product ][station ] = datetime .fromisoformat (timestamp )
167
- return last_polled_times
158
+ try :
159
+ if os .path .exists (self .last_polled_file ):
160
+ with open (self .last_polled_file , 'r' , encoding = 'utf-8' ) as file :
161
+ saved_times : Dict [str , Dict [str , str ]] = json .load (file )
162
+ last_polled_times : Dict [str , Dict [str , datetime ]] = {}
163
+ for product , stations in saved_times .items ():
164
+ for station , timestamp in stations .items ():
165
+ if product not in last_polled_times :
166
+ last_polled_times [product ] = {}
167
+ last_polled_times [product ][station ] = datetime .fromisoformat (timestamp )
168
+ return last_polled_times
169
+ except Exception as e :
170
+ print (f"Error loading last polled times: { e } " )
168
171
return {}
169
172
170
173
def save_last_polled_times (self , last_polled_times : Dict ):
0 commit comments