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/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.

Reply via email to