scripts/weatherpub.py
def weather_update(station, pub_sites, interval):
   '''
   main execution loop. query weather data and post to online service.
   '''
   station.parse()      # read weather data

   # santity check weather data
   if station.fields['TempOut'] > 200:
      raise NoSensorException(
            'Out of range temperature value: %.1f, check sensors' %
            (station.fields['TempOut'],))

   gust, gust_dir = WindGust.get( station, interval )

   # upload data in the following order:
   for ps in pub_sites:
      try: # try block necessary to attempt every publisher
         ps.set(
               pressure    = station.fields['Pressure'],
               dewpoint    = station.fields['DewPoint'],
               humidity    = station.fields['HumOut'],
               tempf       = station.fields['TempOut'],
               rainin      = station.fields['RainRate'],
               rainday     = station.fields['RainDay'],
               dateutc     = station.fields['DateStampUtc'],
               windspeed   = station.fields['WindSpeed10Min'],
               winddir     = station.fields['WindDir'],
               windgust    = gust,
               windgustdir = gust_dir, )

         ps.publish()
      except (Exception) as e:
         log.warn('publisher %s: %s'%(ps.__class__.__name__,e))
def weather_update(station, pub_sites, interval):
   '''
   main execution loop. query weather data and post to online service.
   '''
   station.parse()      # read weather data

   # santity check weather data
   if station.fields['TempOut'] > 200:
      raise NoSensorException(
            'Out of range temperature value: %.1f, check sensors' %
            (station.fields['TempOut'],))

   gust, gust_dir = WindGust.get( station, interval )

   # upload data in the following order:
   for ps in pub_sites:
      try: # try block necessary to attempt every publisher
         ps.set(
               pressure    = station.fields['Pressure'],
               dewpoint    = station.fields['DewPoint'],
               humidity    = station.fields['HumOut'],
               tempf       = station.fields['TempOut'],
               rainin      = station.fields['RainRate'],
               rainday     = station.fields['RainDay'],
               dateutc     = station.fields['DateStampUtc'],
               windspeed   = station.fields['WindSpeed10Min'],
               winddir     = station.fields['WindDir'],
               windgust    = gust,
               windgustdir = gust_dir, )

         ps.publish()
      except (Exception) as e:
         log.warn('publisher %s: %s'%(ps.__class__.__name__,e))
main execution loop. query weather data and post to online service.