Well, I think rather than putting this in the gauge-data.txt.tmpl I'm just going to run it as a cron job and store it as a file. Now all I need to know (and not having much luck finding) is how to assign the files contents into $fc in the template?
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 weewx-user+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.