From 98269a4bb59a28932e3cff0de175b6959e4d7200 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20Silkeb=C3=A6kken?= Date: Sun, 27 Jan 2013 17:42:11 +0100 Subject: [PATCH] Handle more KeyErrors in common weather segment --- powerline/segments/common.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/powerline/segments/common.py b/powerline/segments/common.py index 14363c92..217b59ee 100644 --- a/powerline/segments/common.py +++ b/powerline/segments/common.py @@ -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' } - url = 'http://query.yahooapis.com/v1/public/yql?' + _urllib_urlencode(query_data) - response = json.loads(_urllib_read(url)) try: + url = 'http://query.yahooapis.com/v1/public/yql?' + _urllib_urlencode(query_data) + response = json.loads(_urllib_read(url)) 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():