dglent / meteo-qt

System tray application for weather status information
GNU General Public License v3.0
83 stars 21 forks source link

Crash - KeyError (float() argument must be a string or a number, not 'NoneType') #88

Closed jose1711 closed 5 years ago

jose1711 commented 5 years ago

this seems to be intermittent and possibly is related to OWM data

Child process initialized in 103.42 ms
2019/05/25 16:00:54 CRASH:
--------------------------------------------------------------------------------
<class 'TypeError'>      
float() argument must be a string or a number, not 'NoneType'
--------------------------------------------------------------------------------
  File "/usr/lib/python3.7/site-packages/meteo_qt/meteo_qt.py", line 1504, in weatherdata
    tree[4][0].get('value'), wind, str(int(float(wind_dir_value))),

2019/05/25 16:00:54 CRASH:
--------------------------------------------------------------------------------
<class 'KeyError'>       
'Wind'
--------------------------------------------------------------------------------
  File "/usr/lib/python3.7/site-packages/meteo_qt/meteo_qt.py", line 1400, in done
    self.overviewcity()
  File "/usr/lib/python3.7/site-packages/meteo_qt/meteo_qt.py", line 245, in overviewcity
    wind_speed = '{0:.1f}'.format(float(self.weatherDataDico['Wind'][0]))

looking at self.weatherDataDico the key Wind is missing:

{'Id': '3060972', 'City': 'Bratislava', 'Country': 'SK', 'Temp': '24.37°', 'Meteo': 'jasná obloha', 'Humidity': ('36', '%')}
jose1711 commented 5 years ago

and this is what self.weatherDataDico contains after a while: {'Id': '3060972', 'City': 'Bratislava', 'Country': 'SK', 'Temp': '24.1°', 'Meteo': 'jasná obloha', 'Humidity': ('41', '%'), 'Wind': ('3.1', 'slabý vietor', '340', 'SSZ', 'Severoseverozápad'), 'Clouds': '0% jasná obloha', 'Pressure': ('1012', 'hPa'), 'Sunrise': '2019-05-25T03:01:48', 'Sunset': '2019-05-25T18:35:26', 'Precipitation': ('no', '')}

dglent commented 5 years ago

Hello

i will add an exception to handle this

Thanks for reporting

dglent commented 5 years ago

Fixed in this commit: https://github.com/dglent/meteo-qt/commit/3e9fb2b46c670dd6ba7b78794ed4fb0064c15f2c#diff-5ed3175115338b6f48aaa9ff69a82ab4