Ignore that, I say that you already renamed it. Ryan Roth wrote: > call it 'auto_update_weather.py' and change the line in the info section > to reflect it if you can > > Duncan Webb wrote: > >> Ryan Roth wrote: >> >> >>> Ok ignore the last patch I sent. I did not like the idea of having to >>> use a cron job to schedule the updates. Cron seems to cause a lot of >>> people confusion. I tweaked the helper to use the time.sleep function >>> to wait between updates. To enable the plug ad the following to the >>> local_conf: >>> >>> plugin.activate('helpers.weather') >>> >>> >> If you make this a plug-in then it needs to be in the plugins directory >> :) Will do this, but will need a new name. >> >> >> >>> WEATHER_UPDATE_INTERVAL = 20 >>> >>> The interval number is in minutes. >>> >>> >>> ------------------------------------------------------------------------ >>> >>> Index: src/helpers/weather.py >>> =================================================================== >>> --- src/helpers/weather.py (revision 8792) >>> +++ src/helpers/weather.py (working copy) >>> @@ -5,10 +5,15 @@ >>> # $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. >>> +# To enable add the following to your local_conf.py >>> # >>> +# plugin.activate('helpers.weather') >>> +# WEATHER_UPDATE_INTERVAL = 10 >>> +# >>> +# The WEATHER_UPDATE_INTERVAL is set in whole minutes. >>> +# The weather.py plugin will grab new data if the cache is older than >>> +# two hours, so set the update interval to more often than that. >>> +# >>> # Todo: >>> # >>> # ----------------------------------------------------------------------- >>> @@ -34,22 +39,32 @@ >>> >>> import os >>> import stat >>> -import urllib >>> +import time >>> 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 hasattr(config, 'PLUGIN_WEATHER_LOCATIONS'): >>> + while hasattr(config, 'WEATHER_UPDATE_INTERVAL'): >>> + 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])) >>> + 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)) >>> + os.system ('wget %s -O %s 2> /dev/null' % (dataurl, cacheFile)) >>> + os.system ('wget %s -O %s 2> /dev/null' % (mapurl, mapFile)) >>> + if config.DEBUG == 1: >>> + print "Updated Weather Data\n" >>> + time.sleep(config.WEATHER_UPDATE_INTERVAL * 60) >>> + else: >>> + print "\nWEATHER_UPDATE_INTERVAL not defined in local_conf.py\n" >>> +else: >>> + >>> + print "\nPLUGIN_WEATHER_LOCATIONS not defined in local_conf.py\n" >>> >>> >> You don't need \n with python print because you get a newline anyway. >> >> Duncan >> >> >> ------------------------------------------------------------------------- >> 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-devel mailing list >> Freevo-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/freevo-devel >> >> >> > > ------------------------------------------------------------------------- > 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-devel mailing list > Freevo-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/freevo-devel > >
------------------------------------------------------------------------- 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-devel mailing list Freevo-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freevo-devel