Rename weather segment

This commit is contained in:
Kim Silkebækken 2013-01-17 20:01:39 +01:00
parent 9ec3a8ef5e
commit 07f1b7d697
3 changed files with 3 additions and 8 deletions

View File

@ -17,7 +17,7 @@
"groups": { "groups": {
"user": { "fg": "white", "bg": "mediumblue", "attr": ["bold"] }, "user": { "fg": "white", "bg": "mediumblue", "attr": ["bold"] },
"date": { "fg": "white", "bg": "mediumblue" }, "date": { "fg": "white", "bg": "mediumblue" },
"forecast": { "fg": "brightestblue", "bg": "darkblue" }, "weather": { "fg": "brightestblue", "bg": "darkblue" },
"external_ip": { "fg": "brightestblue", "bg": "darkblue" }, "external_ip": { "fg": "brightestblue", "bg": "darkblue" },
"system_load": { "fg": "brightblue", "bg": "darkestblue" }, "system_load": { "fg": "brightblue", "bg": "darkestblue" },
"system_load_good": { "fg": "green", "bg": "darkestblue" }, "system_load_good": { "fg": "green", "bg": "darkestblue" },

View File

@ -56,14 +56,13 @@ def uptime(format='{days:02d}d {hours:02d}h {minutes:02d}m'):
minutes, seconds = divmod(seconds, 60) minutes, seconds = divmod(seconds, 60)
hours, minutes = divmod(minutes, 60) hours, minutes = divmod(minutes, 60)
days, hours = divmod(hours, 24) days, hours = divmod(hours, 24)
return format.format(days=int(days), hours=hours, minutes=minutes) return format.format(days=int(days), hours=hours, minutes=minutes)
except IOError: except IOError:
pass pass
@memoize(600, persistent=True) @memoize(600, persistent=True)
def forecast(unit='c', location_query=None): def weather(unit='c', location_query=None):
import json import json
import urllib import urllib
import urllib2 import urllib2
@ -74,7 +73,6 @@ def forecast(unit='c', location_query=None):
location_query = ','.join([location['city'], location['region_name'], location['country_name']]) location_query = ','.join([location['city'], location['region_name'], location['country_name']])
except ValueError: except ValueError:
return None return None
query_data = { query_data = {
'q': 'q':
'use "http://github.com/yql/yql-tables/raw/master/weather/weather.bylocation.xml" as we;' 'use "http://github.com/yql/yql-tables/raw/master/weather/weather.bylocation.xml" as we;'
@ -83,13 +81,10 @@ def forecast(unit='c', location_query=None):
} }
url = 'http://query.yahooapis.com/v1/public/yql?' + urllib.urlencode(query_data) url = 'http://query.yahooapis.com/v1/public/yql?' + urllib.urlencode(query_data)
response = json.loads(urllib2.urlopen(url).read()) response = json.loads(urllib2.urlopen(url).read())
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'])
icon = u'' icon = u''
for icon, codes in weather_conditions_codes.items(): for icon, codes in weather_conditions_codes.items():
if condition_code in codes: if condition_code in codes:
break break
return u'{0} {1}°{2}'.format(icon, condition['temp'], unit.upper()) return u'{0} {1}°{2}'.format(icon, condition['temp'], unit.upper())

View File

@ -19,7 +19,7 @@
"name": "system_load" "name": "system_load"
}, },
{ {
"name": "forecast" "name": "weather"
}, },
{ {
"name": "date", "name": "date",