mirror of
https://github.com/powerline/powerline.git
synced 2025-07-29 08:45:15 +02:00
Handle more KeyErrors in common weather segment
This commit is contained in:
parent
d6da2c8d98
commit
98269a4bb5
@ -138,12 +138,12 @@ def weather(unit='c', location_query=None):
|
||||
'select * from we where location="{0}" and unit="{1}"'.format(location_query, unit),
|
||||
'format': 'json'
|
||||
}
|
||||
try:
|
||||
url = 'http://query.yahooapis.com/v1/public/yql?' + _urllib_urlencode(query_data)
|
||||
response = json.loads(_urllib_read(url))
|
||||
try:
|
||||
condition = response['query']['results']['weather']['rss']['channel']['item']['condition']
|
||||
condition_code = int(condition['code'])
|
||||
except KeyError:
|
||||
except (KeyError, ValueError):
|
||||
return None
|
||||
icon = u'〇'
|
||||
for icon, codes in weather_conditions_codes.items():
|
||||
|
Loading…
x
Reference in New Issue
Block a user