From 0570b51fa570d7675973ff09e36bd7f940d54fba Mon Sep 17 00:00:00 2001 From: ncoop Date: Thu, 23 Jun 2016 21:28:42 -0700 Subject: [PATCH 1/2] Catch AttributeError also. --- i3pystatus/weather/weathercom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/i3pystatus/weather/weathercom.py b/i3pystatus/weather/weathercom.py index 5568a54..157c01a 100644 --- a/i3pystatus/weather/weathercom.py +++ b/i3pystatus/weather/weathercom.py @@ -86,11 +86,11 @@ class Weathercom(Backend): # space, hence the use of rpartition). International timezones (or ones # outside the system locale) don't seem to be handled well by # datetime.datetime.strptime(). - observation_time_str = doc.findtext('cc/lsup').rpartition(' ')[0] try: + observation_time_str = doc.findtext('cc/lsup').rpartition(' ')[0] observation_time = datetime.strptime(observation_time_str, '%m/%d/%y %I:%M %p') - except ValueError: + except (ValueError, AttributeError): observation_time = datetime.fromtimestamp(0) pressure_trend_str = doc.findtext('cc/bar/d').lower() From 322bcd59420a2b04b9ec3aad9156e3306978d919 Mon Sep 17 00:00:00 2001 From: ncoop Date: Thu, 23 Jun 2016 21:30:51 -0700 Subject: [PATCH 2/2] PEP8 compliance; remove unused IntervalModule. --- i3pystatus/weather/weathercom.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/i3pystatus/weather/weathercom.py b/i3pystatus/weather/weathercom.py index 157c01a..1db632f 100644 --- a/i3pystatus/weather/weathercom.py +++ b/i3pystatus/weather/weathercom.py @@ -1,4 +1,3 @@ -from i3pystatus import IntervalModule from i3pystatus.core.util import internet, require from i3pystatus.weather import Backend @@ -7,7 +6,8 @@ from urllib.request import urlopen import re import xml.etree.ElementTree as ElementTree -WEATHER_COM_URL = 'http://wxdata.weather.com/wxdata/weather/local/%s?unit=%s&dayf=1&cc=*' +WEATHER_COM_URL = \ + 'http://wxdata.weather.com/wxdata/weather/local/%s?unit=%s&dayf=1&cc=*' ON_LEFTCLICK_URL = 'https://weather.com/weather/today/l/%s' @@ -31,7 +31,8 @@ class Weathercom(Backend): status.register( 'weather', - format='{condition} {current_temp}{temp_unit}{icon}[ Hi: {high_temp}] Lo: {low_temp}', + format='{condition} {current_temp}{temp_unit}{icon}\ +[ Hi: {high_temp}] Lo: {low_temp}', colorize=True, backend=weathercom.Weathercom( location_code='94107:4:US',