From 2b3bcd4604e8afb5bb7e6e3874b5e2fd52dc6a56 Mon Sep 17 00:00:00 2001 From: Cezary Biele Date: Mon, 14 Oct 2013 11:26:06 +0200 Subject: [PATCH 1/3] added weather module --- i3pystatus/weather.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 i3pystatus/weather.py diff --git a/i3pystatus/weather.py b/i3pystatus/weather.py new file mode 100644 index 0000000..c520533 --- /dev/null +++ b/i3pystatus/weather.py @@ -0,0 +1,35 @@ +from i3pystatus import IntervalModule +import pywapi + +class Weather(IntervalModule): + + """ + This module gets the weather from weather.com + First, you need to get the code for the location from the website + Available formatters: + {temp} + """ + + interval = 20 + + settings = ( + "location_code", + "format", + ) + required = ("location_code") + + location_code='PLXX0028' + + format = "{current_temp}°C" + + def run(self): + current_temp = pywapi.get_weather_from_weather_com(self.location_code)['current_conditions']['temperature'] + self.output = { + "full_text": self.format.format(current_temp=current_temp) + } + #print ( self.output ) + +#w=Weather() +#w.run() + #def on_leftclick(self): + #webbrowser.open_new_tab(self.instance.get_url()) From dc85b646313f148093bf3b12b9d312b789a385d1 Mon Sep 17 00:00:00 2001 From: Cezary Biele Date: Mon, 14 Oct 2013 11:54:25 +0200 Subject: [PATCH 2/3] added humidity to weather module --- i3pystatus/weather.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/i3pystatus/weather.py b/i3pystatus/weather.py index c520533..d221578 100644 --- a/i3pystatus/weather.py +++ b/i3pystatus/weather.py @@ -4,32 +4,31 @@ import pywapi class Weather(IntervalModule): """ - This module gets the weather from weather.com - First, you need to get the code for the location from the website + This module gets the weather from weather.com using pywapi module + First, you need to get the code for the location from the www.weather.com Available formatters: - {temp} + {current_temp} + {humidity} """ interval = 20 settings = ( "location_code", + "units", "format", ) - required = ("location_code") - - location_code='PLXX0028' - - format = "{current_temp}°C" + #required = ("location_code") + format = "{current_temp}" def run(self): - current_temp = pywapi.get_weather_from_weather_com(self.location_code)['current_conditions']['temperature'] + #current_temp = pywapi.get_weather_from_weather_com(self.location_code)['current_conditions']['temperature'] + result = pywapi.get_weather_from_weather_com(self.location_code, self.units) + conditions = result['current_conditions'] + temperature = conditions['temperature'] + humidity = conditions['humidity'] + units = result['units'] + current_temp = '{t}°{d}'.format(t=temperature, d=units['temperature']) self.output = { - "full_text": self.format.format(current_temp=current_temp) + "full_text": self.format.format(current_temp=current_temp, humidity=humidity) } - #print ( self.output ) - -#w=Weather() -#w.run() - #def on_leftclick(self): - #webbrowser.open_new_tab(self.instance.get_url()) From b3ae571389cf1cac1776e89523d25bf7f57b2cb7 Mon Sep 17 00:00:00 2001 From: Cezary Biele Date: Mon, 14 Oct 2013 12:11:31 +0200 Subject: [PATCH 3/3] weather fixes --- i3pystatus/weather.py | 1 - 1 file changed, 1 deletion(-) diff --git a/i3pystatus/weather.py b/i3pystatus/weather.py index d221578..f5ad973 100644 --- a/i3pystatus/weather.py +++ b/i3pystatus/weather.py @@ -22,7 +22,6 @@ class Weather(IntervalModule): format = "{current_temp}" def run(self): - #current_temp = pywapi.get_weather_from_weather_com(self.location_code)['current_conditions']['temperature'] result = pywapi.get_weather_from_weather_com(self.location_code, self.units) conditions = result['current_conditions'] temperature = conditions['temperature']