Got it figured out. All I do is run my script every 15 minutes as Weather
Underground updates their forecast that often. Then all i did was comment
out the zambretti stuff in gauge-data.txt.tmpl and substituted one line
with reads the text file generated by the script:
#set $fc = file('/var/tmp/fctdata').read()
That was easier than I made it out to be I guess. Just posting this in
here if anyone is interested in doing the same thing.
On Thursday, 26 January 2017 16:31:43 UTC-5, Robert Mantel wrote:
>
> I'm starting to hone my python skills and have a snippet of code that will
> get the text forecast from weather underground and concatenate it into a
> single variable which I believe is what I will need to hijack the $fc
> variable in the gauges-data.txt.tmpl. I haven't tried putting my code into
> the template yet, but was looking for validation as to whether this will
> work or not and what I might need to change to make it cheetah friendly??
> Here it is:
>
> #!/usr/bin/env python
> import json,requests,codecs
> url = "http://api.wunderground.com/api/<api code>/forecast/q/yqt.json
> <http://api.wunderground.com/api/3eaba4f5fa8ab805/forecast/q/yqt.json>"
> response = requests.get(url)
> json_data = json.loads(response.text)
> forecast_data = json_data['forecast']['txt_forecast']['forecastday']
> fcast = ""
> for item in forecast_data:
> forecastday = item.get('title')
> fcttext_metric = item.get('fcttext_metric')
> fcast += '{} {}'.format(forecastday, fcttext_metric,)
> print fcast
>
> obviously the print statement is just for troubleshooting so wouldn't be
> necessary once introduced into the template. But I have no idea how
> cheetah will deal with it.
>
--
You received this message because you are subscribed to the Google Groups
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.