Author: duncan
Date: Thu Sep 20 16:32:53 2007
New Revision: 9884
Log:
Icons are now working and so is the text
Added:
branches/rel-1/testing/Duncan/weather/1click/64x64/
branches/rel-1/testing/Duncan/weather/1click/64x64/0.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/1.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/10.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/11.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/12.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/13.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/14.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/15.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/16.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/17.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/18.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/19.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/2.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/20.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/21.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/22.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/23.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/24.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/25.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/26.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/27.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/28.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/29.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/3.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/30.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/31.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/32.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/33.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/34.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/35.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/36.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/37.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/38.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/39.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/4.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/40.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/41.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/42.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/43.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/44.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/45.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/46.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/47.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/5.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/6.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/7.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/8.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/9.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/64x64/na.png (contents, props
changed)
branches/rel-1/testing/Duncan/weather/1click/oneclick.py
- copied, changed from r9883,
/branches/rel-1/testing/Duncan/weather/1click/1click.py
Removed:
branches/rel-1/testing/Duncan/weather/1click/1click.py
Modified:
branches/rel-1/testing/Duncan/weather/1click/gets.sh
branches/rel-1/testing/Duncan/weather/1click/weatherdata.py
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/0.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/1.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/10.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/11.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/12.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/13.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/14.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/15.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/16.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/17.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/18.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/19.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/2.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/20.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/21.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/22.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/23.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/24.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/25.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/26.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/27.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/28.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/29.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/3.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/30.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/31.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/32.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/33.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/34.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/35.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/36.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/37.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/38.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/39.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/4.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/40.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/41.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/42.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/43.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/44.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/45.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/46.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/47.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/5.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/6.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/7.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/8.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/9.png
==============================================================================
Binary file. No diff available.
Added: branches/rel-1/testing/Duncan/weather/1click/64x64/na.png
==============================================================================
Binary file. No diff available.
Modified: branches/rel-1/testing/Duncan/weather/1click/gets.sh
==============================================================================
--- branches/rel-1/testing/Duncan/weather/1click/gets.sh (original)
+++ branches/rel-1/testing/Duncan/weather/1click/gets.sh Thu Sep 20
16:32:53 2007
@@ -6,3 +6,7 @@
wget 'http://ff.1click.weather.com/weather/local/SZXX0033?cc=*&unit=m'
# 5 day forecast
wget 'http://ff.1click.weather.com/weather/local/SZXX0033?dayf=5&unit=m'
+
+wget 'http://ff.1click.weather.com/weather/local/UKXX0085?cc=*'
+
+wget 'http://ff.1click.weather.com/weather/local/UKXX0085?eloc=st'
Copied: branches/rel-1/testing/Duncan/weather/1click/oneclick.py (from r9883,
/branches/rel-1/testing/Duncan/weather/1click/1click.py)
==============================================================================
--- /branches/rel-1/testing/Duncan/weather/1click/1click.py (original)
+++ branches/rel-1/testing/Duncan/weather/1click/oneclick.py Thu Sep 20
16:32:53 2007
@@ -1,6 +1,6 @@
# -*- coding: iso-8859-1 -*-
# -----------------------------------------------------------------------
-# weather.py - a plugin to obtain detailed weather forecast information
+# oneclick.py - a plugin to obtain detailed weather forecast information
# -----------------------------------------------------------------------
# $Id: weather.py 9862 2007-09-10 15:36:28Z duncan $
#
@@ -51,7 +51,7 @@
# rdf modules
from xml.dom.ext.reader import Sax2
-import urllib
+import urllib, urllib2
import cElementTree as ET
@@ -71,139 +71,157 @@
#check every 1 hour
WEATHER_AGE = 3600
WEATHER_DIR = os.path.join(config.SHARE_DIR, 'images', 'weather')
+WEATHER_DIR = '/sources/svn/freevo-1.x/testing/Duncan/weather/1click/64x64'
-WEATHER_DATA = [
- ('1', _('Cloudy'), 'cloudy.png'),
- ('3', _('Mostly Cloudy'), 'mcloudy.png'),
- ('4', _('Partly Cloudy'), 'pcloudy.png'),
- ('13', _('Light Rain'), 'lshowers.png'),
- ('14', _('Showers'), 'showers.png'),
- ('16', _('Snow'), 'snowshow.png'),
- ('18', _('Rain'), 'showers.png'),
- ('19', _('AM Showers'), 'showers.png'),
- ('20', _('Fog'), 'fog.png'),
- ('21', _('Few Showers'), 'lshowers.png'),
- ('22', _('Mostly Sunny'), 'sunny.png'),
- ('24', _('Sunny'), 'sunny.png'),
- ('25', _('Scattered Flurries'), 'flurries.png'),
- ('26', _('AM Clouds/PM Sun'), 'pcloudy.png'),
- ('27', _('Isolated T-Storms'), 'thunshowers.png'),
- ('28', _('Scattered Thunderstorms'), 'thunshowers.png'),
- ('29', _('PM Showers'), 'showers.png'),
- ('30', _('PM Showers/Wind'), 'showers.png'),
- ('31', _('Rain/Snow Showers'), 'rainsnow.png'),
- ('32', _('Few Snow Showers'), 'flurries.png'),
- ('33', _('Cloudy/Wind'), 'cloudy.png'),
- ('34', _('Flurries/Wind'), 'flurries.png'),
- ('35', _('Mostly Cloudy/Windy'), 'mcloudy.png'),
- ('36', _('Rain/Thunder'), 'thunshowers.png'),
- ('37', _('Partly Cloudy/Windy'), 'pcloudy.png'),
- ('38', _('AM Rain/Snow Showers'), 'rainsnow.png'),
- ('40', _('Light Rain/Wind'), 'lshowers.png'),
- ('41', _('Showers/Wind'), 'showers.png'),
- ('42', _('Heavy Snow'), 'snowshow.png'),
- ('43', _('Drizzle'), 'showers.png'),
- ('44', _('Mostly Sunny/Wind'), 'sunny.png'),
- ('45', _('Flurries'), 'flurries.png'),
- ('47', _('Rain/Wind'), 'showers.png'),
- ('49', _('Sct Flurries/Wind'), 'flurries.png'),
- ('50', _('Sct Strong Storms'), 'thunshowers.png'),
- ('51', _('PM T-Storms'), 'thunshowers.png'),
- ('53', _('Thunderstorms'), 'thunshowers.png'),
- ('55', _('Sunny/Windy'), 'sunny.png'),
- ('56', _('AM Thunderstorms'), 'thunshowers.png'),
- ('62', _('AM Rain'), 'showers.png'),
- ('64', _('Iso T-Storms/Wind'), 'thunshowers.png'),
- ('65', _('Rain/Snow'), 'rainsnow.png'),
- ('66', _('Sct T-Storms/Wind'), 'showers.png'),
- ('67', _('AM Showers/Wind'), 'showers.png'),
- ('70', _('Sct Snow Showers'), 'snowshow.png'),
- ('71', _('Snow to Ice/Wind'), 'snowshow.png'),
- ('76', _('AM Ice'), 'rainsnow.png'),
- ('77', _('Snow to Rain'), 'rainsnow.png'),
- ('80', _('AM Light Rain'), 'lshowers.png'),
- ('81', _('PM Light Rain'), 'lshowers.png'),
- ('82', _('PM Rain'), 'showers.png'),
- ('84', _('Snow Showers'), 'snowshow.png'),
- ('85', _('Rain to Snow'), 'rainsnow.png'),
- ('86', _('PM Rain/Snow'), 'snowshow.png'),
- ('88', _('Few Showers/Wind'), 'showers.png'),
- ('90', _('Snow/Wind'), 'snowshow.png'),
- ('91', _('PM Rain/Snow Showers'), 'rainsnow.png'),
- ('92', _('PM Rain/Snow/Wind'), 'rainsnow.png'),
- ('93', _('Rain/Snow Showers/Wind'), 'rainsnow.png'),
- ('94', _('Rain/Snow/Wind'), 'rainsnow.png'),
- ('98', _('Light Snow'), 'flurries.png'),
- ('100', _('PM Snow'), 'snowshow.png'),
- ('101', _('Few Snow Showers/Wind'), 'snowshow.png'),
- ('103', _('Light Snow/Wind'), 'flurries.png'),
- ('104', _('Wintry Mix'), 'flurries.png'),
- ('105', _('AM Wintry Mix'), 'rainsnow.png'),
- ('106', _('Hvy Rain/Freezing Rain'), 'rainsnow.png'),
- ('108', _('AM Light Snow'), 'flurries.png'),
- ('109', _('PM Rain/Snow/Wind'), 'rainsnow.png'),
- ('114', _('Rain/Freezing Rain'), 'showers.png'),
- ('118', _('T-Storms/Wind'), 'thunshowers.png'),
- ('123', _('Sprinkles'), 'lshowers.png'),
- ('125', _('AM Snow Showers'), 'snowshow.png'),
- ('126', _('AM Clouds/PM Sun/Wind'), 'pcloudy.png'),
- ('128', _('AM Rain/Snow/Wind'), 'rainsnow.png'),
- ('130', _('Rain to Snow/Wind'), 'rainsnow.png'),
- ('132', _('Snow to Wintry Mix'), 'snowshow.png'),
- ('133', _('PM Snow Showers/Wind'), 'snowshow.png'),
- ('135', _('Snow and Ice to Rain'), 'rainsnow.png'),
- ('137', _('Heavy Rain'), 'showers.png'),
- ('138', _('AM Rain/Ice'), 'showers.png'),
- ('145', _('AM Snow Showers/Wind'), 'snowshow.png'),
- ('146', _('AM Light Snow/Wind'), 'flurries.png'),
- ('150', _('PM Light Rain/Wind'), 'lshowers.png'),
- ('152', _('AM Light Wintry Mix'), 'rainsnow.png'),
- ('153', _('PM Light Snow/Wind'), 'flurries.png'),
- ('154', _('Heavy Rain/Wind'), 'showers.png'),
- ('155', _('PM Snow Shower'), 'snowshow.png'),
- ('158', _('Snow to Rain/Wind'), 'rainsnow.png'),
- ('164', _('PM Light Rain/Ice'), 'showers.png'),
- ('167', _('AM Snow'), 'snowshow.png'),
- ('171', _('Snow to Ice'), 'snowshow.png'),
- ('172', _('Wintry Mix/Wind'), 'rainsnow.png'),
- ('175', _('PM Light Snow'), 'flurries.png'),
- ('178', _('AM Drizzle'), 'lshowers.png'),
- ('189', _('Strong Storms/Wind'), 'thunshowers.png'),
- ('193', _('PM Drizzle'), 'lshowers.png'),
- ('194', _('Drizzle'), 'lshowers.png'),
- ('201', _('AM Light Rain/Wind'), 'lshowers.png'),
- ('204', _('AM Rain/Wind'), 'showers.png'),
- ('223', _('Wintry Mix to Snow'), 'rainsnow.png'),
- ('231', _('Rain'), 'showers.png'),
- ('240', _('AM Light Rain/Ice'), 'rainsnow.png'),
- ('259', _('Hvy Rain/Freezing Rain'), 'showers.png'),
- ('271', _('Snow Showers/Windy'), 'snowshow.png'),
- ('988', _('Partly Cloudy/Windy'), 'pcloudy.png'),
- ('989', _('Light Rain Shower'), 'lshowers.png'),
- ('990', _('Light Rain with Thunder'), 'thunshowers.png'),
- ('991', _('Light Drizzle'), 'lshowers.png'),
- ('992', _('Mist'), 'fog.png'),
- ('993', _('Smoke'), 'fog.png'),
- ('994', _('Haze'), 'fog.png'),
- ('995', _('Light Snow Shower'), 'flurries.png'),
- ('996', _('Light Snow Shower/ Windy'), 'flurries.png'),
- ('997', _('Clear'), 'fair.png'),
- ('998', _('A Few Clouds'), 'pcloudy.png'),
- ('999', _('Fair'), 'fair.png')
-]
-
-def wget1(iUrl):
- print 'wget1(%s)' % (iUrl)
- data = None
+WEATHER_DATA = {
+ 1: ( _('Cloudy'), 'cloudy.png'),
+ 3: ( _('Mostly Cloudy'), 'mcloudy.png'),
+ 4: ( _('Partly Cloudy'), 'pcloudy.png'),
+ 13: ( _('Light Rain'), 'lshowers.png'),
+ 14: ( _('Showers'), 'showers.png'),
+ 16: ( _('Snow'), 'snowshow.png'),
+ 18: ( _('Rain'), 'showers.png'),
+ 19: ( _('AM Showers'), 'showers.png'),
+ 20: ( _('Fog'), 'fog.png'),
+ 21: ( _('Few Showers'), 'lshowers.png'),
+ 22: ( _('Mostly Sunny'), 'sunny.png'),
+ 24: ( _('Sunny'), 'sunny.png'),
+ 25: ( _('Scattered Flurries'), 'flurries.png'),
+ 26: ( _('AM Clouds/PM Sun'), 'pcloudy.png'),
+ 27: ( _('Isolated T-Storms'), 'thunshowers.png'),
+ 28: ( _('Scattered Thunderstorms'), 'thunshowers.png'),
+ 29: ( _('PM Showers'), 'showers.png'),
+ 30: ( _('PM Showers/Wind'), 'showers.png'),
+ 31: ( _('Rain/Snow Showers'), 'rainsnow.png'),
+ 32: ( _('Few Snow Showers'), 'flurries.png'),
+ 33: ( _('Cloudy/Wind'), 'cloudy.png'),
+ 34: ( _('Flurries/Wind'), 'flurries.png'),
+ 35: ( _('Mostly Cloudy/Windy'), 'mcloudy.png'),
+ 36: ( _('Rain/Thunder'), 'thunshowers.png'),
+ 37: ( _('Partly Cloudy/Windy'), 'pcloudy.png'),
+ 38: ( _('AM Rain/Snow Showers'), 'rainsnow.png'),
+ 40: ( _('Light Rain/Wind'), 'lshowers.png'),
+ 41: ( _('Showers/Wind'), 'showers.png'),
+ 42: ( _('Heavy Snow'), 'snowshow.png'),
+ 43: ( _('Drizzle'), 'showers.png'),
+ 44: ( _('Mostly Sunny/Wind'), 'sunny.png'),
+ 45: ( _('Flurries'), 'flurries.png'),
+ 47: ( _('Rain/Wind'), 'showers.png'),
+ 49: ( _('Sct Flurries/Wind'), 'flurries.png'),
+ 50: ( _('Sct Strong Storms'), 'thunshowers.png'),
+ 51: ( _('PM T-Storms'), 'thunshowers.png'),
+ 53: ( _('Thunderstorms'), 'thunshowers.png'),
+ 55: ( _('Sunny/Windy'), 'sunny.png'),
+ 56: ( _('AM Thunderstorms'), 'thunshowers.png'),
+ 62: ( _('AM Rain'), 'showers.png'),
+ 64: ( _('Iso T-Storms/Wind'), 'thunshowers.png'),
+ 65: ( _('Rain/Snow'), 'rainsnow.png'),
+ 66: ( _('Sct T-Storms/Wind'), 'showers.png'),
+ 67: ( _('AM Showers/Wind'), 'showers.png'),
+ 70: ( _('Sct Snow Showers'), 'snowshow.png'),
+ 71: ( _('Snow to Ice/Wind'), 'snowshow.png'),
+ 76: ( _('AM Ice'), 'rainsnow.png'),
+ 77: ( _('Snow to Rain'), 'rainsnow.png'),
+ 80: ( _('AM Light Rain'), 'lshowers.png'),
+ 81: ( _('PM Light Rain'), 'lshowers.png'),
+ 82: ( _('PM Rain'), 'showers.png'),
+ 84: ( _('Snow Showers'), 'snowshow.png'),
+ 85: ( _('Rain to Snow'), 'rainsnow.png'),
+ 86: ( _('PM Rain/Snow'), 'snowshow.png'),
+ 88: ( _('Few Showers/Wind'), 'showers.png'),
+ 90: ( _('Snow/Wind'), 'snowshow.png'),
+ 91: ( _('PM Rain/Snow Showers'), 'rainsnow.png'),
+ 92: ( _('PM Rain/Snow/Wind'), 'rainsnow.png'),
+ 93: ( _('Rain/Snow Showers/Wind'), 'rainsnow.png'),
+ 94: ( _('Rain/Snow/Wind'), 'rainsnow.png'),
+ 98: ( _('Light Snow'), 'flurries.png'),
+ 100: ( _('PM Snow'), 'snowshow.png'),
+ 101: ( _('Few Snow Showers/Wind'), 'snowshow.png'),
+ 103: ( _('Light Snow/Wind'), 'flurries.png'),
+ 104: ( _('Wintry Mix'), 'flurries.png'),
+ 105: ( _('AM Wintry Mix'), 'rainsnow.png'),
+ 106: ( _('Hvy Rain/Freezing Rain'), 'rainsnow.png'),
+ 108: ( _('AM Light Snow'), 'flurries.png'),
+ 109: ( _('PM Rain/Snow/Wind'), 'rainsnow.png'),
+ 114: ( _('Rain/Freezing Rain'), 'showers.png'),
+ 118: ( _('T-Storms/Wind'), 'thunshowers.png'),
+ 123: ( _('Sprinkles'), 'lshowers.png'),
+ 125: ( _('AM Snow Showers'), 'snowshow.png'),
+ 126: ( _('AM Clouds/PM Sun/Wind'), 'pcloudy.png'),
+ 128: ( _('AM Rain/Snow/Wind'), 'rainsnow.png'),
+ 130: ( _('Rain to Snow/Wind'), 'rainsnow.png'),
+ 132: ( _('Snow to Wintry Mix'), 'snowshow.png'),
+ 133: ( _('PM Snow Showers/Wind'), 'snowshow.png'),
+ 135: ( _('Snow and Ice to Rain'), 'rainsnow.png'),
+ 137: ( _('Heavy Rain'), 'showers.png'),
+ 138: ( _('AM Rain/Ice'), 'showers.png'),
+ 145: ( _('AM Snow Showers/Wind'), 'snowshow.png'),
+ 146: ( _('AM Light Snow/Wind'), 'flurries.png'),
+ 150: ( _('PM Light Rain/Wind'), 'lshowers.png'),
+ 152: ( _('AM Light Wintry Mix'), 'rainsnow.png'),
+ 153: ( _('PM Light Snow/Wind'), 'flurries.png'),
+ 154: ( _('Heavy Rain/Wind'), 'showers.png'),
+ 155: ( _('PM Snow Shower'), 'snowshow.png'),
+ 158: ( _('Snow to Rain/Wind'), 'rainsnow.png'),
+ 164: ( _('PM Light Rain/Ice'), 'showers.png'),
+ 167: ( _('AM Snow'), 'snowshow.png'),
+ 171: ( _('Snow to Ice'), 'snowshow.png'),
+ 172: ( _('Wintry Mix/Wind'), 'rainsnow.png'),
+ 175: ( _('PM Light Snow'), 'flurries.png'),
+ 178: ( _('AM Drizzle'), 'lshowers.png'),
+ 189: ( _('Strong Storms/Wind'), 'thunshowers.png'),
+ 193: ( _('PM Drizzle'), 'lshowers.png'),
+ 194: ( _('Drizzle'), 'lshowers.png'),
+ 201: ( _('AM Light Rain/Wind'), 'lshowers.png'),
+ 204: ( _('AM Rain/Wind'), 'showers.png'),
+ 223: ( _('Wintry Mix to Snow'), 'rainsnow.png'),
+ 231: ( _('Rain'), 'showers.png'),
+ 240: ( _('AM Light Rain/Ice'), 'rainsnow.png'),
+ 259: ( _('Hvy Rain/Freezing Rain'), 'showers.png'),
+ 271: ( _('Snow Showers/Windy'), 'snowshow.png'),
+ 988: ( _('Partly Cloudy/Windy'), 'pcloudy.png'),
+ 989: ( _('Light Rain Shower'), 'lshowers.png'),
+ 990: ( _('Light Rain with Thunder'), 'thunshowers.png'),
+ 991: ( _('Light Drizzle'), 'lshowers.png'),
+ 992: ( _('Mist'), 'fog.png'),
+ 993: ( _('Smoke'), 'fog.png'),
+ 994: ( _('Haze'), 'fog.png'),
+ 995: ( _('Light Snow Shower'), 'flurries.png'),
+ 996: ( _('Light Snow Shower/ Windy'), 'flurries.png'),
+ 997: ( _('Clear'), 'fair.png'),
+ 998: ( _('A Few Clouds'), 'pcloudy.png'),
+ 999: ( _('Fair'), 'fair.png')
+}
+
+def wget(url):
+ """
+ """
+ print 'wget(%s)' % (url)
+ txdata = None
+ txheaders = {
+ 'User-Agent' : 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7'
+ }
+ req = urllib2.Request(url, txdata, txheaders)
try:
- fd = open(iUrl)
+ response = urllib2.urlopen(req)
+ try:
+ data = response.read()
+ finally:
+ response.close()
+ if response.msg == 'OK':
+ return data
+ except urllib2.HTTPError, error:
+ print 'getting %r failed: %s' % (url, error)
+ except ValueError, error:
+ print 'invalid url %r failed: %s' % (url, error)
+ fd = open(url)
data = fd.read()
fd.close()
- except IOError:
- pass
- return data
+ return data
+ return None
-def wget(iUrl):
+
+def wget2(iUrl):
print 'wget(iUrl)'
for i in range(3):
try:
@@ -252,16 +270,16 @@
To activate, put the following lines in local_conf.py:
- plugin.activate('weather', level=45)
+ plugin.activate('oneclick', level=45)
PLUGIN_WEATHER_LOCATIONS = [
- ("<val1>", <bool>, "<lang>", "<str>"),
- ("<val2>", <bool>, "<lang>", "<str>"),
+ ("<loc1>", <metric>, "<location name1>"),
+ ("<loc2>", <metric>, "<location name2>"),
...
]
- where <val#> is a zipcode or
- and <bool> (1 == convert to SI Units; 0 == do not convert)
- and <str> is a custom name you wish to use for this location
+ where <val#> is a zipcode or an airport code
+ and <metric> (1 == convert to SI Units; 0 == do not convert)
+ and <location name#> is a custom name you wish to use for this location
"""
# make an init func that creates the cache dir if it don't exist
def __init__(self):
@@ -274,9 +292,11 @@
def config(self):
print 'config(self)'
return [
- ('PLUGIN_WEATHER_LOCATIONS', [("USNC0559", 0)], "Location codes to
grab forecasts for"),
- ('PLUGIN_WEATHER_DATAURL',
'http://www.tpfans.com/rss/weather.php?Citycode=%s&Language=%s', 'Data URL'),
- ('PLUGIN_WEATHER_MAPURL',
'http://www.weather.com/weather/map/%s?from=LAPmaps', 'Radar Map URL')
+ ('ONECLICK_LOCATIONS', [('USNC0559', 0)], 'Location codes for
current conditions and forecasts'),
+ ('ONECLICK_URL_CURC',
'http://ff.1click.weather.com/weather/local/%s?cc=*%s', 'Current Conditions
URL'),
+ ('ONECLICK_URL_DAYF',
'http://ff.1click.weather.com/weather/local/%s?dayf=5%s', 'Day Forecast URL'),
+ ('ONECLICK_URL_ELOC',
'http://ff.1click.weather.com/weather/local/%s?eloc=st', 'Extended Location
URL'),
+ ('ONECLICK_URL_MAP',
'http://www.weather.com/weather/map/%s?from=LAPmaps', 'Radar Map URL')
]
def items(self, parent):
@@ -288,8 +308,8 @@
"""
Item for the menu for one rss feed
"""
- def __init__(self, parent, iLocation):
- print '__init__(self, parent, iLocation)'
+ def __init__(self, parent, location):
+ print '__init__(parent=%r, location=%r)' % (parent, location)
Item.__init__(self, parent)
self.parent = parent
@@ -298,11 +318,15 @@
self.error = 0
self.location = None
- self.language = 'EN'
- self.convertData = 0
+ self.ismetric = False
self.name = None
self.city = None
self.state = None
+ self.unit_t = None
+ self.unit_d = None
+ self.unit_s = None
+ self.unit_p = None
+ self.unit_r = None
self.country = None
self.curTemp = None
self.updated = None
@@ -326,35 +350,34 @@
self.wdata = []
self.popupParam = None
self.radarUrl = None
- # were we asked to convert to SI units?
- if isinstance(iLocation, tuple):
- self.location = iLocation[0]
- if len(iLocation) > 1:
- self.convertData = int(iLocation[1])
- if len(iLocation) > 2:
- self.language = str(iLocation[2])
- if len(iLocation) > 3:
- self.name = str(iLocation[3])
- if len(iLocation) > 4:
- self.radarUrl = str(iLocation[4])
- self.popupParam = Unicode(self.location)
- if self.name:
- self.popupParam = Unicode(self.name)
+ if isinstance(location, tuple):
+ self.location = location[0]
+ if len(location) > 1:
+ self.ismetric = int(location[1])
+ if len(location) > 2:
+ self.name = str(location[3])
+ if len(location) > 3:
+ self.radarUrl = str(location[4])
else:
- self.location = iLocation
- self.convertData = 0
- self.popupParam = self.location
-
- #self.dataurl =
"http://www.msnbc.com/m/chnk/d/weather_d_src.asp?acid=%s" % (self.location,)
- #self.dataurl =
"http://www.tpfans.com/rss/weather.php?Citycode=%s&Language=%s" %
(self.location, self.language)
- #self.dataurl = config.PLUGIN_WEATHER_DATAURL % (self.location,
self.language)
- self.dataurle = 'USNC0559-eloc.xml'
- self.dataurle = 'SZXX0033-eloc.xml'
- self.dataurlf = 'SZXX0033-dayf5.xml'
- self.dataurlc = 'SZXX0033-cc.xml'
- self.mapurl = "http://www.weather.com/weather/map/%s?from=LAPmaps" %
(self.location,)
- self.mapurl = config.PLUGIN_WEATHER_MAPURL % (self.location,)
+ self.location = location
+ self.ismetric = False
+
+ self.popupParam = Unicode(self.location)
+ if self.name:
+ self.popupParam = Unicode(self.name)
+
+ if self.ismetric:
+ self.units = '&unit=m'
+ else:
+ self.units = ''
+ self.url_curc = config.ONECLICK_URL_CURC %
(urllib.quote(self.location), self.units)
+ self.url_dayf = config.ONECLICK_URL_DAYF %
(urllib.quote(self.location), self.units)
+ self.url_eloc = config.ONECLICK_URL_ELOC %
(urllib.quote(self.location))
+ self.url_curc = 'SZXX0033-cc.xml'
+ self.url_dayf = 'SZXX0033-dayf5.xml'
+ self.url_eloc = 'SZXX0033-eloc.xml'
+ self.mapurl = config.ONECLICK_URL_MAP % (self.location,)
self.mapurl2 = None
self.maplink = None
self.weatherData = None
@@ -370,106 +393,55 @@
#get forecast data
self.getForecast()
+ def start_detailed_interface(self, arg=None, menuw=None):
+ print 'start_detailed_interface(self, arg=None, menuw=None)'
+ WeatherDetailHandler(arg, menuw, self)
+
+ def actions(self):
+ print 'actions(self)'
+ """
+ return a list of actions for this item
+ """
+ return [ (self.start_detailed_interface, _('Show Weather Details')) ]
+
def isValid(self):
print 'isValid(self)'
return not self.error
+ def getLastUpdated(self):
+ print 'getLastUpdated(self)'
+ if self.ismetric:
+ # day / month / year 24hour:min:sec
+ return _("Last updated: %s") % (time.strftime("%d/%m/%Y %H:%M:%S",
time.localtime(self.last_update)),)
+ else:
+ # month / day / year 12hour:min:sec [AM|PM]
+ return _("Last updated: %s") % (time.strftime("%m/%d/%Y %I:%M:%S
%p", time.localtime(self.last_update)),)
+
def getHumidity(self):
print 'getHumidity(self)'
return "%s %%" % (self.curHumid,)
def getBarometer(self):
print 'getBarometer(self)'
- if self.convertData:
- return "%s kPa" % (self.barometer,)
- else:
- return "%s in" % (self.barometer,)
+ return "%s %s" % (self.barometer, self.unit_p)
def getWind(self):
print 'getWind(self)'
- if self.convertData:
- return "%s km/h" % (self.curWind,)
- else:
- return "%s mph" % (self.curWind,)
+ return "%s %s" % (self.curWind, self.unit_s)
def getTemp(self):
print 'getTemp(self)'
- if self.convertData:
- return u"%s\xb0 C" % (self.curTemp,)
- else:
- return u"%s\xb0 F" % (self.curTemp,)
-
- def getLastUpdated(self):
- print 'getLastUpdated(self)'
- if self.convertData:
- # day / month / year 24hour:min:sec
- return _("Last updated: %s") % (time.strftime("%d/%m/%Y %H:%M:%S",
time.localtime(self.last_update)),)
- else:
- # month / day / year 12hour:min:sec [AM|PM]
- return _("Last updated: %s") % (time.strftime("%m/%d/%Y %I:%M:%S
%p", time.localtime(self.last_update)),)
+ return u"%s\xb0%s" % (self.curTemp, self.unit_t)
def getFeel(self):
print 'getFeel(self)'
- if self.convertData:
- return u"%s\xb0 C" % (self.curFeel,)
- else:
- return u"%s\xb0 F" % (self.curFeel,)
+ return u"%s\xb0%s" % (self.curFeel, self.unit_t)
def getVisibility(self):
print 'getVisibility(self)'
if float(self.visibility) == 999.00:
return _("Unlimited")
- elif self.convertData:
- return "%s km" % (self.visibility,)
- else:
- return "%s mi" % (self.visibility,)
-
- def start_detailed_interface(self, arg=None, menuw=None):
- print 'start_detailed_interface(self, arg=None, menuw=None)'
- WeatherDetailHandler(arg, menuw, self)
-
- def actions(self):
- print 'actions(self)'
- """
- return a list of actions for this item
- """
- return [ (self.start_detailed_interface, _('Show Weather Details')) ]
-
- def saveToCache(self):
- print 'saveToCache(self)'
- util.save_pickle(self.weatherData, self.cacheFile)
- # attempt to save weathermap
- try:
- if self.weatherMapData is not None:
- imgfd = os.open(self.mapFile, os.O_CREAT|os.W_OK)
- os.write(imgfd, self.weatherMapData)
- os.close(imgfd)
- except:
- print "failed while saving weather map to cache '%s'" %
(self.mapFile,)
-
- def loadFromCache(self):
- print 'loadFromCache(self)'
- self.weatherData = util.read_pickle(self.cacheFile)
-
- try:
- size = int(os.stat(self.mapFile)[6])
- except:
- _debug_("failed attempting to load %s radar map from cache" %
(self.location,), config.DERROR)
- pass
- else:
- imgfd = os.open(self.mapFile, os.R_OK)
- self.weatherMapData = os.read(imgfd, size)
- os.close(imgfd)
-
- def needRefresh(self):
- '''is the cache too old?'''
- print 'needRefresh(self)'
- return 1
- if (os.path.isfile(self.cacheFile) == 0 or \
- (abs(time.time() - os.path.getmtime(self.cacheFile)) >
WEATHER_AGE)):
- return 1
- else:
- return 0
+ return "%s %s" % (self.visibility, self.unit_d)
def getForecast(self, force=0):
print 'getForecast(self, force=0)'
@@ -506,18 +478,42 @@
# output = urllib.unquote(output)
# print output
- def GetString(self, var):
- print 'GetString(self, var)'
- '''when given a variable, it returns the value stored in the MSNBC
forecast data'''
-
- regexp = re.compile('%s = "[^"]*"' % (var,))
- results = regexp.search(self.weatherData)
- if not results:
- return ''
- (start, end) = results.span()
- start += len(var) + 4 # the 4 chars is the ' = "'
- end -= 1 # strip off the right "
- return self.weatherData[start:end]
+
+ def needRefresh(self):
+ '''is the cache too old?'''
+ print 'needRefresh(self)'
+ return 1
+ if (os.path.isfile(self.cacheFile) == 0 or \
+ (abs(time.time() - os.path.getmtime(self.cacheFile)) >
WEATHER_AGE)):
+ return 1
+ else:
+ return 0
+
+ def saveToCache(self):
+ print 'saveToCache(self)'
+ util.save_pickle(self.weatherData, self.cacheFile)
+ # attempt to save weathermap
+ try:
+ if self.weatherMapData is not None:
+ imgfd = os.open(self.mapFile, os.O_CREAT|os.W_OK)
+ os.write(imgfd, self.weatherMapData)
+ os.close(imgfd)
+ except:
+ print "failed while saving weather map to cache '%s'" %
(self.mapFile,)
+
+ def loadFromCache(self):
+ print 'loadFromCache(self)'
+ self.weatherData = util.read_pickle(self.cacheFile)
+
+ try:
+ size = int(os.stat(self.mapFile)[6])
+ except:
+ _debug_("failed attempting to load %s radar map from cache" %
(self.location,), config.DERROR)
+ pass
+ else:
+ imgfd = os.open(self.mapFile, os.R_OK)
+ self.weatherMapData = os.read(imgfd, size)
+ os.close(imgfd)
def updateData(self):
print 'updateData(self)'
@@ -526,15 +522,15 @@
popup.show()
# parse the document
+ self.currentData = wget(self.url_curc)
try:
- #self.weatherData = wget(self.dataurl)
- self.conditionsData = wget1(self.dataurlc)
- self.forecastData = wget1(self.dataurlf)
- self.locationData = wget1(self.dataurle)
+ self.currentData = wget(self.url_curc)
+ self.forecastData = wget(self.url_dayf)
+ self.locationData = wget(self.url_eloc)
except:
if GUI:
popup.destroy()
- raise WeatherError, 'Weather ERROR: failed attempting to grab
forecast for %s' % self.location
+ raise 'Weather: failed attempting to grab forecast for %s' %
self.location
#TODO: Get description from
http://weather.noaa.gov/pub/data/forecasts/zone/nc/ncz041.txt
@@ -591,22 +587,6 @@
if GUI:
popup.destroy()
- def findWeatherDataDict(self, tree, elements):
- print 'findWeatherDataDict(self, tree, elements)'
- '''find the elements from tree
- @param tree is a ElementTree tree
- @param elements is a map of xml tags and
- @returns a dict
- '''
- #print elements
- d = {}
- for k,v in elements.items():
- for elem in tree.findall(k):
- #print '%s %r %r' % (elem.tag, elem.text.strip(), elem.items())
- d[elem.tag] = elem
- #print d
- return d
-
def convertWeatherData1(self):
"""
@@ -615,11 +595,14 @@
#print self.locationData
locationTree = ET.XML(self.locationData)
location = WeatherData(locationTree)
- conditionsTree = ET.XML(self.conditionsData)
- conditions = WeatherData(conditionsTree)
+ currentTree = ET.XML(self.currentData)
+ current = WeatherData(currentTree)
forecastTree = ET.XML(self.forecastData)
forecast = WeatherData(forecastTree)
+ if not self.name:
+ self.name = location.loc.dnam
+
dnam = location.loc.dnam.split(', ')
ctry = location.eloc.ctry
print dnam
@@ -632,9 +615,15 @@
self.state = ''
self.country = dnam[1]
print 'city=%s, state=%s, country=%s' % (self.city, self.state,
self.country)
-
- self.curTemp = conditions.cc.tmp
- self.updated = conditions.cc.lsup
+
+ self.unit_t = current.head.ut
+ self.unit_d = current.head.ud
+ self.unit_s = current.head.us
+ self.unit_p = current.head.up
+ self.unit_r = current.head.ur
+
+ self.curTemp = current.cc.tmp
+ self.updated = current.cc.lsup
# reset variables
self.date = []
@@ -643,16 +632,17 @@
self.lowTemp = []
self.weatherType = []
- self.curIcon = conditions.cc.icon
- self.curWind = conditions.cc.wind.s + ' ' + conditions.head.us
- self.windDir = conditions.cc.wind.t
- self.barometer = conditions.cc.bar.r + ' ' + conditions.cc.bar.d
- self.curHumid = conditions.cc.hmid
- self.curFeel = conditions.cc.flik
- self.uvIndex = conditions.cc.uv.i + ' ' + conditions.cc.uv.t
- self.visibility = conditions.cc.vis
- self.shortdesc = conditions.cc.t
- self.description = '%s %s %s' % (self.shortdesc, _("at"), self.curTemp)
+ self.curIcon = current.cc.icon
+ self.curWind = current.cc.wind.s
+ self.windDir = current.cc.wind.t
+ self.barometer = current.cc.bar.r
+ self.curHumid = current.cc.hmid
+ self.curFeel = current.cc.flik
+ self.uvIndex = current.cc.uv.i
+ self.visibility = current.cc.vis
+ self.shortdesc = current.cc.t
+ self.description = '%s %s %s' % (self.shortdesc, _("at"),
self.getTemp())
+ self.image = self.setWeatherIcon(self.curIcon)
for day in forecast.dayf.days:
self.date.append(day.t)
@@ -660,154 +650,23 @@
self.lowTemp.append(day.low)
for part in day.parts:
if part.p == 'd':
- self.weatherIcon.append(part.icon)
+ self.weatherIcon.append(self.setWeatherIcon(part.icon))
self.weatherType.append(part.t)
- for i in dir(self):
- print i, self[i]
+ #for i in dir(self):
+ # print i, self[i]
- def convertWeatherData(self):
- print 'convertWeatherData(self)'
- self.city = self.GetString("this.swCity")
- self.state = self.GetString("this.swSubDiv")
- self.country = self.GetString("this.swCountry")
- self.curTemp = self.GetString("this.swTemp")
- self.updated = self.GetString("this.swLastUp")
- # reset variables
- self.date = []
- self.weatherIcon = []
- self.highTemp = []
- self.lowTemp = []
- self.weatherType = []
-
- # set the location name (if one was not specified in the
WEATHER_LOCATIONS"
- if self.name is None:
- self.name = "%s" % (self.city)
-
- # convert temperature
- if self.curTemp is None or len(self.curTemp) == 0:
- self.curTemp = "-na-"
- self.updated = self.updated + " (Not All Information Available)"
- else:
- if self.convertData:
- self.curTemp = toCelcius(self.curTemp)
-
- self.curIcon = self.GetString("this.swCIcon")
- self.curWind = self.GetString("this.swWindS")
-
- # convert wind
- if self.convertData:
- self.curWind = toKilometers(self.curWind)
-
- self.windDir = self.GetString("this.swWindD")
- self.barometer = self.GetString("this.swBaro")
-
- # convert barometer
- if self.convertData:
- self.barometer = toBarometer(self.barometer)
-
- self.curHumid = self.GetString("this.swHumid")
- self.curFeel = self.GetString("this.swReal")
-
- # convert feels-like temp
- if self.convertData:
- self.curFeel = toCelcius(self.curFeel)
-
- self.uvIndex = self.GetString("this.swUV")
- self.visibility = self.GetString("this.swVis")
- if not self.visibility:
- self.visibility = 0.0
-
- # convert visibility
- if self.convertData and float(self.visibility) != 999.0:
- self.visibility = toKilometers(self.visibility)
-
- self.shortdesc = _(self.GetString("this.swConText"))
- if self.shortdesc is None or len(self.shortdesc) == 0:
- self.shortdesc = self.curIcon
-
- self.forecastData = self.GetString("this.swFore")
- holdings = []
- holdings = self.forecastData.split("|")
- try:
- dayNum = int(holdings[0])
- except ValueError:
- dayNum = int(time.strftime("%u")) + 1
- curDay = int(time.strftime("%u")) + 1 # day of week 2(mon) - 1(sun)
-
- if dayNum != curDay:
- self.pastTime = 1
-
- ltime = time.localtime()
- ctr = 0
- for i in range(5,10):
- (mons, days, years) = holdings[i].split("/")
- mons = int(mons)
- days = int(days)
- years = int(years)
- dnum = (ltime[6] + ctr) % 7
- self.date.append(time.strftime("%A", (years, mons, days, ltime[3],
ltime[4], ltime[5], \
- dnum, ltime[7], ltime[8])))
- ctr += 1
-
- # weather icon
- for i in (10,11,12,13):
- self.weatherIcon.append(holdings[i])
-
- # calculate high temps
- for i in (20,21,22,23):
- if self.convertData:
- holdings[i] = toCelcius(holdings[i])
- self.highTemp.append(holdings[i])
-
- # calculate low temps
- for i in (40,41,42,43):
- if self.convertData:
- holdings[i] = toCelcius(holdings[i])
- self.lowTemp.append(holdings[i])
-
- for i in (15,16,17,18):
- self.weatherType.append(holdings[i])
-
- self.setWeatherTypeIcon()
- self.setWeatherIcon()
-
- # Create description
- self.description = "%s %s %s" % (self.shortdesc, _("at"),
self.getTemp())
-
- def setWeatherIcon(self):
- print 'setWeatherIcon(self)'
- '''set the weather icon given the short forecast description'''
-
- match = weatherTypes.findType(name=self.shortdesc)
- if match:
- self.curIcon = match.getIcon()
- else:
- self.curIcon = "unknown.png"
-
- # set the Item.image value
- self.image = os.path.join(WEATHER_DIR, self.curIcon)
- return
-
- def setWeatherTypeIcon(self):
- print 'setWeatherTypeIcon(self)'
+ def setWeatherIcon(self, num):
'''obtain the weather icons for multiple day forecast'''
+ print 'setWeatherTypeIcon(self)'
+
+ icon = os.path.join(WEATHER_DIR, '%s.png' % num)
+ if not os.path.exists(icon):
+ icon = os.path.join(WEATHER_DIR, 'na.png')
+ print '%s: %s' % (num, icon)
+ return icon
- for i in range(4):
- weather_type = self.weatherType[i]
- if not weather_type:
- print 'No weather type for day %s' % (i)
- self.weatherType[i] = _("%s (day: %s)") % (_("Unknown"), i)
- self.weatherIcon[i] = "unknown.png"
- else:
- match = weatherTypes.findType(number=weather_type)
- if match:
- self.weatherType[i] = match.getName()
- self.weatherIcon[i] = match.getIcon()
- else:
- self.weatherType[i] = _("%s (type: %s)") % (_("Unknown"),
weather_type)
- self.weatherIcon[i] = "unknown.png"
class WeatherType:
def __init__(self, iNum=0, iName="", iIcon=""):
@@ -866,6 +725,7 @@
self.wtypes.append (wtype)
except:
pass
+
def findType(self, number=None, name=None, icon=None):
print 'findType(self, number=None, name=None, icon=None)'
''' return a type given a type number '''
@@ -1044,7 +904,7 @@
A base class for weather screens to inherit from, provides common
members+methods
"""
def __init__(self):
- print '__init__(self)'
+ print 'WeatherBaseScreen.__init__(self)'
skin.Area.__init__(self, 'content')
# Weather display fonts
@@ -1140,6 +1000,7 @@
x=x_start, y=y_start,
width=self.content.width, height=-1, align_h='left')
+
def update_forecast(self):
print 'update_forecast(self)'
'''
@@ -1178,6 +1039,7 @@
x=x_start, y=y, height=-1, align_h='left')
y += (30 * self.ymult)
+
def update_week(self):
print 'update_week(self)'
Modified: branches/rel-1/testing/Duncan/weather/1click/weatherdata.py
==============================================================================
--- branches/rel-1/testing/Duncan/weather/1click/weatherdata.py (original)
+++ branches/rel-1/testing/Duncan/weather/1click/weatherdata.py Thu Sep 20
16:32:53 2007
@@ -32,6 +32,7 @@
return 'WeatherData'
+#391 lines
class Loc:
""" Location information
<loc id="SZXX0033">
@@ -199,7 +200,7 @@
class Bar:
- """
+ """
<bar>
<r>1020.0</r>
<d>rising</d>
@@ -220,7 +221,7 @@
class Uv:
- """
+ """
<uv>
<i>0</i>
<t>Low</t>
@@ -241,7 +242,7 @@
class Moon:
- """
+ """
<moon>
<icon>29</icon>
<t>New</t>
@@ -321,8 +322,8 @@
class Part:
""" Part of a day information
<part p="n">
- <icon>29</icon>
- <t>Partly Cloudy</t>
+ <icon>29</icon>
+ <t>Partly Cloudy</t>
<wind>
</wind>
<bt>P Cloudy</bt>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog