Author: duncan Date: Fri Dec 22 02:52:35 2006 New Revision: 8785 Added: branches/rel-1/freevo/src/helpers/weather.py
Log: [ 1603052 ] Weather download slow Helper from Ryan Roth added Added: branches/rel-1/freevo/src/helpers/weather.py ============================================================================== --- (empty file) +++ branches/rel-1/freevo/src/helpers/weather.py Fri Dec 22 02:52:35 2006 @@ -0,0 +1,55 @@ +# -*- coding: iso-8859-1 -*- +# ----------------------------------------------------------------------- +# weather.py Freevo Weather Helper +# ----------------------------------------------------------------------- +# $Id$ +# +# Notes: +# Requires cron to call "freevo weather" to get updates. The weather.py +# plugin will grab new data if the cache is older than two hours, so +# run your cron job more often than that. +# +# Todo: +# +# ----------------------------------------------------------------------- +# Freevo - A Home Theater PC framework +# Copyright (C) 2002 Krister Lagerstrom, et al. +# Please see the fout freevo/Docs/CREDITS for a complete list of authors. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MER- +# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# ----------------------------------------------------------------------- + +import os +import stat +import urllib +import config + +location = [] +dataurl = [] +WEATHER_DIR = os.path.join(config.SHARE_DIR, 'images', 'weather') +for local in config.PLUGIN_WEATHER_LOCATIONS: + location = local[0] + dataurl = "http://www.msnbc.com/m/chnk/d/weather_d_src.asp?acid=%s" % location + mapurl = "http://w3.weather.com/weather/map/%s?from=LAPmaps" % location + cacheDir = '%s/weather_%s' % (config.FREEVO_CACHEDIR, location) + cacheFile = '%s/data' % (cacheDir) + mapFile = '%s/map' % (cacheDir) + + if not os.path.isdir(cacheDir): + os.mkdir(cacheDir, stat.S_IMODE(os.stat(config.FREEVO_CACHEDIR)[stat.ST_MODE])) + + os.system ('wget %s -O %s 2> /dev/null' % (dataurl, cacheFile)) + os.system ('wget %s -O %s 2> /dev/null' % (mapurl, mapFile)) ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Freevo-cvslog mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/freevo-cvslog
