From 87004aadc139d069926fefe84888b70c2d5e35a7 Mon Sep 17 00:00:00 2001 From: Kimmo Huoman Date: Mon, 21 Dec 2020 20:09:33 +0200 Subject: [PATCH] Add exception handling to weather symbol conversion. --- fmi/observation.py | 6 +++++- setup.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fmi/observation.py b/fmi/observation.py index e135969..de1c5ae 100644 --- a/fmi/observation.py +++ b/fmi/observation.py @@ -35,7 +35,6 @@ def __init__(self, timestamp, point): self.dew_point = point.get('dew_point', None) self.precipitation = point.get('precipitation', None) self.precipitation_1h = point.get('precipitation_1h', None) - self.weather_symbol = int(point.get('weather_symbol', 0)) self.radiation_global_accumulation = point.get( 'radiation_global_accumulation', None) self.radiation_long_wave_accumulation = point.get( @@ -47,6 +46,11 @@ def __init__(self, timestamp, point): self.radiation_diffuse_accumulation = point.get( 'radiation_diffuse_accumulation', None) + try: + self.weather_symbol = int(point.get('weather_symbol', 0)) + except ValueError: + self.weather_symbol = None + def __repr__(self): return '<%s: %s - %.1f C>' % ( self.__class__.__name__, diff --git a/setup.py b/setup.py index 46b80a9..0848328 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name='fmi_weather', - version='1.1.1', + version='1.1.2', description='FMI weather data fetcher', author='Kimmo Huoman', author_email='kipenroskaposti@gmail.com',