Advertisement
Guest User

xbmcplugin_weather.py

a guest
Nov 5th, 2011
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 77.93 KB | None | 0 0
  1. """
  2. GUI for displaying maps and forecasts from weather.com
  3.  
  4. Nuka1195, Brightsr
  5. """
  6.  
  7. # main imports
  8. import sys
  9. import os
  10.  
  11. import xbmc
  12. import xbmcgui
  13.  
  14. """
  15. from threading import Thread
  16. """
  17.  
  18. import WeatherClient as WeatherClient
  19.  
  20. from xbmcaddon import Addon
  21.  
  22. import re
  23.  
  24.  
  25. class Main:
  26. __settings__ = Addon( id="weather.weatherplus" )
  27. __language__ = __settings__.getLocalizedString
  28. # print "Mode AddOn ON"
  29.  
  30. _ = __language__
  31. Settings = __settings__
  32.  
  33. def __init__( self, *args, **kwargs ):
  34. # print "Initiation"
  35. # get current window
  36. self._get_weather_window()
  37. # get our new WeatherClient
  38. self.locationindex = xbmc.getInfoLabel( "Window(Weather).Property(LocationIndex)" )
  39. self._get_client()
  40. # if user selected a new map, only need to fetch it
  41. if ( sys.argv[ 1 ].startswith( "map=" ) ):
  42. # parse sys.argv for params
  43. params = dict( arg.split( "=" ) for arg in sys.argv[ 1 ].split( "&" ) )
  44. # fetch map (map=%s&title=%s&location=
  45. self._fetch_map( params[ "map" ], params[ "title" ], params[ "location" ] )
  46. else:
  47. # set plugin name property
  48. self._set_plugin_name()
  49. # clear key properties if new location
  50. if ( self.new_location ):
  51. self._clear_properties()
  52. # initialize our thread list
  53. """
  54. # Read guisetting.xml
  55. fh = open( "special://masterprofile/guisettings.xml" )
  56. content = fh.read()
  57. fh.close()
  58. areacodes = re.findall( "<areacode[0-9]+>(.+?)</areacode[0-9]+>", content )
  59. # Which area?
  60. self.area_num = 0
  61. for count, area in enumerate( areacodes ):
  62. code = area.split("-")[0].replace(" ","")
  63. if ( self.areacode == code ):
  64. self.area_num = count+1
  65. print "[Weather Plus] self.area_num = " + str(self.area_num)
  66. """
  67. self.provider = "Default"
  68. # Alternative Provider ( 0 : Accuweather.com Global, 1 : NOAA )
  69. if ( self.Settings.getSetting("location" + str(self.locationindex)) == "true" ):
  70. Location = self.Settings.getSetting("alt_location" + str(self.locationindex))
  71. self.provider = self.Settings.getSetting("alt_provider" + str(self.locationindex))
  72. self.WEATHER_WINDOW.setProperty( "Location", Location.split(" (")[0] )
  73. if ( self.provider == "0" ):
  74. self.areacode = self.Settings.getSetting("alt_code" + str(self.locationindex))
  75. print "[Weather Plus] Alternative Provider Selected : Accuweather.com Global (" + self.areacode + ")"
  76. # print re.search( "/", self.areacode )
  77. if ( re.search( "/", self.areacode ) is None ):
  78. dialog = xbmcgui.Dialog()
  79. yesno = dialog.yesno( "Area Code Error", "You need to re-select your location.", "Would you want to open Settings window?", "(Please refresh after re-selection.)" )
  80. if ( yesno ):
  81. self.__settings__.openSettings()
  82. return
  83. self._accu_hourly_forecast()
  84. self._accu_36_forecast()
  85. self._accu_10day_forecast()
  86. # self._accu_weekend_forecast()
  87. for count in range( 1, 4 ):
  88. self._clear_map_list( count )
  89. # self.provider = 1
  90. # self._fetch_map_list()
  91. if ( self.provider == "1" ):
  92. self.areacode = self.Settings.getSetting("alt_code" + str(self.locationindex))
  93. print "[Weather Plus] Alternative Provider Selected : NOAA (" + self.areacode +")"
  94. if ( re.search( "CityName", self.areacode ) is None ):
  95. dialog = xbmcgui.Dialog()
  96. yesno = dialog.yesno( "Area Code Error", "You need to re-select your location.", "Would you want to open Settings window?", "(Please refresh after re-selection.)")
  97. if ( yesno ):
  98. self.__settings__.openSettings()
  99. return
  100. self._noaa_36_forecast()
  101. self._noaa_hourly_forecast()
  102. # self._noaa_10day_forecast()
  103. self._noaa_weekend_forecast()
  104. for count in range( 1, 4 ):
  105. self._clear_map_list( count )
  106. # self.provider = 1
  107. # self._fetch_map_list()
  108. # Default provider (weather.com)
  109. else :
  110. self.WEATHER_WINDOW.setProperty( "Location", xbmc.getInfoLabel( "Weather.Location" ) )
  111. self._fetch_map_list()
  112. self._fetch_36_forecast()
  113. self._fetch_hourly_forecast()
  114. self._fetch_10day_forecast()
  115. self._fetch_weekend_forecast()
  116.  
  117. # we're finished, exit
  118. self._exit_script()
  119.  
  120. def _get_weather_window( self ):
  121. # grab the weather window
  122. self.WEATHER_WINDOW = xbmcgui.Window( 12600 )
  123.  
  124. def _set_plugin_name( self ):
  125. # set plugin name
  126. self.WEATHER_WINDOW.setProperty( "Plugin", sys.modules[ "__main__" ].__plugin__ )
  127.  
  128. def _get_client( self ):
  129. self.settings = { "translate": None, "accu_translate": "en-us" }
  130. if ( self.Settings.getSetting( "translate" ) == "true" ):
  131. self.settings[ "translate" ] = {
  132. "Chinese (Simple)": "en_zh",
  133. "Chinese (Traditional)": "en_zt",
  134. "Dutch": "en_nl",
  135. "French": "en_fr",
  136. "German": "en_de",
  137. "German (Austria)": "en_de",
  138. "Greek": "en_el",
  139. "Italian": "en_it",
  140. "Japanese": "en_ja",
  141. "Korean": "en_ko",
  142. "Portuguese": "en_pt",
  143. "Portuguese (Brazil)": "en_pt",
  144. "Russian": "en_ru",
  145. "Spanish": "en_es",
  146. "Spanish (Mexico)": "en_es",
  147. }.get( xbmc.getLanguage(), None )
  148.  
  149. self.settings[ "accu_translate" ] = {
  150. "2": "ca",
  151. "6": "cs",
  152. "7": "da",
  153. "13": "de",
  154. "28": "es-ar",
  155. "29": "es-mx",
  156. "1": "es",
  157. "11": "fr-ca",
  158. "12": "fr",
  159. "18": "it",
  160. "17": "hu",
  161. "8": "nl",
  162. "9": "en-us",
  163. "21": "no",
  164. "22": "pl",
  165. "23": "pt-br",
  166. "24": "pt",
  167. "25": "ro",
  168. "26": "ru",
  169. "30": "sv",
  170. "10": "fi",
  171. "27": "sk",
  172. "0": "ar",
  173. "3": "zh-cn",
  174. "4": "zh-tw",
  175. "5": "zh-hk",
  176. "31": "tr",
  177. "14": "el",
  178. "19": "ja",
  179. "20": "ko",
  180. "16": "hi",
  181. "15": "he"
  182. }.get( self.Settings.getSetting( "accu_translate" ), "en-us" )
  183.  
  184. if ( sys.argv[ 1 ].startswith( "map=" ) ):
  185. self.areacode = xbmc.getInfoLabel( "Window(Weather).Property(AreaCode)" )
  186. elif ( self.Settings.getSetting("location" + str(self.locationindex)) == "true" ):
  187. self.areacode = self.Settings.getSetting("alt_code" + str(self.locationindex))
  188. else:
  189. self.areacode = sys.argv[ 1 ]
  190. # set if new location
  191. self.new_location = ( xbmc.getInfoLabel( "Window(Weather).Property(Weather.AreaCode)" ) != self.areacode and self.Settings.getSetting("alt_code" + str(self.locationindex)) != self.areacode )
  192. # if new set it
  193. if ( self.new_location ):
  194. self.WEATHER_WINDOW.setProperty( "Weather.AreaCode", self.areacode )
  195. # setup our radar client
  196. self.WeatherClient = WeatherClient.WeatherClient( self.areacode, self.settings[ "translate" ], self.settings[ "accu_translate" ] )
  197.  
  198. def _set_maps_path( self, path=0, maps_path="", legend_path="" ):
  199. # we have three possibilities. loading, default (error) or the actual map path
  200. if ( path == 0 ):
  201. self.WEATHER_WINDOW.setProperty( "MapStatus", "loading" )
  202. self.WEATHER_WINDOW.setProperty( "MapPath", "weather.com plus/loading" )
  203. self.WEATHER_WINDOW.setProperty( "LegendPath", "" )
  204. elif ( path == 1 ):
  205. self.WEATHER_WINDOW.setProperty( "MapStatus", "loaded" )
  206. self.WEATHER_WINDOW.setProperty( "MapPath", maps_path )
  207. self.WEATHER_WINDOW.setProperty( "LegendPath", legend_path )
  208. elif ( path == 2 ):
  209. self.WEATHER_WINDOW.setProperty( "MapStatus", "error" )
  210. self.WEATHER_WINDOW.setProperty( "MapPath", "weather.com plus/error" )
  211. self.WEATHER_WINDOW.setProperty( "LegendPath", "" )
  212.  
  213. def _clear_properties( self ):
  214. # clear properties used for visibilty
  215. self.WEATHER_WINDOW.clearProperty( "Alerts" )
  216. self.WEATHER_WINDOW.setProperty( "Alerts.Color", "default" )
  217. self.WEATHER_WINDOW.clearProperty( "Video" )
  218. self.WEATHER_WINDOW.clearProperty( "36Hour.IsFetched" )
  219. self.WEATHER_WINDOW.clearProperty( "Weekend.IsFetched" )
  220. self.WEATHER_WINDOW.clearProperty( "Daily.IsFetched" )
  221. self.WEATHER_WINDOW.clearProperty( "Hourly.IsFetched" )
  222.  
  223. def _clear_map_list( self, list_id ):
  224. # enumerate thru and clear all map list labels, icons and onclicks
  225. for count in range( 1, 31 ):
  226. # these are what the user sees and the action the button performs
  227. self.WEATHER_WINDOW.clearProperty( "MapList.%d.MapLabel.%d" % ( list_id, count, ) )
  228. self.WEATHER_WINDOW.clearProperty( "MapList.%d.MapLabel2.%d" % ( list_id, count, ) )
  229. self.WEATHER_WINDOW.clearProperty( "MapList.%d.MapIcon.%d" % ( list_id, count, ) )
  230. self.WEATHER_WINDOW.clearProperty( "MapList.%d.MapOnclick.%d" % ( list_id, count, ) )
  231. # set the default titles
  232. self._set_map_list_titles( list_id )
  233.  
  234. def _set_map_list_titles( self, list_id, title=None, long_title=None ):
  235. # set map list titles for skinners buttons
  236. if ( title is None ):
  237. # non user defined list
  238. title = ( "", self._( 32800 + int( self.Settings.getSetting( "maplist%d" % ( list_id, ) ) ) ), )[ int( self.Settings.getSetting( "maplist%d" % ( list_id, ) ) ) > 0 ]
  239. long_title = self._( 32600 + int( self.Settings.getSetting( "maplist%d" % ( list_id, ) ) ) )
  240. # now set the titles
  241. self.WEATHER_WINDOW.setProperty( "MapList.%d.ShortTitle" % ( list_id, ), title )
  242. self.WEATHER_WINDOW.setProperty( "MapList.%d.LongTitle" % ( list_id, ), long_title )
  243.  
  244. def _fetch_map_list( self ):
  245. # exit script if user changed locations
  246. if ( self.areacode != xbmc.getInfoLabel( "Window(Weather).Property(AreaCode)" ) and self.areacode != self.Settings.getSetting("alt_code" + str(self.locationindex)) ):
  247. return
  248. # intialize our download variable, we use this so we don't re-download same info
  249. map_download = []
  250. # enumerate thru and clear our properties if map is different (if user changed setiings), local and user defined list should be downloaded if location changed
  251. for count in range( 1, 4 ):
  252. # do we need to download this list?
  253. map_download += [ ( self.new_location and int( self.Settings.getSetting( "maplist%d" % ( count, ) ) ) == 1 ) or
  254. ( self.new_location and int( self.Settings.getSetting( "maplist%d" % ( count, ) ) ) == len( self.WeatherClient.BASE_MAPS ) - 1 ) or
  255. ( self.WEATHER_WINDOW.getProperty( "MapList.%d.LongTitle" % ( count, ) ) != self._( 32600 + int( self.Settings.getSetting( "maplist%d" % ( count, ) ) ) ) ) ]
  256. # do we need to clear the info?
  257. if ( map_download[ count - 1 ] ):
  258. self._clear_map_list( count )
  259. # we set this here in case we do not need to download new lists
  260. current_map = self.WEATHER_WINDOW.getProperty( "Weather.CurrentMapUrl" )
  261. current_map_title = self.WEATHER_WINDOW.getProperty( "Weather.CurrentMap" )
  262. print "[Weather Plus] Current Map : " + current_map
  263. # only run if any new map lists
  264. if ( True ):
  265. # we set our maps path property to loading images while downloading
  266. self._set_maps_path()
  267. # set default map, we allow skinners to have users set this with a skin string
  268. # TODO: look at this, seems wrong, when changing locations maps can fail to load.
  269. default = ( self.WEATHER_WINDOW.getProperty( "Weather.CurrentMap" ), xbmc.getInfoLabel( "Skin.String(TWC.DefaultMap)" ), )[ xbmc.getInfoLabel( "Skin.String(TWC.DefaultMap)" ) != "" and self.WEATHER_WINDOW.getProperty( "Weather.CurrentMap" ) == "" ]
  270. # enumurate thru map lists and fetch map list
  271. for maplist_count in range( 1, 4 ):
  272. # only fetch new list if required
  273. # if ( not map_download[ maplist_count - 1 ] ):
  274. # continue
  275. # get the correct category
  276. # print self.provider, maplist_count
  277. if ( self.provider == "Default" ):
  278. map_category = int( self.Settings.getSetting( "maplist%d" % ( maplist_count, ) ) )
  279. elif ( self.provider == "1" and maplist_count == 1 ):
  280. map_category = 8
  281. # print "Accu Map!"
  282. # fetch map list
  283. category_title, maps = self.WeatherClient.fetch_map_list( self.provider, map_category, self.Settings.getSetting( "maplist_user_file" ), xbmc.getInfoLabel( "Window(Weather).Property(LocationIndex)" ) )
  284. # print maps
  285. # only run if maps were found
  286. if ( maps is None ):
  287. continue
  288. # set a current_map in case one isn't set
  289. if ( current_map == "" ):
  290. try:
  291. current_map = maps[ 0 ][ 0 ]
  292. current_map_title = maps[ 0 ][ 1 ]
  293. except:
  294. print "ERROR : Failed Fatching Maps of Category No."+map_category
  295. # if user defined map list set the new titles
  296. if ( category_title is not None ):
  297. self._set_map_list_titles( maplist_count, category_title, category_title )
  298. if ( self.provider == 1 and maplist_count == 1):
  299. self._set_map_list_titles( maplist_count, "Satellite", "Satellite" )
  300. # enumerate thru our map list and add map and title and check for default
  301. for count, map in enumerate( maps ):
  302. # create our label, icon and onclick event
  303. self.WEATHER_WINDOW.setProperty( "MapList.%d.MapLabel.%d" % ( maplist_count, count + 1, ), map[ 1 ] )
  304. self.WEATHER_WINDOW.setProperty( "MapList.%d.MapLabel2.%d" % ( maplist_count, count + 1, ), map[ 0 ] )
  305. self.WEATHER_WINDOW.setProperty( "MapList.%d.MapIcon.%d" % ( maplist_count, count + 1, ), map[ 1 ].replace( ":", " -" ).replace( "/", " - " ) + ".jpg" )
  306. self.WEATHER_WINDOW.setProperty( "MapList.%d.MapOnclick.%d" % ( maplist_count, count + 1, ), "XBMC.RunScript(%s,map=%s&title=%s&location=%s)" % ( sys.argv[ 0 ], map[ 0 ], map[ 1 ], str( map[ 2 ] ) ) )
  307. # if we have a match, set our class variable
  308. if ( map[ 1 ] == default ):
  309. current_map = map[ 0 ]
  310. current_map_title = map[ 1 ]
  311. # fetch the current map
  312. self._fetch_map( current_map, current_map_title, xbmc.getInfoLabel( "Window(Weather).Property(LocationIndex)" ) )
  313.  
  314. def _fetch_map( self, map, title, locationindex=None ):
  315. print "[Weather Plus] map = " + map
  316. print "[Weather Plus] title = " + title
  317. print "[Weather Plus] Locationindex = " + locationindex
  318. print "[Weather Plus] maplist_user_file = " + self.Settings.getSetting("maplist_user_file")
  319. # exit script if user changed locations
  320. if ( self.areacode != xbmc.getInfoLabel( "Window(Weather).Property(AreaCode)" ) ):
  321. return
  322. # we set our maps path property to loading images while downloading
  323. self._set_maps_path()
  324. # we set Weather.CurrentMap and Weather.CurrentMapUrl, the skin can handle it when the user selects a new map for immediate update
  325. self.WEATHER_WINDOW.setProperty( "Weather.CurrentMap", title )
  326. self.WEATHER_WINDOW.setProperty( "Weather.CurrentMapUrl", map )
  327. # fetch the available map urls
  328. maps = self.WeatherClient.fetch_map_urls( map, self.Settings.getSetting( "maplist_user_file" ), locationindex )
  329. # fetch the images
  330. maps_path, legend_path = self.WeatherClient.fetch_images( maps )
  331. # print "maps", maps
  332. # hack incase the weather in motion link was bogus
  333. if ( maps_path == "" and len( maps[ 1 ] ) ):
  334. maps_path, legend_path = self.WeatherClient.fetch_images( ( maps[ 0 ], [], maps[ 2 ], ) )
  335. # now set our window properties so multi image will display images 1==success, 2==failure
  336. self._set_maps_path( ( maps_path == "" ) + 1, maps_path, legend_path )
  337.  
  338. def _set_alerts( self, alerts, alertsrss, alertsnotify, alertscolor, alertscount ):
  339. try:
  340. alertscolor = {"1":"red", "2":"orange"}.get(alertscolor)
  341. except:
  342. alertscolor = ""
  343. # send notification if user preference and there are alerts
  344. if ( alerts != "" and ( int( self.Settings.getSetting( "alert_notify_type" ) ) == 1 or
  345. ( alertscolor == "red" and int( self.Settings.getSetting( "alert_notify_type" ) ) > 1 ) or
  346. ( alertscolor == "orange" and int( self.Settings.getSetting( "alert_notify_type" ) ) == 3 ) ) and
  347. ( self.Settings.getSetting( "alert_notify_once" ) == "false" or self.WEATHER_WINDOW.getProperty( "Alerts.RSS" ) != alertsrss )
  348. ):
  349. xbmc.executebuiltin( "XBMC.Notification(%s,\"%s\",%d,weather.com plus/alert-%s.png)" % ( self._( 32100 ), alertsnotify, ( 10, 20, 30, 45, 60, 120, 300, 600, )[ int( self.Settings.getSetting( "alert_notify_time" ) ) ] * 1000, alertscolor, ) )
  350. # set any alerts
  351. self.WEATHER_WINDOW.setProperty( "Alerts", alerts )
  352. self.WEATHER_WINDOW.setProperty( "Alerts.RSS", alertsrss )
  353. self.WEATHER_WINDOW.setProperty( "Alerts.Color", ( "default", alertscolor, )[ alerts != "" ] )
  354. self.WEATHER_WINDOW.setProperty( "Alerts.Count", ( "", str( alertscount ), )[ alertscount > 1 ] )
  355. self.WEATHER_WINDOW.setProperty( "Alerts.Label", xbmc.getLocalizedString( 33049 + ( alertscount > 1 ) ) )
  356.  
  357. def _set_video( self, video_url, video_title ):
  358. self.WEATHER_WINDOW.setProperty( "Video", video_url[0] )
  359. self.WEATHER_WINDOW.setProperty( "Video.1", video_url[0] )
  360. self.WEATHER_WINDOW.setProperty( "Video.1.Title", video_title[0] )
  361. self.WEATHER_WINDOW.setProperty( "Video.2", video_url[1] )
  362. self.WEATHER_WINDOW.setProperty( "Video.2.Title", video_title[1] )
  363. self.WEATHER_WINDOW.setProperty( "Video.3", video_url[2] )
  364. self.WEATHER_WINDOW.setProperty( "Video.3.Title", video_title[2] )
  365. # self.WEATHER_WINDOW.setProperty( "Video.regional", video_url )
  366. # self.WEATHER_WINDOW.setProperty( "Video.local", video_local_url )
  367. # print "[Weather Plus] Video_type = " + self.Settings.getSetting("video_type")
  368. # print "[Weather Plus] Video_url = " + video_url
  369. # print "[Weather Plus] Video_local_url = " + video_local_url
  370. print "[Weather Plus] Selected Weather Video = "+self.WEATHER_WINDOW.getProperty ("Video")
  371.  
  372. def _set_extra_current_info( self, extras ):
  373. if ( extras ):
  374. self.WEATHER_WINDOW.setProperty( "Current.Pressure", extras[ 0 ][0] )
  375. if ( extras[0][1] != "N/A" ) :
  376. try:
  377. self.WEATHER_WINDOW.setProperty( "Current.Visibility", "%s %s" % ( extras[ 0 ][1].split( " " )[ 0 ], { "mile": self._( 32300 ), "miles": self._( 32301 ), "kilometer": self._( 32302 ), "kilometers": self._( 32303 ) }[ extras[ 0 ][1].split( " " )[ 1 ] ], ) )
  378. except:
  379. self.WEATHER_WINDOW.setProperty( "Current.Visibility", extras[ 0 ][ 1 ])
  380. else:
  381. self.WEATHER_WINDOW.setProperty( "Current.Visibility", extras[ 0 ][ 1 ])
  382. self.WEATHER_WINDOW.setProperty( "Current.Sunrise", extras[ 0 ][ 2 ] )
  383. self.WEATHER_WINDOW.setProperty( "Current.Sunset", extras[ 0 ][ 3 ])
  384. # print self.WEATHER_WINDOW.getProperty( "Current.Pressure" )
  385. else:
  386. self.WEATHER_WINDOW.clearProperty( "Current.Pressure" )
  387. self.WEATHER_WINDOW.clearProperty( "Current.Visibility" )
  388. self.WEATHER_WINDOW.clearProperty( "Current.Sunrise" )
  389. self.WEATHER_WINDOW.clearProperty( "Current.Sunset" )
  390.  
  391. def _fetch_36_forecast( self, showView=True ):
  392. # exit script if user changed locations
  393. if ( self.areacode != xbmc.getInfoLabel( "Window(Weather).Property(AreaCode)" ) ):
  394. return
  395. # fetch 36 hour forecast
  396. alerts, alertsrss, alertsnotify, alertscolor, alertscount, forecasts, extras, video, video_title = self.WeatherClient.fetch_36_forecast( self.WEATHER_WINDOW.getProperty( "Video" ) )
  397. # set any alerts
  398. self._set_alerts( alerts, alertsrss, alertsnotify, alertscolor, alertscount )
  399. # set video
  400. self._set_video( video, video_title )
  401. # set extra info
  402. self._set_extra_current_info( extras )
  403. # enumerate thru and set the info
  404. for day, forecast in enumerate( forecasts ):
  405. self.WEATHER_WINDOW.setProperty( "36Hour.%d.OutlookIcon" % ( day + 1, ), forecast[ 1 ] )
  406. self.WEATHER_WINDOW.setProperty( "36Hour.%d.FanartCode" % ( day + 1, ), os.path.splitext( os.path.basename( forecast[ 1 ] ) )[ 0 ] )
  407. self.WEATHER_WINDOW.setProperty( "36Hour.%d.Outlook" % ( day + 1, ), forecast[ 2 ] )
  408. self.WEATHER_WINDOW.setProperty( "36Hour.%d.TemperatureColor" % ( day + 1, ), forecast[ 3 ].lower() )
  409. self.WEATHER_WINDOW.setProperty( "36Hour.%d.TemperatureHeading" % ( day + 1, ), ( xbmc.getLocalizedString( 393 ), xbmc.getLocalizedString( 391 ), )[ forecast[ 3 ] == "Low" ] )
  410. self.WEATHER_WINDOW.setProperty( "36Hour.%d.Temperature" % ( day + 1, ), forecast[ 4 ] )
  411. self.WEATHER_WINDOW.setProperty( "36Hour.%d.Precipitation" % ( day + 1, ), forecast[ 6 ] )
  412. self.WEATHER_WINDOW.setProperty( "36Hour.%d.Forecast" % ( day + 1, ), forecast[ 7 ] )
  413. self.WEATHER_WINDOW.setProperty( "36Hour.%d.DaylightTitle" % ( day + 1, ), forecast[ 8 ].replace( "Sunrise", xbmc.getLocalizedString( 33027 ) ).replace( "Sunset", xbmc.getLocalizedString( 33028 ) ) )
  414. self.WEATHER_WINDOW.setProperty( "36Hour.%d.DaylightTime" % ( day + 1, ), forecast[ 9 ] )
  415. self.WEATHER_WINDOW.setProperty( "36Hour.%d.DaylightType" % ( day + 1, ), ( "sunrise", "sunset", )[ forecast[ 8 ] == "Sunset" ] )
  416. self.WEATHER_WINDOW.setProperty( "36Hour.%d.Heading" % ( day + 1, ), { "Today": xbmc.getLocalizedString( 33006 ), "Tonight": xbmc.getLocalizedString( 33018 ), "Tomorrow": xbmc.getLocalizedString( 33007 ), "Tomorrow Night": xbmc.getLocalizedString( 33019 ) }[ forecast[ 0 ] ] )
  417. # use this to hide info until fully fetched
  418. self.WEATHER_WINDOW.setProperty( "36Hour.IsFetched", "true" )
  419.  
  420. def _fetch_hourly_forecast( self ):
  421. # exit script if user changed locations
  422. if ( self.areacode != xbmc.getInfoLabel( "Window(Weather).Property(AreaCode)" ) ):
  423. return
  424. # fetch hourly forecast
  425. forecasts = self.WeatherClient.fetch_hourly_forecast()
  426. # localized long and short date dictionary
  427. longdate_dict = { "January": xbmc.getLocalizedString( 21 ), "February": xbmc.getLocalizedString( 22 ), "March": xbmc.getLocalizedString( 23 ), "April": xbmc.getLocalizedString( 24 ), "May": xbmc.getLocalizedString( 25 ), "June": xbmc.getLocalizedString( 26 ), "July": xbmc.getLocalizedString( 27 ), "August": xbmc.getLocalizedString( 28 ), "September": xbmc.getLocalizedString( 29 ), "October": xbmc.getLocalizedString( 30 ), "November": xbmc.getLocalizedString( 31 ), "December": xbmc.getLocalizedString( 32 ) }
  428. shortdate_dict = { "January": xbmc.getLocalizedString( 51 ), "February": xbmc.getLocalizedString( 52 ), "March": xbmc.getLocalizedString( 53 ), "April": xbmc.getLocalizedString( 54 ), "May": xbmc.getLocalizedString( 55 ), "June": xbmc.getLocalizedString( 56 ), "July": xbmc.getLocalizedString( 57 ), "August": xbmc.getLocalizedString( 58 ), "September": xbmc.getLocalizedString( 59 ), "October": xbmc.getLocalizedString( 60 ), "November": xbmc.getLocalizedString( 61 ), "December": xbmc.getLocalizedString( 62 ) }
  429. # enumerate thru and set the info
  430. for count, forecast in enumerate( forecasts ):
  431. # set properties
  432. self.WEATHER_WINDOW.setProperty( "Hourly.%d.Time" % ( count + 1, ), forecast[ 0 ] )
  433. self.WEATHER_WINDOW.setProperty( "Hourly.%d.LongDate" % ( count + 1, ), "%s %s" % ( longdate_dict.get( forecast[ 1 ].split( " " )[ 0 ], "" ), forecast[ 1 ].split( " " )[ -1 ], ) )
  434. self.WEATHER_WINDOW.setProperty( "Hourly.%d.ShortDate" % ( count + 1, ), "%s %s" % ( shortdate_dict.get( forecast[ 1 ].split( " " )[ 0 ], "" ), forecast[ 1 ].split( " " )[ -1 ], ) )
  435. self.WEATHER_WINDOW.setProperty( "Hourly.%d.OutlookIcon" % ( count + 1, ), forecast[ 2 ] )
  436. self.WEATHER_WINDOW.setProperty( "Hourly.%d.FanartCode" % ( count + 1, ), os.path.splitext( os.path.basename( forecast[ 2 ] ) )[ 0 ] )
  437. self.WEATHER_WINDOW.setProperty( "Hourly.%d.Temperature" % ( count + 1, ), forecast[ 3 ] )
  438. self.WEATHER_WINDOW.setProperty( "Hourly.%d.Outlook" % ( count + 1, ), forecast[ 4 ] )
  439. self.WEATHER_WINDOW.setProperty( "Hourly.%d.FeelsLike" % ( count + 1, ), forecast[ 5 ] )
  440. self.WEATHER_WINDOW.setProperty( "Hourly.%d.Precipitation" % ( count + 1, ), forecast[ 6 ] )
  441. self.WEATHER_WINDOW.setProperty( "Hourly.%d.Humidity" % ( count + 1, ), forecast[ 7 ] )
  442. self.WEATHER_WINDOW.setProperty( "Hourly.%d.WindDirection" % ( count + 1, ), forecast[ 8 ] )
  443. self.WEATHER_WINDOW.setProperty( "Hourly.%d.WindSpeed" % ( count + 1, ), forecast[ 9 ] )
  444. self.WEATHER_WINDOW.setProperty( "Hourly.%d.ShortWindDirection" % ( count + 1, ), forecast[ 10 ] )
  445. self.WEATHER_WINDOW.setProperty( "Hourly.%d.Sunrise" % ( count + 1, ), forecast[ 11 ] )
  446. self.WEATHER_WINDOW.setProperty( "Hourly.%d.Sunset" % ( count + 1, ), forecast[ 12 ] )
  447. # enumerate thru and clear all hourly times
  448. for count in range( len( forecasts ), 12 ):
  449. # clear any remaining hourly times as some locals do not have all of them
  450. self.WEATHER_WINDOW.clearProperty( "Hourly.%d.Time" % ( count + 1, ) )
  451. # use this to hide info until fully fetched
  452. self.WEATHER_WINDOW.setProperty( "Hourly.IsFetched", "true" )
  453.  
  454. def _fetch_weekend_forecast( self ):
  455. # exit script if user changed locations
  456. if ( self.areacode != xbmc.getInfoLabel( "Window(Weather).Property(AreaCode)" ) ):
  457. return
  458. # fetch weekend forecast
  459. forecasts = self.WeatherClient.fetch_weekend_forecast()
  460. # enumerate thru and set the info
  461. for day, forecast in enumerate( forecasts ):
  462. self.WEATHER_WINDOW.setProperty( "Weekend.%d.OutlookIcon" % ( day + 1, ), forecast[ 2 ] )
  463. self.WEATHER_WINDOW.setProperty( "Weekend.%d.FanartCode" % ( day + 1, ), os.path.splitext( os.path.basename( forecast[ 2 ] ) )[ 0 ] )
  464. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Outlook" % ( day + 1, ), forecast[ 3 ] )
  465. self.WEATHER_WINDOW.setProperty( "Weekend.%d.HighTemperature" % ( day + 1, ), forecast[ 5 ] )
  466. self.WEATHER_WINDOW.setProperty( "Weekend.%d.LowTemperature" % ( day + 1, ), forecast[ 7 ] )
  467. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Precipitation" % ( day + 1, ), forecast[ 9 ] )
  468. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Wind" % ( day + 1, ), forecast[ 11 ] )
  469. self.WEATHER_WINDOW.setProperty( "Weekend.%d.UV" % ( day + 1, ), forecast[ 13 ] )
  470. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Humidity" % ( day + 1, ), forecast[ 15 ] )
  471. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Sunrise" % ( day + 1, ), forecast[ 17 ] )
  472. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Sunset" % ( day + 1, ), forecast[ 19 ] )
  473. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Forecast" % ( day + 1, ), forecast[ 20 ] )
  474. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Observed" % ( day + 1, ), forecast[ 21 ] )
  475. self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedPrecipitation" % ( day + 1, ), forecast[ 23 ] )
  476. self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedAvgHighTemperature" % ( day + 1, ), forecast[ 25 ] )
  477. self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedAvgLowTemperature" % ( day + 1, ), forecast[ 27 ] )
  478. self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedRecordHighTemperature" % ( day + 1, ), forecast[ 29 ] )
  479. self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedRecordLowTemperature" % ( day + 1, ), forecast[ 31 ] )
  480. self.WEATHER_WINDOW.setProperty( "Weekend.%d.DepartureHigh" % ( day + 1, ), forecast[ 33 ] )
  481. self.WEATHER_WINDOW.setProperty( "Weekend.%d.DepartureHighColor" % ( day + 1, ), ( "low", "high", "default", )[ ( len( forecast[ 33 ] ) and forecast[ 33 ][ 0 ] == "+" ) + ( forecast[ 33 ] == "+0" ) ] )
  482. self.WEATHER_WINDOW.setProperty( "Weekend.%d.DepartureLow" % ( day + 1, ), forecast[ 34 ] )
  483. self.WEATHER_WINDOW.setProperty( "Weekend.%d.DepartureLowColor" % ( day + 1, ), ( "low", "high", "default", )[ ( len( forecast[ 34 ] ) and forecast[ 34 ][ 0 ] == "+" ) + ( forecast[ 34 ] == "+0" ) ] )
  484. # do this last so skin's visibilty works better
  485. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Date" % ( day + 1, ), forecast[ 1 ] )
  486. # use this to hide info until fully fetched
  487. self.WEATHER_WINDOW.setProperty( "Weekend.IsFetched", "true" )
  488.  
  489. def _fetch_10day_forecast( self ):
  490. # exit script if user changed locations
  491. if ( self.areacode != xbmc.getInfoLabel( "Window(Weather).Property(AreaCode)" ) ):
  492. return
  493. # fetch daily forecast
  494. forecasts = self.WeatherClient.fetch_10day_forecast()
  495. # localized long and short day dictionary
  496. longday_dict = { "Mon": xbmc.getLocalizedString( 11 ), "Tue": xbmc.getLocalizedString( 12 ), "Wed": xbmc.getLocalizedString( 13 ), "Thu": xbmc.getLocalizedString( 14 ), "Fri": xbmc.getLocalizedString( 15 ), "Sat": xbmc.getLocalizedString( 16 ), "Sun": xbmc.getLocalizedString( 17 ), "Today": xbmc.getLocalizedString( 33006 ), "Tonight": xbmc.getLocalizedString( 33018 ), "N/A": "N/A" }
  497. shortday_dict = { "Mon": xbmc.getLocalizedString( 41 ), "Tue": xbmc.getLocalizedString( 42 ), "Wed": xbmc.getLocalizedString( 43 ), "Thu": xbmc.getLocalizedString( 44 ), "Fri": xbmc.getLocalizedString( 45 ), "Sat": xbmc.getLocalizedString( 46 ), "Sun": xbmc.getLocalizedString( 47 ), "Today": xbmc.getLocalizedString( 33006 ), "Tonight": xbmc.getLocalizedString( 33018 ), "N/A": "N/A" }
  498. # localized long and short date dictionary
  499. longdate_dict = { "Jan": xbmc.getLocalizedString( 21 ), "Feb": xbmc.getLocalizedString( 22 ), "Mar": xbmc.getLocalizedString( 23 ), "Apr": xbmc.getLocalizedString( 24 ), "May": xbmc.getLocalizedString( 25 ), "Jun": xbmc.getLocalizedString( 26 ), "Jul": xbmc.getLocalizedString( 27 ), "Aug": xbmc.getLocalizedString( 28 ), "Sep": xbmc.getLocalizedString( 29 ), "Oct": xbmc.getLocalizedString( 30 ), "Nov": xbmc.getLocalizedString( 31 ), "Dec": xbmc.getLocalizedString( 32 ), "N/A": "" }
  500. shortdate_dict = { "Jan": xbmc.getLocalizedString( 51 ), "Feb": xbmc.getLocalizedString( 52 ), "Mar": xbmc.getLocalizedString( 53 ), "Apr": xbmc.getLocalizedString( 54 ), "May": xbmc.getLocalizedString( 55 ), "Jun": xbmc.getLocalizedString( 56 ), "Jul": xbmc.getLocalizedString( 57 ), "Aug": xbmc.getLocalizedString( 58 ), "Sep": xbmc.getLocalizedString( 59 ), "Oct": xbmc.getLocalizedString( 60 ), "Nov": xbmc.getLocalizedString( 61 ), "Dec": xbmc.getLocalizedString( 62 ), "N/A": "" }
  501. # enumerate thru and set the info
  502. for count, forecast in enumerate( forecasts ):
  503. self.WEATHER_WINDOW.setProperty( "Daily.%d.LongDay" % ( count + 1, ), longday_dict[ forecast[ 0 ] ] )
  504. self.WEATHER_WINDOW.setProperty( "Daily.%d.ShortDay" % ( count + 1, ), shortday_dict[ forecast[ 0 ] ] )
  505. self.WEATHER_WINDOW.setProperty( "Daily.%d.LongDate" % ( count + 1, ), "%s %s" % ( longdate_dict[ forecast[ 1 ].split( " " )[ 0 ] ], forecast[ 1 ].split( " " )[ 1 ], ) )
  506. self.WEATHER_WINDOW.setProperty( "Daily.%d.ShortDate" % ( count + 1, ), "%s %s" % ( shortdate_dict[ forecast[ 1 ].split( " " )[ 0 ] ], forecast[ 1 ].split( " " )[ 1 ], ) )
  507. self.WEATHER_WINDOW.setProperty( "Daily.%d.OutlookIcon" % ( count + 1, ), forecast[ 2 ] )
  508. self.WEATHER_WINDOW.setProperty( "Daily.%d.FanartCode" % ( count + 1, ), os.path.splitext( os.path.basename( forecast[ 2 ] ) )[ 0 ] )
  509. self.WEATHER_WINDOW.setProperty( "Daily.%d.Outlook" % ( count + 1, ), forecast[ 3 ] )
  510. self.WEATHER_WINDOW.setProperty( "Daily.%d.HighTemperature" % ( count + 1, ), forecast[ 4 ] )
  511. self.WEATHER_WINDOW.setProperty( "Daily.%d.LowTemperature" % ( count + 1, ), forecast[ 5 ] )
  512. self.WEATHER_WINDOW.setProperty( "Daily.%d.Precipitation" % ( count + 1, ), forecast[ 6 ] )
  513. self.WEATHER_WINDOW.setProperty( "Daily.%d.WindDirection" % ( count + 1, ), forecast[ 7 ] )
  514. self.WEATHER_WINDOW.setProperty( "Daily.%d.WindSpeed" % ( count + 1, ), forecast[ 8 ] )
  515. self.WEATHER_WINDOW.setProperty( "Daily.%d.ShortWindDirection" % ( count + 1, ), forecast[ 9 ] )
  516. # just in case day 10 is missing
  517. for count in range( len( forecasts ), 10 ):
  518. self.WEATHER_WINDOW.clearProperty( "Daily.%d.ShortDay" % ( count + 1, ) )
  519. self.WEATHER_WINDOW.clearProperty( "Daily.%d.LongDay" % ( count + 1, ) )
  520. # use this to hide info until fully fetched
  521. self.WEATHER_WINDOW.setProperty( "Daily.IsFetched", "true" )
  522.  
  523. def _accu_36_forecast( self ):
  524. # exit script if user changed locations
  525. if ( self.areacode != self.Settings.getSetting("alt_code" + str(self.locationindex)) ):
  526. return
  527. # fetch 36 hour forecast
  528. alerts, alertsrss, alertsnotify, alertscolor, alertscount, forecasts, extras, video, video_local = self.WeatherClient.accu_36_forecast("")
  529. # set current info
  530. self.WEATHER_WINDOW.setProperty( "Current.Temperature", extras[0][4] )
  531. print "Current.Temperature", extras[0][4]
  532. self.WEATHER_WINDOW.setProperty( "Current.FeelsLike", extras[0][5] )
  533. self.WEATHER_WINDOW.setProperty( "Current.Condition", extras[0][6] )
  534. # Ido added missing
  535. self.WEATHER_WINDOW.setProperty( "Current.FanartCode", os.path.splitext( os.path.basename( extras[0][10] ) )[ 0 ] )
  536. print "Current.FanartCode", os.path.splitext( os.path.basename( extras[0][10] ) ) [ 0 ]
  537. self.WEATHER_WINDOW.setProperty( "Current.Wind", extras[0][7] )
  538. self.WEATHER_WINDOW.setProperty( "Current.Humidity", extras[0][8] )
  539. self.WEATHER_WINDOW.setProperty( "Current.DewPoint", extras[0][9] )
  540. self.WEATHER_WINDOW.setProperty( "Current.UVIndex", "N/A" )
  541. self.WEATHER_WINDOW.setProperty( "Current.ConditionIcon", extras[0][10] )
  542. # set any alerts
  543. self._set_alerts( alerts, alertsrss, alertsnotify, alertscolor, alertscount )
  544. # set video
  545. self._set_video( video, video_local )
  546. # set extra info
  547. self._set_extra_current_info( extras )
  548. # enumerate thru and set the info
  549. for day, forecast in enumerate( forecasts ):
  550. self.WEATHER_WINDOW.setProperty( "36Hour.%d.OutlookIcon" % ( day + 1, ), forecast[ 1 ] )
  551. self.WEATHER_WINDOW.setProperty( "36Hour.%d.FanartCode" % ( day + 1, ), os.path.splitext( os.path.basename( forecast[ 1 ] ) )[ 0 ] )
  552. self.WEATHER_WINDOW.setProperty( "36Hour.%d.Outlook" % ( day + 1, ), forecast[ 2 ] )
  553. self.WEATHER_WINDOW.setProperty( "36Hour.%d.TemperatureColor" % ( day + 1, ), forecast[ 3 ].lower() )
  554. self.WEATHER_WINDOW.setProperty( "36Hour.%d.TemperatureHeading" % ( day + 1, ), ( xbmc.getLocalizedString( 393 ), xbmc.getLocalizedString( 391 ), )[ forecast[ 3 ] == "Low" ] )
  555. self.WEATHER_WINDOW.setProperty( "36Hour.%d.Temperature" % ( day + 1, ), forecast[ 4 ] )
  556. self.WEATHER_WINDOW.setProperty( "36Hour.%d.Precipitation" % ( day + 1, ), forecast[ 6 ] )
  557. self.WEATHER_WINDOW.setProperty( "36Hour.%d.Forecast" % ( day + 1, ), forecast[ 7 ] )
  558. self.WEATHER_WINDOW.setProperty( "36Hour.%d.DaylightTitle" % ( day + 1, ), forecast[ 8 ].replace( "Sunrise", xbmc.getLocalizedString( 33027 ) ).replace( "Sunset", xbmc.getLocalizedString( 33028 ) ) )
  559. self.WEATHER_WINDOW.setProperty( "36Hour.%d.DaylightTime" % ( day + 1, ), forecast[ 9 ] )
  560. self.WEATHER_WINDOW.setProperty( "36Hour.%d.DaylightType" % ( day + 1, ), ( "sunrise", "sunset", )[ forecast[ 8 ] == "Sunset" ] )
  561. self.WEATHER_WINDOW.setProperty( "36Hour.%d.Heading" % ( day + 1, ), { "Today": xbmc.getLocalizedString( 33006 ), "Tonight": xbmc.getLocalizedString( 33018 ), "Tomorrow": xbmc.getLocalizedString( 33007 ), "Tomorrow Night": xbmc.getLocalizedString( 33019 ) }[ forecast[ 0 ] ] )
  562. # use this to hide info until fully fetched
  563. self.WEATHER_WINDOW.setProperty( "36Hour.IsFetched", "true" )
  564.  
  565. def _accu_hourly_forecast( self ):
  566. # exit script if user changed locations
  567. if ( self.areacode != self.Settings.getSetting("alt_code" + str(self.locationindex)) ):
  568. return
  569. # fetch hourly forecast
  570. forecasts = self.WeatherClient.accu_fetch_hourly_forecast()
  571. # localized long and short date dictionary
  572. longdate_dict = { "1": xbmc.getLocalizedString( 21 ), "2": xbmc.getLocalizedString( 22 ), "3": xbmc.getLocalizedString( 23 ), "4": xbmc.getLocalizedString( 24 ), "5": xbmc.getLocalizedString( 25 ), "6": xbmc.getLocalizedString( 26 ), "7": xbmc.getLocalizedString( 27 ), "8": xbmc.getLocalizedString( 28 ), "9": xbmc.getLocalizedString( 29 ), "10": xbmc.getLocalizedString( 30 ), "11": xbmc.getLocalizedString( 31 ), "12": xbmc.getLocalizedString( 32 ) }
  573. shortdate_dict = { "1": xbmc.getLocalizedString( 51 ), "2": xbmc.getLocalizedString( 52 ), "3": xbmc.getLocalizedString( 53 ), "4": xbmc.getLocalizedString( 54 ), "5": xbmc.getLocalizedString( 55 ), "6": xbmc.getLocalizedString( 56 ), "7": xbmc.getLocalizedString( 57 ), "8": xbmc.getLocalizedString( 58 ), "9": xbmc.getLocalizedString( 59 ), "10": xbmc.getLocalizedString( 60 ), "11": xbmc.getLocalizedString( 61 ), "12": xbmc.getLocalizedString( 62 ) }
  574. # enumerate thru and set the info
  575. for count, forecast in enumerate( forecasts ):
  576. # set properties
  577. self.WEATHER_WINDOW.setProperty( "Hourly.%d.Time" % ( count + 1, ), forecast[ 0 ] )
  578. self.WEATHER_WINDOW.setProperty( "Hourly.%d.LongDate" % ( count + 1, ), "%s %s" % ( longdate_dict.get( forecast[ 1 ].split( " " )[ 0 ], "" ), forecast[ 1 ].split( " " )[ -1 ], ) )
  579. self.WEATHER_WINDOW.setProperty( "Hourly.%d.ShortDate" % ( count + 1, ), "%s %s" % ( shortdate_dict.get( forecast[ 1 ].split( " " )[ 0 ], "" ), forecast[ 1 ].split( " " )[ -1 ], ) )
  580. self.WEATHER_WINDOW.setProperty( "Hourly.%d.OutlookIcon" % ( count + 1, ), forecast[ 2 ] )
  581. self.WEATHER_WINDOW.setProperty( "Hourly.%d.FanartCode" % ( count + 1, ), os.path.splitext( os.path.basename( forecast[ 2 ] ) )[ 0 ] )
  582. self.WEATHER_WINDOW.setProperty( "Hourly.%d.Temperature" % ( count + 1, ), forecast[ 3 ] )
  583. self.WEATHER_WINDOW.setProperty( "Hourly.%d.Outlook" % ( count + 1, ), forecast[ 4 ] )
  584. self.WEATHER_WINDOW.setProperty( "Hourly.%d.FeelsLike" % ( count + 1, ), forecast[ 5 ] )
  585. self.WEATHER_WINDOW.setProperty( "Hourly.%d.Precipitation" % ( count + 1, ), forecast[ 6 ] )
  586. self.WEATHER_WINDOW.setProperty( "Hourly.%d.Humidity" % ( count + 1, ), forecast[ 7 ] )
  587. self.WEATHER_WINDOW.setProperty( "Hourly.%d.WindDirection" % ( count + 1, ), forecast[ 8 ] )
  588. self.WEATHER_WINDOW.setProperty( "Hourly.%d.WindSpeed" % ( count + 1, ), forecast[ 9 ] )
  589. self.WEATHER_WINDOW.setProperty( "Hourly.%d.ShortWindDirection" % ( count + 1, ), forecast[ 10 ] )
  590. self.WEATHER_WINDOW.setProperty( "Hourly.%d.Sunrise" % ( count + 1, ), forecast[ 11 ] )
  591. self.WEATHER_WINDOW.setProperty( "Hourly.%d.Sunset" % ( count + 1, ), forecast[ 12 ] )
  592. # enumerate thru and clear all hourly times
  593. for count in range( len( forecasts ), 12 ):
  594. # clear any remaining hourly times as some locals do not have all of them
  595. self.WEATHER_WINDOW.clearProperty( "Hourly.%d.Time" % ( count + 1, ) )
  596. # use this to hide info until fully fetched
  597. self.WEATHER_WINDOW.setProperty( "Hourly.IsFetched", "true" )
  598.  
  599. def _accu_weekend_forecast( self ):
  600. # exit script if user changed locations
  601. if ( self.areacode != xbmc.getInfoLabel( "Window(Weather).Property(AreaCode)" ) ):
  602. return
  603. # fetch weekend forecast
  604. forecasts = self.WeatherClient.accu_weekend_forecast()
  605. # enumerate thru and set the info
  606. for day, forecast in enumerate( forecasts ):
  607. self.WEATHER_WINDOW.setProperty( "Weekend.%d.OutlookIcon" % ( day + 1, ), forecast[ 2 ] )
  608. self.WEATHER_WINDOW.setProperty( "Weekend.%d.FanartCode" % ( day + 1, ), os.path.splitext( os.path.basename( forecast[ 2 ] ) )[ 0 ] )
  609. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Outlook" % ( day + 1, ), forecast[ 3 ] )
  610. self.WEATHER_WINDOW.setProperty( "Weekend.%d.HighTemperature" % ( day + 1, ), forecast[ 5 ] )
  611. self.WEATHER_WINDOW.setProperty( "Weekend.%d.LowTemperature" % ( day + 1, ), forecast[ 7 ] )
  612. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Precipitation" % ( day + 1, ), forecast[ 9 ] )
  613. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Wind" % ( day + 1, ), forecast[ 11 ] )
  614. self.WEATHER_WINDOW.setProperty( "Weekend.%d.UV" % ( day + 1, ), forecast[ 13 ] )
  615. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Humidity" % ( day + 1, ), forecast[ 15 ] )
  616. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Sunrise" % ( day + 1, ), forecast[ 17 ] )
  617. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Sunset" % ( day + 1, ), forecast[ 19 ] )
  618. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Forecast" % ( day + 1, ), forecast[ 20 ] )
  619. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Observed" % ( day + 1, ), forecast[ 21 ] )
  620. self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedPrecipitation" % ( day + 1, ), forecast[ 23 ] )
  621. self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedAvgHighTemperature" % ( day + 1, ), forecast[ 25 ] )
  622. self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedAvgLowTemperature" % ( day + 1, ), forecast[ 27 ] )
  623. self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedRecordHighTemperature" % ( day + 1, ), forecast[ 29 ] )
  624. self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedRecordLowTemperature" % ( day + 1, ), forecast[ 31 ] )
  625. self.WEATHER_WINDOW.setProperty( "Weekend.%d.DepartureHigh" % ( day + 1, ), forecast[ 33 ] )
  626. self.WEATHER_WINDOW.setProperty( "Weekend.%d.DepartureHighColor" % ( day + 1, ), ( "low", "high", "default", )[ ( len( forecast[ 33 ] ) and forecast[ 33 ][ 0 ] == "+" ) + ( forecast[ 33 ] == "+0" ) ] )
  627. self.WEATHER_WINDOW.setProperty( "Weekend.%d.DepartureLow" % ( day + 1, ), forecast[ 34 ] )
  628. self.WEATHER_WINDOW.setProperty( "Weekend.%d.DepartureLowColor" % ( day + 1, ), ( "low", "high", "default", )[ ( len( forecast[ 34 ] ) and forecast[ 34 ][ 0 ] == "+" ) + ( forecast[ 34 ] == "+0" ) ] )
  629. # do this last so skin's visibilty works better
  630. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Date" % ( day + 1, ), forecast[ 1 ] )
  631. # use this to hide info until fully fetched
  632. self.WEATHER_WINDOW.setProperty( "Weekend.IsFetched", "true" )
  633.  
  634. def _accu_10day_forecast( self ):
  635. # exit script if user changed locations
  636. if ( self.areacode != self.Settings.getSetting("alt_code" + str(self.locationindex)) ):
  637. return
  638. # fetch daily forecast
  639. forecasts = self.WeatherClient.accu_fetch_10day_forecast()
  640. print forecasts
  641. # localized long and short day dictionary
  642. longday_dict = { "Monday": xbmc.getLocalizedString( 11 ), "Tuesday": xbmc.getLocalizedString( 12 ), "Wednesday": xbmc.getLocalizedString( 13 ), "Thursday": xbmc.getLocalizedString( 14 ), "Friday": xbmc.getLocalizedString( 15 ), "Saturday": xbmc.getLocalizedString( 16 ), "Sunday": xbmc.getLocalizedString( 17 ), "Today": xbmc.getLocalizedString( 33006 ), "Tonight": xbmc.getLocalizedString( 33018 ) }
  643. shortday_dict = { "Monday": xbmc.getLocalizedString( 41 ), "Tuesday": xbmc.getLocalizedString( 42 ), "Wednesday": xbmc.getLocalizedString( 43 ), "Thursday": xbmc.getLocalizedString( 44 ), "Friday": xbmc.getLocalizedString( 45 ), "Saturday": xbmc.getLocalizedString( 46 ), "Sunday": xbmc.getLocalizedString( 47 ), "Today": xbmc.getLocalizedString( 33006 ), "Tonight": xbmc.getLocalizedString( 33018 ) }
  644. # localized long and short date dictionary
  645. longdate_dict = { "1": xbmc.getLocalizedString( 21 ), "2": xbmc.getLocalizedString( 22 ), "3": xbmc.getLocalizedString( 23 ), "4": xbmc.getLocalizedString( 24 ), "5": xbmc.getLocalizedString( 25 ), "6": xbmc.getLocalizedString( 26 ), "7": xbmc.getLocalizedString( 27 ), "8": xbmc.getLocalizedString( 28 ), "9": xbmc.getLocalizedString( 29 ), "10": xbmc.getLocalizedString( 30 ), "11": xbmc.getLocalizedString( 31 ), "12": xbmc.getLocalizedString( 32 ) }
  646. shortdate_dict = { "1": xbmc.getLocalizedString( 51 ), "2": xbmc.getLocalizedString( 52 ), "3": xbmc.getLocalizedString( 53 ), "4": xbmc.getLocalizedString( 54 ), "5": xbmc.getLocalizedString( 55 ), "6": xbmc.getLocalizedString( 56 ), "7": xbmc.getLocalizedString( 57 ), "8": xbmc.getLocalizedString( 58 ), "9": xbmc.getLocalizedString( 59 ), "10": xbmc.getLocalizedString( 60 ), "11": xbmc.getLocalizedString( 61 ), "12": xbmc.getLocalizedString( 62 ) }
  647. # enumerate thru and set the info
  648. weekend_count = 0
  649. weekend = 0
  650. for count in range(1,4):
  651. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.OutlookIcon" % ( count, ) )
  652. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.FanartCode" % ( count, ) )
  653. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Outlook" % ( count, ) )
  654. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.HighTemperature" % ( count, ) )
  655. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.LowTemperature" % ( count, ) )
  656. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Precipitation" % ( count, ) )
  657. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Wind" % ( count, ) )
  658. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.UV" % ( count, ) )
  659. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Humidity" % ( count, ) )
  660. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Sunrise" % ( count, ) )
  661. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Sunset" % ( count, ) )
  662. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Forecast" % ( count, ) )
  663. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Observed" % ( count, ) )
  664. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.ObservedPrecipitation" % ( count, ) )
  665. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.ObservedAvgHighTemperature" % ( count, ) )
  666. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.ObservedAvgLowTemperature" % ( count, ) )
  667. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.ObservedRecordHighTemperature" % ( count, ) )
  668. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.ObservedRecordLowTemperature" % ( count, ) )
  669. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.DepartureHigh" % ( count, ) )
  670. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.DepartureHighColor" % ( count, ) )
  671. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.DepartureLow" % ( count, ) )
  672. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.DepartureLowColor" % ( count, ) )
  673. # do this last so skin's visibilty works better
  674. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Date" % ( count, ) )
  675. for count, forecast in enumerate( forecasts ):
  676. self.WEATHER_WINDOW.setProperty( "Daily.%d.LongDay" % ( count + 1, ), longday_dict[ forecast[ 0 ] ] )
  677. self.WEATHER_WINDOW.setProperty( "Daily.%d.ShortDay" % ( count + 1, ), shortday_dict[ forecast[ 0 ] ] )
  678. self.WEATHER_WINDOW.setProperty( "Daily.%d.LongDate" % ( count + 1, ), "%s %s" % ( longdate_dict[ forecast[ 1 ].split( "/" )[ 0 ] ], forecast[ 1 ].split( "/" )[ 1 ], ) )
  679. self.WEATHER_WINDOW.setProperty( "Daily.%d.ShortDate" % ( count + 1, ), "%s %s" % ( shortdate_dict[ forecast[ 1 ].split( "/" )[ 0 ] ], forecast[ 1 ].split( "/" )[ 1 ], ) )
  680. self.WEATHER_WINDOW.setProperty( "Daily.%d.OutlookIcon" % ( count + 1, ), forecast[ 2 ] )
  681. self.WEATHER_WINDOW.setProperty( "Daily.%d.FanartCode" % ( count + 1, ), os.path.splitext( os.path.basename( forecast[ 2 ] ) )[ 0 ] )
  682. self.WEATHER_WINDOW.setProperty( "Daily.%d.Outlook" % ( count + 1, ), forecast[ 3 ] )
  683. self.WEATHER_WINDOW.setProperty( "Daily.%d.HighTemperature" % ( count + 1, ), forecast[ 4 ] )
  684. self.WEATHER_WINDOW.setProperty( "Daily.%d.LowTemperature" % ( count + 1, ), forecast[ 5 ] )
  685. self.WEATHER_WINDOW.setProperty( "Daily.%d.Precipitation" % ( count + 1, ), forecast[ 6 ] )
  686. self.WEATHER_WINDOW.setProperty( "Daily.%d.WindDirection" % ( count + 1, ), forecast[ 7 ] )
  687. self.WEATHER_WINDOW.setProperty( "Daily.%d.WindSpeed" % ( count + 1, ), forecast[ 8 ] )
  688. self.WEATHER_WINDOW.setProperty( "Daily.%d.ShortWindDirection" % ( count + 1, ), forecast[ 9 ] )
  689. # weekend info
  690. if ( forecast[ 0 ] == "Friday" and weekend_count == 0 ):
  691. weekend = 1
  692. elif ( forecast[ 0 ] == "Saturday" and weekend_count < 2 ):
  693. weekend = 2
  694. elif ( forecast[ 0 ] == "Sunday" ):
  695. weekend = 3
  696. if ( weekend != 0 and weekend_count != 100 ):
  697. self.WEATHER_WINDOW.setProperty( "Weekend.%d.OutlookIcon" % ( weekend, ), forecast[ 2 ] )
  698. self.WEATHER_WINDOW.setProperty( "Weekend.%d.FanartCode" % ( weekend, ), os.path.splitext( os.path.basename( forecast[ 2 ] ) )[ 0 ] )
  699. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Outlook" % ( weekend, ), "" )
  700. self.WEATHER_WINDOW.setProperty( "Weekend.%d.HighTemperature" % ( weekend, ), forecast[ 4 ] )
  701. self.WEATHER_WINDOW.setProperty( "Weekend.%d.LowTemperature" % ( weekend, ), forecast[ 5 ] )
  702. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Precipitation" % ( weekend, ), "" )
  703. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Wind" % ( weekend, ), "" )
  704. self.WEATHER_WINDOW.setProperty( "Weekend.%d.UV" % ( weekend, ), "" )
  705. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Humidity" % ( weekend, ), "" )
  706. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Sunrise" % ( weekend, ), "" )
  707. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Sunset" % ( weekend, ), "" )
  708. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Forecast" % ( weekend, ), forecast[ 3 ] )
  709. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Observed" % ( weekend, ), "" )
  710. self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedPrecipitation" % ( weekend, ), "" )
  711. self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedAvgHighTemperature" % ( weekend, ), "" )
  712. self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedAvgLowTemperature" % ( weekend, ), "" )
  713. self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedRecordHighTemperature" % ( weekend, ), "" )
  714. self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedRecordLowTemperature" % ( weekend, ), "" )
  715. self.WEATHER_WINDOW.setProperty( "Weekend.%d.DepartureHigh" % ( weekend, ), "" )
  716. self.WEATHER_WINDOW.setProperty( "Weekend.%d.DepartureHighColor" % ( weekend, ), "" )
  717. self.WEATHER_WINDOW.setProperty( "Weekend.%d.DepartureLow" % ( weekend, ), "" )
  718. self.WEATHER_WINDOW.setProperty( "Weekend.%d.DepartureLowColor" % ( weekend, ), "" )
  719. # do this last so skin's visibilty works better
  720. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Date" % ( weekend, ), "%s %s" % ( shortdate_dict[ forecast[ 1 ].split( "/" )[ 0 ] ], forecast[ 1 ].split( "/" )[ 1 ], ) )
  721. if ( weekend != 3 ):
  722. weekend_count += 1
  723. else:
  724. weekend_count = 100
  725. weekend = 0
  726. # just in case day 10 is missing
  727. for count in range( len( forecasts ), 10 ):
  728. self.WEATHER_WINDOW.clearProperty( "Daily.%d.ShortDay" % ( count + 1, ) )
  729. self.WEATHER_WINDOW.clearProperty( "Daily.%d.LongDay" % ( count + 1, ) )
  730. # use this to hide info until fully fetched
  731. self.WEATHER_WINDOW.setProperty( "Daily.IsFetched", "true" )
  732.  
  733. def _noaa_36_forecast( self ):
  734. # exit script if user changed locations
  735. if ( self.areacode != self.Settings.getSetting("alt_code" + str(self.locationindex)) ):
  736. return
  737. # fetch 36 hour forecast
  738. alerts, alertsrss, alertsnotify, alertscolor, alertscount, forecasts, extras, video, video_local = self.WeatherClient.noaa_36_forecast("")
  739. # set current info
  740. self.WEATHER_WINDOW.setProperty( "Current.Temperature", extras[0][4] )
  741. self.WEATHER_WINDOW.setProperty( "Current.FeelsLike", extras[0][5] )
  742. self.WEATHER_WINDOW.setProperty( "Current.Condition", extras[0][6] )
  743. self.WEATHER_WINDOW.setProperty( "Current.FanartCode", os.path.splitext( os.path.basename( extras[0][10] ) )[ 0 ] )
  744. self.WEATHER_WINDOW.setProperty( "Current.Wind", extras[0][7] )
  745. self.WEATHER_WINDOW.setProperty( "Current.Humidity", extras[0][8]+"%" )
  746. self.WEATHER_WINDOW.setProperty( "Current.DewPoint", extras[0][9] )
  747. self.WEATHER_WINDOW.setProperty( "Current.UVIndex", "N/A" )
  748. self.WEATHER_WINDOW.setProperty( "Current.ConditionIcon", extras[0][10] )
  749. # set any alerts
  750. self._set_alerts( alerts, alertsrss, alertsnotify, alertscolor, alertscount )
  751. # set video
  752. self._set_video( video, video_local )
  753. # set extra info
  754. self._set_extra_current_info( extras )
  755. # enumerate thru and set the info
  756. for day, forecast in enumerate( forecasts ):
  757. if ( day < 3 ):
  758. self.WEATHER_WINDOW.setProperty( "36Hour.%d.OutlookIcon" % ( day + 1, ), forecast[ 1 ] )
  759. self.WEATHER_WINDOW.setProperty( "36Hour.%d.FanartCode" % ( day + 1, ), os.path.splitext( os.path.basename( forecast[ 1 ] ) )[ 0 ] )
  760. self.WEATHER_WINDOW.setProperty( "36Hour.%d.Outlook" % ( day + 1, ), forecast[ 2 ] )
  761. self.WEATHER_WINDOW.setProperty( "36Hour.%d.TemperatureColor" % ( day + 1, ), forecast[ 3 ].lower() )
  762. self.WEATHER_WINDOW.setProperty( "36Hour.%d.TemperatureHeading" % ( day + 1, ), ( xbmc.getLocalizedString( 393 ), xbmc.getLocalizedString( 391 ), )[ forecast[ 3 ] == "Low" ] )
  763. self.WEATHER_WINDOW.setProperty( "36Hour.%d.Temperature" % ( day + 1, ), forecast[ 4 ] )
  764. self.WEATHER_WINDOW.setProperty( "36Hour.%d.Precipitation" % ( day + 1, ), forecast[ 6 ] )
  765. self.WEATHER_WINDOW.setProperty( "36Hour.%d.Forecast" % ( day + 1, ), forecast[ 7 ] )
  766. self.WEATHER_WINDOW.setProperty( "36Hour.%d.DaylightTitle" % ( day + 1, ), forecast[ 8 ].replace( "Sunrise", xbmc.getLocalizedString( 33027 ) ).replace( "Sunset", xbmc.getLocalizedString( 33028 ) ) )
  767. self.WEATHER_WINDOW.setProperty( "36Hour.%d.DaylightTime" % ( day + 1, ), forecast[ 9 ] )
  768. self.WEATHER_WINDOW.setProperty( "36Hour.%d.DaylightType" % ( day + 1, ), ( "sunrise", "sunset", )[ forecast[ 8 ] == "Sunset" ] )
  769. self.WEATHER_WINDOW.setProperty( "36Hour.%d.Heading" % ( day + 1, ), { "Today": xbmc.getLocalizedString( 33006 ), "Tonight": xbmc.getLocalizedString( 33018 ), "Tomorrow": xbmc.getLocalizedString( 33007 ), "Tomorrow Night": xbmc.getLocalizedString( 33019 ) }[ forecast[ 0 ] ] )
  770. # use this to hide info until fully fetched
  771. self.WEATHER_WINDOW.setProperty( "36Hour.IsFetched", "true" )
  772.  
  773. # localized long and short day dictionary
  774. longday_dict = { "Monday": xbmc.getLocalizedString( 11 ), "Tuesday": xbmc.getLocalizedString( 12 ), "Wednesday": xbmc.getLocalizedString( 13 ), "Thursday": xbmc.getLocalizedString( 14 ), "Friday": xbmc.getLocalizedString( 15 ), "Saturday": xbmc.getLocalizedString( 16 ), "Sunday": xbmc.getLocalizedString( 17 ), "Today": xbmc.getLocalizedString( 33006 ), "Tonight": xbmc.getLocalizedString( 33018 ) }
  775. shortday_dict = { "Monday": xbmc.getLocalizedString( 41 ), "Tuesday": xbmc.getLocalizedString( 42 ), "Wednesday": xbmc.getLocalizedString( 43 ), "Thursday": xbmc.getLocalizedString( 44 ), "Friday": xbmc.getLocalizedString( 45 ), "Saturday": xbmc.getLocalizedString( 46 ), "Sunday": xbmc.getLocalizedString( 47 ), "Today": xbmc.getLocalizedString( 33006 ), "Tonight": xbmc.getLocalizedString( 33018 ) }
  776. # localized long and short date dictionary
  777. longdate_dict = { "1": xbmc.getLocalizedString( 21 ), "2": xbmc.getLocalizedString( 22 ), "3": xbmc.getLocalizedString( 23 ), "4": xbmc.getLocalizedString( 24 ), "5": xbmc.getLocalizedString( 25 ), "6": xbmc.getLocalizedString( 26 ), "7": xbmc.getLocalizedString( 27 ), "8": xbmc.getLocalizedString( 28 ), "9": xbmc.getLocalizedString( 29 ), "10": xbmc.getLocalizedString( 30 ), "11": xbmc.getLocalizedString( 31 ), "12": xbmc.getLocalizedString( 32 ) }
  778. shortdate_dict = { "1": xbmc.getLocalizedString( 51 ), "2": xbmc.getLocalizedString( 52 ), "3": xbmc.getLocalizedString( 53 ), "4": xbmc.getLocalizedString( 54 ), "5": xbmc.getLocalizedString( 55 ), "6": xbmc.getLocalizedString( 56 ), "7": xbmc.getLocalizedString( 57 ), "8": xbmc.getLocalizedString( 58 ), "9": xbmc.getLocalizedString( 59 ), "10": xbmc.getLocalizedString( 60 ), "11": xbmc.getLocalizedString( 61 ), "12": xbmc.getLocalizedString( 62 ) }
  779. # enumerate thru and set the info
  780. for count in range(0, 11):
  781. self.WEATHER_WINDOW.clearProperty( "Daily.%d.LongDay" % ( count ))
  782. self.WEATHER_WINDOW.clearProperty( "Daily.%d.ShortDay" % ( count ) )
  783. self.WEATHER_WINDOW.clearProperty( "Daily.%d.LongDate" % ( count ) )
  784. self.WEATHER_WINDOW.clearProperty( "Daily.%d.ShortDate" % ( count ))
  785. self.WEATHER_WINDOW.clearProperty( "Daily.%d.OutlookIcon" % ( count ))
  786. self.WEATHER_WINDOW.clearProperty( "Daily.%d.FanartCode" % ( count ))
  787. self.WEATHER_WINDOW.clearProperty( "Daily.%d.Outlook" % ( count ))
  788. self.WEATHER_WINDOW.clearProperty( "Daily.%d.Precipitation" % ( count ))
  789. self.WEATHER_WINDOW.clearProperty( "Daily.%d.WindDirection" % ( count ))
  790. self.WEATHER_WINDOW.clearProperty( "Daily.%d.WindSpeed" % ( count ))
  791. self.WEATHER_WINDOW.clearProperty( "Daily.%d.ShortWindDirection" % ( count ))
  792. self.WEATHER_WINDOW.clearProperty( "Daily.%d.HighTemperature" % ( count ))
  793. self.WEATHER_WINDOW.clearProperty( "Daily.%d.LowTemperature" % ( count ))
  794.  
  795. ampm = 0
  796. for count, forecast in enumerate( forecasts ):
  797. print re.findall( "Night", forecast[ 10 ] )
  798. if ( forecast[ 0 ] == "Tonight" and count == 0 ):
  799. try:
  800. self.WEATHER_WINDOW.setProperty( "Daily.%d.LongDay" % ( int( ( count + 1 + ampm )/2 ) + 1, ), longday_dict[ forecast[ 10 ] ] )
  801. self.WEATHER_WINDOW.setProperty( "Daily.%d.ShortDay" % ( int( ( count + 1 + ampm )/2 ) + 1, ), shortday_dict[ forecast[ 10 ] ] )
  802. except:
  803. self.WEATHER_WINDOW.setProperty( "Daily.%d.LongDay" % ( int( ( count + 1 + ampm )/2 ) + 1, ), forecast[ 10 ][:5]+"." )
  804. self.WEATHER_WINDOW.setProperty( "Daily.%d.ShortDay" % ( int( ( count + 1 + ampm )/2 ) + 1, ), forecast[ 10 ][:5]+"." )
  805. self.WEATHER_WINDOW.setProperty( "Daily.%d.LongDate" % ( int( ( count + 1 + ampm )/2 ) + 1, ), "%s %s" % ( longdate_dict[ forecast[ 11 ].split( " " )[ 1 ] ], forecast[ 11 ].split( " " )[ 0 ], ) )
  806. self.WEATHER_WINDOW.setProperty( "Daily.%d.ShortDate" % ( int( ( count + 1 + ampm )/2 ) + 1, ), "%s %s" % ( shortdate_dict[ forecast[ 11 ].split( " " )[ 1 ] ], forecast[ 11 ].split( " " )[ 0 ], ) )
  807. self.WEATHER_WINDOW.setProperty( "Daily.%d.OutlookIcon" % ( int( ( count + 1 + ampm )/2 ) + 1, ), forecast[ 1 ] )
  808. self.WEATHER_WINDOW.setProperty( "Daily.%d.FanartCode" % ( int( ( count + 1 + ampm )/2 ) + 1, ), os.path.splitext( os.path.basename( forecast[ 1 ] ) )[ 0 ] )
  809. self.WEATHER_WINDOW.setProperty( "Daily.%d.Outlook" % ( int( ( count + 1 + ampm )/2 ) + 1, ), forecast[ 2 ] )
  810. self.WEATHER_WINDOW.setProperty( "Daily.%d.Precipitation" % ( int( ( count + 1 + ampm )/2 ) + 1, ), forecast[ 6 ] )
  811. self.WEATHER_WINDOW.setProperty( "Daily.%d.WindDirection" % ( int( ( count + 1 + ampm )/2 ) + 1, ), forecast[ 12 ] )
  812. self.WEATHER_WINDOW.setProperty( "Daily.%d.WindSpeed" % ( int( ( count + 1 + ampm )/2 ) + 1, ), forecast[ 13 ] )
  813. self.WEATHER_WINDOW.setProperty( "Daily.%d.ShortWindDirection" % ( int( ( count + 1 + ampm )/2 ) + 1, ), "" )
  814. self.WEATHER_WINDOW.setProperty( "Daily.%d.HighTemperature" % ( 1 ), "N/A" )
  815. self.WEATHER_WINDOW.setProperty( "Daily.%d.LowTemperature" % ( 1 ), forecast[ 4 ] )
  816. ampm = 1
  817. elif ( re.findall( "Night", forecast[ 10 ] ) == [] and forecast[ 10 ] != "Tonight" ):
  818. print int( ( count + 1 + ampm )/2 ) + 1
  819. print forecast
  820. try:
  821. self.WEATHER_WINDOW.setProperty( "Daily.%d.LongDay" % ( int( ( count + 1 + ampm )/2 ) + 1, ), longday_dict[ forecast[ 10 ] ] )
  822. self.WEATHER_WINDOW.setProperty( "Daily.%d.ShortDay" % ( int( ( count + 1 + ampm )/2 ) + 1, ), shortday_dict[ forecast[ 10 ] ] )
  823. except:
  824. self.WEATHER_WINDOW.setProperty( "Daily.%d.LongDay" % ( int( ( count + 1 + ampm )/2 ) + 1, ), forecast[ 10 ][:5]+"." )
  825. self.WEATHER_WINDOW.setProperty( "Daily.%d.ShortDay" % ( int( ( count + 1 + ampm )/2 ) + 1, ), forecast[ 10 ][:5]+"." )
  826. self.WEATHER_WINDOW.setProperty( "Daily.%d.LongDate" % ( int( ( count + 1 + ampm )/2 ) + 1, ), "%s %s" % ( longdate_dict[ forecast[ 11 ].split( " " )[ 1 ] ], forecast[ 11 ].split( " " )[ 0 ], ) )
  827. self.WEATHER_WINDOW.setProperty( "Daily.%d.ShortDate" % ( int( ( count + 1 + ampm )/2 ) + 1, ), "%s %s" % ( shortdate_dict[ forecast[ 11 ].split( " " )[ 1 ] ], forecast[ 11 ].split( " " )[ 0 ], ) )
  828. self.WEATHER_WINDOW.setProperty( "Daily.%d.OutlookIcon" % ( int( ( count + 1 + ampm )/2 ) + 1, ), forecast[ 1 ] )
  829. self.WEATHER_WINDOW.setProperty( "Daily.%d.FanartCode" % ( int( ( count + 1 + ampm )/2 ) + 1, ), os.path.splitext( os.path.basename( forecast[ 1 ] ) )[ 0 ] )
  830. self.WEATHER_WINDOW.setProperty( "Daily.%d.Outlook" % ( int( ( count + 1 + ampm )/2 ) + 1, ), forecast[ 2 ] )
  831. self.WEATHER_WINDOW.setProperty( "Daily.%d.HighTemperature" % ( int( ( count + 1 + ampm )/2 ) + 1, ), forecast[ 4 ] )
  832. self.WEATHER_WINDOW.setProperty( "Daily.%d.Precipitation" % ( int( ( count + 1 + ampm )/2 ) + 1, ), forecast[ 6 ] )
  833. self.WEATHER_WINDOW.setProperty( "Daily.%d.WindDirection" % ( int( ( count + 1 + ampm )/2 ) + 1, ), forecast[ 12 ] )
  834. self.WEATHER_WINDOW.setProperty( "Daily.%d.WindSpeed" % ( int( ( count + 1 + ampm )/2 ) + 1, ), forecast[ 13 ] )
  835. self.WEATHER_WINDOW.setProperty( "Daily.%d.ShortWindDirection" % ( int( ( count + 1 + ampm )/2 ) + 1, ), "" )
  836. else:
  837. self.WEATHER_WINDOW.setProperty( "Daily.%d.LowTemperature" % ( int( ( count + 1 + ampm )/2 ) ), forecast[ 4 ] )
  838. # use this to hide info until fully fetched
  839. self.WEATHER_WINDOW.setProperty( "Daily.IsFetched", "true" )
  840.  
  841.  
  842. def _noaa_hourly_forecast( self ):
  843. # exit script if user changed locations
  844. if ( self.areacode != self.Settings.getSetting("alt_code" + str(self.locationindex)) ):
  845. return
  846. # fetch hourly forecast
  847. forecasts = self.WeatherClient.noaa_fetch_hourly_forecast()
  848. # localized long and short date dictionary
  849. longdate_dict = { "01": xbmc.getLocalizedString( 21 ), "02": xbmc.getLocalizedString( 22 ), "03": xbmc.getLocalizedString( 23 ), "04": xbmc.getLocalizedString( 24 ), "05": xbmc.getLocalizedString( 25 ), "06": xbmc.getLocalizedString( 26 ), "07": xbmc.getLocalizedString( 27 ), "08": xbmc.getLocalizedString( 28 ), "09": xbmc.getLocalizedString( 29 ), "10": xbmc.getLocalizedString( 30 ), "11": xbmc.getLocalizedString( 31 ), "12": xbmc.getLocalizedString( 32 ) }
  850. shortdate_dict = { "01": xbmc.getLocalizedString( 51 ), "02": xbmc.getLocalizedString( 52 ), "03": xbmc.getLocalizedString( 53 ), "04": xbmc.getLocalizedString( 54 ), "05": xbmc.getLocalizedString( 55 ), "06": xbmc.getLocalizedString( 56 ), "07": xbmc.getLocalizedString( 57 ), "08": xbmc.getLocalizedString( 58 ), "09": xbmc.getLocalizedString( 59 ), "10": xbmc.getLocalizedString( 60 ), "11": xbmc.getLocalizedString( 61 ), "12": xbmc.getLocalizedString( 62 ) }
  851. # enumerate thru and set the info
  852. for count, forecast in enumerate( forecasts ):
  853. # set properties
  854. self.WEATHER_WINDOW.setProperty( "Hourly.%d.Time" % ( count + 1, ), forecast[ 0 ] )
  855. self.WEATHER_WINDOW.setProperty( "Hourly.%d.LongDate" % ( count + 1, ), "%s %s" % ( longdate_dict.get( forecast[ 1 ].split( "/" )[ 0 ], "" ), forecast[ 1 ].split( "/" )[ -1 ], ) )
  856. self.WEATHER_WINDOW.setProperty( "Hourly.%d.ShortDate" % ( count + 1, ), "%s %s" % ( shortdate_dict.get( forecast[ 1 ].split( "/" )[ 0 ], "" ), forecast[ 1 ].split( "/" )[ -1 ], ) )
  857. self.WEATHER_WINDOW.setProperty( "Hourly.%d.OutlookIcon" % ( count + 1, ), forecast[ 2 ] )
  858. self.WEATHER_WINDOW.setProperty( "Hourly.%d.FanartCode" % ( count + 1, ), os.path.splitext( os.path.basename( forecast[ 2 ] ) )[ 0 ] )
  859. self.WEATHER_WINDOW.setProperty( "Hourly.%d.Temperature" % ( count + 1, ), forecast[ 3 ] )
  860. self.WEATHER_WINDOW.setProperty( "Hourly.%d.Outlook" % ( count + 1, ), forecast[ 4 ] )
  861. self.WEATHER_WINDOW.setProperty( "Hourly.%d.FeelsLike" % ( count + 1, ), forecast[ 5 ] )
  862. self.WEATHER_WINDOW.setProperty( "Hourly.%d.Precipitation" % ( count + 1, ), forecast[ 6 ] )
  863. self.WEATHER_WINDOW.setProperty( "Hourly.%d.Humidity" % ( count + 1, ), forecast[ 7 ] )
  864. self.WEATHER_WINDOW.setProperty( "Hourly.%d.WindDirection" % ( count + 1, ), forecast[ 8 ] )
  865. self.WEATHER_WINDOW.setProperty( "Hourly.%d.WindSpeed" % ( count + 1, ), forecast[ 9 ] )
  866. self.WEATHER_WINDOW.setProperty( "Hourly.%d.ShortWindDirection" % ( count + 1, ), forecast[ 10 ] )
  867. self.WEATHER_WINDOW.setProperty( "Hourly.%d.Sunrise" % ( count + 1, ), "" )
  868. self.WEATHER_WINDOW.setProperty( "Hourly.%d.Sunset" % ( count + 1, ), "" )
  869. # use this to hide info until fully fetched
  870. self.WEATHER_WINDOW.setProperty( "Hourly.IsFetched", "true" )
  871.  
  872. def _noaa_weekend_forecast( self ):
  873. # exit script if user changed locations
  874. if (self.areacode != self.Settings.getSetting("alt_code" + str(self.locationindex)) ):
  875. return
  876. # fetch weekend forecast
  877. # forecasts = self.WeatherClient.accu_weekend_forecast()
  878. # clear the info
  879. for count in range(1,4):
  880. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.OutlookIcon" % ( count, ) )
  881. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.FanartCode" % ( count, ) )
  882. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Outlook" % ( count, ) )
  883. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.HighTemperature" % ( count, ) )
  884. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.LowTemperature" % ( count, ) )
  885. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Precipitation" % ( count, ) )
  886. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Wind" % ( count, ) )
  887. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.UV" % ( count, ) )
  888. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Humidity" % ( count, ) )
  889. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Sunrise" % ( count, ) )
  890. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Sunset" % ( count, ) )
  891. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Forecast" % ( count, ) )
  892. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Observed" % ( count, ) )
  893. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.ObservedPrecipitation" % ( count, ) )
  894. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.ObservedAvgHighTemperature" % ( count, ) )
  895. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.ObservedAvgLowTemperature" % ( count, ) )
  896. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.ObservedRecordHighTemperature" % ( count, ) )
  897. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.ObservedRecordLowTemperature" % ( count, ) )
  898. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.DepartureHigh" % ( count, ) )
  899. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.DepartureHighColor" % ( count, ) )
  900. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.DepartureLow" % ( count, ) )
  901. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.DepartureLowColor" % ( count, ) )
  902. # do this last so skin's visibilty works better
  903. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Date" % ( count, ) )
  904. # print self.WEATHER_WINDOW.getProperty( "Weekend.1.OutlookIcon" )
  905. # use this to hide info until fully fetched
  906. self.WEATHER_WINDOW.setProperty( "Weekend.IsFetched", "true" )
  907.  
  908. def _noaa_10day_forecast( self ):
  909. # exit script if user changed locations
  910. if ( self.areacode != self.Settings.getSetting("alt_code" + str(self.locationindex)) ):
  911. return
  912. # fetch daily forecast
  913. forecasts = self.WeatherClient.accu_fetch_10day_forecast()
  914. print forecasts
  915. # localized long and short day dictionary
  916. longday_dict = { "Monday": xbmc.getLocalizedString( 11 ), "Tuesday": xbmc.getLocalizedString( 12 ), "Wednesday": xbmc.getLocalizedString( 13 ), "Thursday": xbmc.getLocalizedString( 14 ), "Friday": xbmc.getLocalizedString( 15 ), "Saturday": xbmc.getLocalizedString( 16 ), "Sunday": xbmc.getLocalizedString( 17 ), "Today": xbmc.getLocalizedString( 33006 ), "Tonight": xbmc.getLocalizedString( 33018 ) }
  917. shortday_dict = { "Monday": xbmc.getLocalizedString( 41 ), "Tuesday": xbmc.getLocalizedString( 42 ), "Wednesday": xbmc.getLocalizedString( 43 ), "Thursday": xbmc.getLocalizedString( 44 ), "Friday": xbmc.getLocalizedString( 45 ), "Saturday": xbmc.getLocalizedString( 46 ), "Sunday": xbmc.getLocalizedString( 47 ), "Today": xbmc.getLocalizedString( 33006 ), "Tonight": xbmc.getLocalizedString( 33018 ) }
  918. # localized long and short date dictionary
  919. longdate_dict = { "1": xbmc.getLocalizedString( 21 ), "2": xbmc.getLocalizedString( 22 ), "3": xbmc.getLocalizedString( 23 ), "4": xbmc.getLocalizedString( 24 ), "5": xbmc.getLocalizedString( 25 ), "6": xbmc.getLocalizedString( 26 ), "7": xbmc.getLocalizedString( 27 ), "8": xbmc.getLocalizedString( 28 ), "9": xbmc.getLocalizedString( 29 ), "10": xbmc.getLocalizedString( 30 ), "11": xbmc.getLocalizedString( 31 ), "12": xbmc.getLocalizedString( 32 ) }
  920. shortdate_dict = { "1": xbmc.getLocalizedString( 51 ), "2": xbmc.getLocalizedString( 52 ), "3": xbmc.getLocalizedString( 53 ), "4": xbmc.getLocalizedString( 54 ), "5": xbmc.getLocalizedString( 55 ), "6": xbmc.getLocalizedString( 56 ), "7": xbmc.getLocalizedString( 57 ), "8": xbmc.getLocalizedString( 58 ), "9": xbmc.getLocalizedString( 59 ), "10": xbmc.getLocalizedString( 60 ), "11": xbmc.getLocalizedString( 61 ), "12": xbmc.getLocalizedString( 62 ) }
  921. # enumerate thru and set the info
  922. weekend_count = 0
  923. weekend = 0
  924. for count in range(0,3):
  925. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.OutlookIcon" % ( count, ) )
  926. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.FanartCode" % ( count, ) )
  927. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Outlook" % ( count, ) )
  928. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.HighTemperature" % ( count, ) )
  929. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.LowTemperature" % ( count, ) )
  930. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Precipitation" % ( count, ) )
  931. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Wind" % ( count, ) )
  932. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.UV" % ( count, ) )
  933. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Humidity" % ( count, ) )
  934. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Sunrise" % ( count, ) )
  935. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Sunset" % ( count, ) )
  936. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Forecast" % ( count, ) )
  937. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Observed" % ( count, ) )
  938. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.ObservedPrecipitation" % ( count, ) )
  939. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.ObservedAvgHighTemperature" % ( count, ) )
  940. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.ObservedAvgLowTemperature" % ( count, ) )
  941. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.ObservedRecordHighTemperature" % ( count, ) )
  942. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.ObservedRecordLowTemperature" % ( count, ) )
  943. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.DepartureHigh" % ( count, ) )
  944. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.DepartureHighColor" % ( count, ) )
  945. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.DepartureLow" % ( count, ) )
  946. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.DepartureLowColor" % ( count, ) )
  947. # do this last so skin's visibilty works better
  948. self.WEATHER_WINDOW.clearProperty( "Weekend.%d.Date" % ( count, ) )
  949. for count, forecast in enumerate( forecasts ):
  950. self.WEATHER_WINDOW.setProperty( "Daily.%d.LongDay" % ( count + 1, ), longday_dict[ forecast[ 0 ] ] )
  951. self.WEATHER_WINDOW.setProperty( "Daily.%d.ShortDay" % ( count + 1, ), shortday_dict[ forecast[ 0 ] ] )
  952. self.WEATHER_WINDOW.setProperty( "Daily.%d.LongDate" % ( count + 1, ), "%s %s" % ( longdate_dict[ forecast[ 1 ].split( "/" )[ 0 ] ], forecast[ 1 ].split( "/" )[ 1 ], ) )
  953. self.WEATHER_WINDOW.setProperty( "Daily.%d.ShortDate" % ( count + 1, ), "%s %s" % ( shortdate_dict[ forecast[ 1 ].split( "/" )[ 0 ] ], forecast[ 1 ].split( "/" )[ 1 ], ) )
  954. self.WEATHER_WINDOW.setProperty( "Daily.%d.OutlookIcon" % ( count + 1, ), forecast[ 2 ] )
  955. self.WEATHER_WINDOW.setProperty( "Daily.%d.FanartCode" % ( count + 1, ), os.path.splitext( os.path.basename( forecast[ 2 ] ) )[ 0 ] )
  956. self.WEATHER_WINDOW.setProperty( "Daily.%d.Outlook" % ( count + 1, ), forecast[ 3 ] )
  957. self.WEATHER_WINDOW.setProperty( "Daily.%d.HighTemperature" % ( count + 1, ), forecast[ 4 ] )
  958. self.WEATHER_WINDOW.setProperty( "Daily.%d.LowTemperature" % ( count + 1, ), forecast[ 5 ] )
  959. self.WEATHER_WINDOW.setProperty( "Daily.%d.Precipitation" % ( count + 1, ), forecast[ 6 ] )
  960. self.WEATHER_WINDOW.setProperty( "Daily.%d.WindDirection" % ( count + 1, ), forecast[ 7 ] )
  961. self.WEATHER_WINDOW.setProperty( "Daily.%d.WindSpeed" % ( count + 1, ), forecast[ 8 ] )
  962. self.WEATHER_WINDOW.setProperty( "Daily.%d.ShortWindDirection" % ( count + 1, ), forecast[ 9 ] )
  963. # weekend info
  964. if ( forecast[ 0 ] == "Friday" and weekend_count == 0 ):
  965. weekend = 1
  966. elif ( forecast[ 0 ] == "Saturday" and weekend_count < 2 ):
  967. weekend = 2
  968. elif ( forecast[ 0 ] == "Sunday" ):
  969. weekend = 3
  970. if ( weekend != 0 and weekend_count != 100 ):
  971. self.WEATHER_WINDOW.setProperty( "Weekend.%d.OutlookIcon" % ( weekend, ), forecast[ 2 ] )
  972. self.WEATHER_WINDOW.setProperty( "Weekend.%d.FanartCode" % ( weekend, ), os.path.splitext( os.path.basename( forecast[ 2 ] ) )[ 0 ] )
  973. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Outlook" % ( weekend, ), "" )
  974. self.WEATHER_WINDOW.setProperty( "Weekend.%d.HighTemperature" % ( weekend, ), forecast[ 4 ] )
  975. self.WEATHER_WINDOW.setProperty( "Weekend.%d.LowTemperature" % ( weekend, ), forecast[ 5 ] )
  976. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Precipitation" % ( weekend, ), "" )
  977. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Wind" % ( weekend, ), "" )
  978. self.WEATHER_WINDOW.setProperty( "Weekend.%d.UV" % ( weekend, ), "" )
  979. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Humidity" % ( weekend, ), "" )
  980. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Sunrise" % ( weekend, ), "" )
  981. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Sunset" % ( weekend, ), "" )
  982. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Forecast" % ( weekend, ), forecast[ 3 ] )
  983. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Observed" % ( weekend, ), "" )
  984. self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedPrecipitation" % ( weekend, ), "" )
  985. self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedAvgHighTemperature" % ( weekend, ), "" )
  986. self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedAvgLowTemperature" % ( weekend, ), "" )
  987. self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedRecordHighTemperature" % ( weekend, ), "" )
  988. self.WEATHER_WINDOW.setProperty( "Weekend.%d.ObservedRecordLowTemperature" % ( weekend, ), "" )
  989. self.WEATHER_WINDOW.setProperty( "Weekend.%d.DepartureHigh" % ( weekend, ), "" )
  990. self.WEATHER_WINDOW.setProperty( "Weekend.%d.DepartureHighColor" % ( weekend, ), "" )
  991. self.WEATHER_WINDOW.setProperty( "Weekend.%d.DepartureLow" % ( weekend, ), "" )
  992. self.WEATHER_WINDOW.setProperty( "Weekend.%d.DepartureLowColor" % ( weekend, ), "" )
  993. # do this last so skin's visibilty works better
  994. self.WEATHER_WINDOW.setProperty( "Weekend.%d.Date" % ( weekend, ), "%s %s" % ( shortdate_dict[ forecast[ 1 ].split( "/" )[ 0 ] ], forecast[ 1 ].split( "/" )[ 1 ], ) )
  995. if ( weekend != 3 ):
  996. weekend_count += 1
  997. else:
  998. weekend_count = 100
  999. weekend = 0
  1000. # just in case day 10 is missing
  1001. for count in range( len( forecasts ), 10 ):
  1002. self.WEATHER_WINDOW.clearProperty( "Daily.%d.ShortDay" % ( count + 1, ) )
  1003. self.WEATHER_WINDOW.clearProperty( "Daily.%d.LongDay" % ( count + 1, ) )
  1004. # use this to hide info until fully fetched
  1005. self.WEATHER_WINDOW.setProperty( "Daily.IsFetched", "true" )
  1006.  
  1007. def _exit_script( self ):
  1008. # end script
  1009. pass
  1010.  
  1011. # __init__(self,'location=06604')
  1012.  
  1013. """
  1014. class FetchInfo( Thread ):
  1015. def __init__( self, method ):
  1016. Thread.__init__( self )
  1017. self.method = method
  1018.  
  1019. def run( self ):
  1020. self.method()
  1021. """
  1022.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement