Upload weather data to PWS Weather.

PWS Weather is a site run by AerisWeather that “brings together personal weather station data worldwide from locales not served by primary weather services.”


ToService(context[, check_params])
class pywws.service.pwsweather.ToService(context, check_params=True)[source]

Bases: pywws.service.CatchupDataService

config = {'password': ('', True, 'PASSWORD'), 'station': ('', True, 'ID')}
fixed_data = {'action': 'updateraw', 'softwaretype': 'pywws'}
logger = <Logger pywws.service.pwsweather (WARNING)>
service_name = 'pwsweather'
template = '\n#live#\n#idx "\'dateutc\' : \'%Y-%m-%d %H:%M:%S\',"#\n#wind_dir "\'winddir\' : \'%.0f\'," "" "winddir_degrees(x)"#\n#wind_ave "\'windspeedmph\': \'%.2f\'," "" "wind_mph(x)"#\n#wind_gust "\'windgustmph\' : \'%.2f\'," "" "wind_mph(x)"#\n#hum_out "\'humidity\' : \'%.d\',"#\n#temp_out "\'tempf\' : \'%.1f\'," "" "temp_f(x)"#\n#rel_pressure "\'baromin\' : \'%.4f\'," "" "pressure_inhg(x)"#\n#calc "temp_f(dew_point(data[\'temp_out\'], data[\'hum_out\']))" "\'dewptf\': \'%.1f\',"#\n#calc "rain_inch(rain_hour(data))" "\'rainin\': \'%g\',"#\n#calc "rain_inch(rain_day(data))" "\'dailyrainin\': \'%g\',"#\n'

Context manager factory function for a batch of one or more uploads.

This makes it easy to ensure any resources such as an internet connection are properly closed after a batch of uploads. Use the contextlib.contextmanager() decorator when you implement this method.

For a typical example, see the source code of the pywws.service.openweathermap module. If your upload can’t benefit from a session object yield None, as in pywws.service.copy.

upload_data(session, prepared_data={})[source]

Upload one data set to the service.

Every data service class must implement this method.

  • session (object) – the object created by session(). This is typically used to communicate with the server and is automatically closed when a batch of uploads has finished.
  • prepared_data (dict) – a set of key: value pairs to upload. The keys and values must all be text strings.

Comments or questions? Please subscribe to the pywws mailing list and let us know.