username = configs['email']['username'] password = configs['email']['password'] recipient = configs['cell settings']['recipient'] # Location settings source = configs['noaa.gov settings']['my_source'] location = configs['noaa.gov settings']['location'] time_zone = configs['location settings']['set_time_zone'] all_dat = configs['forecast settings'].getboolean('send_all_data') forecast = configs['forecast settings'].getboolean('send_marine_forecast') hours_ = int(configs['forecast settings']['hours_ahead_to_forecast']) tmpfile = 'tmp-forecast.csv' weather = NoaaParser() weather.get_locations(location, source) if all_dat: message = weather.weather_get_all() # returns a list else: message = weather.weather_info_dict(time_zone) # returns a dict if forecast: with open(tmpfile, 'w') as f: for n in weather.prettify_forecast(hours_ahead=hours_): field, time, data = n f.write(field + ',' + time + ',' + data + '\n') else: pass
def ocean_data(source, my_loc): WeatherInfo = NoaaParser() all_locations = WeatherInfo.parse_results(source) my_sources = WeatherInfo.get_locations(my_loc, all_locations) return WeatherInfo.weather_get(my_sources)
def ocean_data_clean(source, my_loc, time_zone): WeatherInfo = NoaaParser() all_locations = WeatherInfo.parse_results(source) my_sources = WeatherInfo.get_locations(my_loc, all_locations) return WeatherInfo.weather_info_dict(my_sources, time_zone)