mirror of
https://github.com/powerline/powerline.git
synced 2025-07-27 07:44:36 +02:00
Merge pull request #1123 from ZyX-I/weather-diagnostics
Include raw_response in error message in weather segment
This commit is contained in:
commit
f0d2f2884e
@ -139,11 +139,16 @@ class WeatherSegment(KwThreadedSegment):
|
|||||||
raw_response = urllib_read(url)
|
raw_response = urllib_read(url)
|
||||||
if not raw_response:
|
if not raw_response:
|
||||||
self.error('Failed to get response')
|
self.error('Failed to get response')
|
||||||
return
|
return None
|
||||||
|
|
||||||
response = json.loads(raw_response)
|
response = json.loads(raw_response)
|
||||||
|
try:
|
||||||
condition = response['query']['results']['weather']['rss']['channel']['item']['condition']
|
condition = response['query']['results']['weather']['rss']['channel']['item']['condition']
|
||||||
condition_code = int(condition['code'])
|
condition_code = int(condition['code'])
|
||||||
temp = float(condition['temp'])
|
temp = float(condition['temp'])
|
||||||
|
except (KeyError, ValueError):
|
||||||
|
self.exception('Yahoo returned malformed or unexpected response: {0}', repr(raw_response))
|
||||||
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
icon_names = weather_conditions_codes[condition_code]
|
icon_names = weather_conditions_codes[condition_code]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user