mirror of
https://github.com/powerline/powerline.git
synced 2025-07-31 01:35:40 +02:00
Rename weather segment
This commit is contained in:
parent
9ec3a8ef5e
commit
07f1b7d697
@ -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" },
|
||||||
|
@ -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())
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
"name": "system_load"
|
"name": "system_load"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "forecast"
|
"name": "weather"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "date",
|
"name": "date",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user