Beispiel #1
0
 def _get_weather(self):
     weather_data = self.get_default_values()
     print('-------------------------------------------------------')
     print('-------------------------------------------------------')
     print('Underground Weather Service url: %s' % URL %
           (self.key, self.latitude, self.longitude))
     print('-------------------------------------------------------')
     print('-------------------------------------------------------')
     parsed_json = read_json_from_url(
         URL % (self.key, self.latitude, self.longitude))
     if parsed_json is None:
         return weather_data
     weather_data['update_time'] = time.time()
     weather_data['ok'] = True
     condition = gvfco('weather', parsed_json).lower()
     #
     weather_data['current_conditions']['condition_text'] =\
         weatherservice.get_condition(condition, 'text')
     if weather_data['current_conditions']['isday']:
         weather_data['current_conditions']['condition_image'] =\
             weatherservice.get_condition(condition, 'image')
         weather_data['current_conditions']['condition_icon_dark'] =\
             weatherservice.get_condition(condition, 'icon-dark')
         weather_data['current_conditions']['condition_icon_light'] =\
             weatherservice.get_condition(condition, 'icon-light')
     else:
         weather_data['current_conditions']['condition_image'] =\
             weatherservice.get_condition(condition, 'image-night')
         weather_data['current_conditions']['condition_icon_dark'] =\
             weatherservice.get_condition(condition, 'icon-night-dark')
         weather_data['current_conditions']['condition_icon_light'] =\
             weatherservice.get_condition(condition, 'icon-night-light')
     temperature = weatherservice.s2f(gvfco('temp_f', parsed_json))
     weather_data['current_conditions']['temperature'] =\
         weatherservice.change_temperature(
             temperature, self.units.temperature)
     pressure = weatherservice.s2f(gvfco('pressure_mb', parsed_json))
     weather_data['current_conditions']['pressure'] =\
         weatherservice.change_pressure(pressure, self.units.pressure)
     humidity = weatherservice.s2f(
         gvfco('relative_humidity', parsed_json)[:-1])
     weather_data['current_conditions']['humidity'] = str(
         int(humidity)) + ' %'
     weather_data['current_conditions']['dew_point'] =\
         weatherservice.get_dew_point(
             humidity, temperature, self.units.temperature)
     wind_velocity = weatherservice.s2f(gvfco('wind_mph', parsed_json))
     wind_direction = gvfco('wind_dir', parsed_json)
     weather_data['current_conditions']['wind_condition'] =\
         weatherservice.get_wind_condition(
             wind_velocity, wind_direction, self.units.wind)
     weather_data['current_conditions']['wind_icon'] =\
         weatherservice.get_wind_icon(wind_direction)
     #
     weather_data['current_conditions']['heat_index'] =\
         weatherservice.get_heat_index(temperature, humidity)
     weather_data['current_conditions']['windchill'] =\
         weatherservice.get_wind_chill(temperature, wind_velocity)
     #
     weather_data['current_conditions']['feels_like'] =\
         weatherservice.get_feels_like(
             temperature, humidity, wind_velocity, self.units.temperature)
     #
     weather_data['current_conditions']['visibility'] =\
         weatherservice.change_distance(
             gvfco('visibility_mi', parsed_json), self.units.visibility)
     weather_data['current_conditions']['solarradiation'] = gvfco(
         'solarradiation', parsed_json)
     weather_data['current_conditions']['UV'] = gvfco('UV', parsed_json)
     weather_data['current_conditions']['precip_1hr'] =\
         weatherservice.change_longitude(
             gvfco('precip_1hr_in', parsed_json), self.units.rain)
     weather_data['current_conditions']['precip_today'] =\
         weatherservice.change_longitude(
             gvfco('precip_today_in', parsed_json), self.units.rain)
     for i in range(0, 4):
         weather_data['forecasts'][i]['low'] =\
             weatherservice.change_temperature(
                 gvff('low', i, parsed_json)['fahrenheit'],
                 self.units.temperature)
         weather_data['forecasts'][i]['high'] =\
             weatherservice.change_temperature(
                 gvff('high', i, parsed_json)['fahrenheit'],
                 self.units.temperature)
         #
         weather_data['forecasts'][i]['qpf_allday'] =\
             weatherservice.change_longitude(
                 gvff('qpf_allday', i, parsed_json)['in'], self.units.rain)
         weather_data['forecasts'][i]['qpf_day'] =\
             weatherservice.change_longitude(
                 gvff('qpf_day', i, parsed_json)['in'], self.units.rain)
         weather_data['forecasts'][i]['qpf_night'] =\
             weatherservice.change_longitude(
                 gvff('qpf_night', i, parsed_json)['in'], self.units.rain)
         weather_data['forecasts'][i]['snow_allday'] =\
             weatherservice.change_longitude(
                 gvff('snow_allday', i, parsed_json)['in'], self.units.snow)
         weather_data['forecasts'][i]['snow_day'] =\
             weatherservice.change_longitude(
                 gvff('snow_day', i, parsed_json)['in'], self.units.snow)
         weather_data['forecasts'][i]['snow_night'] =\
             weatherservice.change_longitude(
                 gvff('snow_night', i, parsed_json)['in'], self.units.snow)
         wind = gvff('maxwind', i, parsed_json)
         weather_data['forecasts'][i]['maxwind'] =\
             weatherservice.get_wind_condition(
                 wind['mph'], wind['dir'], self.units.wind)
         wind = gvff('avewind', i, parsed_json)
         weather_data['forecasts'][i]['avewind'] =\
             weatherservice.get_wind_condition(
                 wind['mph'], wind['dir'], self.units.wind)
         weather_data['forecasts'][i]['avehumidity'] = '%s %%' % gvff(
             'avehumidity', i, parsed_json)
         weather_data['forecasts'][i]['maxhumidity'] = '%s %%' % gvff(
             'maxhumidity', i, parsed_json)
         weather_data['forecasts'][i]['minhumidity'] = '%s %%' % gvff(
             'minhumidity', i, parsed_json)
         #
         condition = gvff('conditions', i, parsed_json).lower()
         weather_data['forecasts'][i]['condition'] = condition
         weather_data['forecasts'][i]['condition_text'] =\
             weatherservice.get_condition(condition, 'text')
         weather_data['forecasts'][i]['condition_image'] =\
             weatherservice.get_condition(condition, 'image')
         weather_data['forecasts'][i]['condition_icon'] =\
             weatherservice.get_condition(condition, 'icon-light')
     weather_data['forecast_information']['city'] =\
         gvfi('city', parsed_json)
     weather_data['forecast_information']['postal_code'] =\
         gvfi('zip', parsed_json)
     weather_data['forecast_information']['latitude_e6'] =\
         gvfi('latitude', parsed_json)
     weather_data['forecast_information']['longitude_e6'] =\
         gvfi('longitude', parsed_json)
     return weather_data
	def _get_weather(self):
		weather_data = self.get_default_values()
		print('-------------------------------------------------------')
		print('-------------------------------------------------------')
		print('Underground Weather Service url: %s'%URL%(self.key,self.latitude,self.longitude))
		print('-------------------------------------------------------')
		print('-------------------------------------------------------')
		parsed_json = read_json_from_url(
			URL % (self.key, self.latitude, self.longitude))
		if parsed_json is None:
			return None
		condition = gvfco('weather',parsed_json).lower()
		#
		weather_data['current_conditions']['condition_text'] = weatherservice.get_condition(condition,'text')
		if weather_data['current_conditions']['isday']:
			weather_data['current_conditions']['condition_image'] = weatherservice.get_condition(condition,'image')
			weather_data['current_conditions']['condition_icon_dark'] = weatherservice.get_condition(condition,'icon-dark')
			weather_data['current_conditions']['condition_icon_light'] = weatherservice.get_condition(condition,'icon-light')
		else:
			weather_data['current_conditions']['condition_image'] = weatherservice.get_condition(condition,'image-night')
			weather_data['current_conditions']['condition_icon_dark'] = weatherservice.get_condition(condition,'icon-night-dark')
			weather_data['current_conditions']['condition_icon_light'] = weatherservice.get_condition(condition,'icon-night-light')
		temperature = weatherservice.s2f(gvfco('temp_f',parsed_json))
		weather_data['current_conditions']['temperature'] = weatherservice.change_temperature(temperature,self.units.temperature)
		pressure = weatherservice.s2f(gvfco('pressure_mb',parsed_json))
		weather_data['current_conditions']['pressure'] = weatherservice.change_pressure(pressure,self.units.pressure)
		humidity = weatherservice.s2f(gvfco('relative_humidity',parsed_json)[:-1])
		weather_data['current_conditions']['humidity'] = str(int(humidity))+' %'
		weather_data['current_conditions']['dew_point'] = weatherservice.get_dew_point(humidity,temperature,self.units.temperature)
		wind_velocity = weatherservice.s2f(gvfco('wind_mph',parsed_json))
		wind_direction = gvfco('wind_dir',parsed_json)
		print(wind_direction)
		weather_data['current_conditions']['wind_condition'] = weatherservice.get_wind_condition(wind_velocity,wind_direction,self.units.wind)
		weather_data['current_conditions']['wind_icon'] =weatherservice.get_wind_icon(wind_direction)
		#
		weather_data['current_conditions']['heat_index'] = weatherservice.get_heat_index(temperature,humidity)
		weather_data['current_conditions']['windchill'] = weatherservice.get_wind_chill(temperature,wind_velocity)
		#
		weather_data['current_conditions']['feels_like'] = weatherservice.get_feels_like(temperature,humidity,wind_velocity,self.units.temperature)
		#
		weather_data['current_conditions']['visibility'] = weatherservice.change_distance(gvfco('visibility_mi',parsed_json),self.units.visibility)
		weather_data['current_conditions']['solarradiation'] = gvfco('solarradiation',parsed_json)
		weather_data['current_conditions']['UV'] = gvfco('UV',parsed_json)
		weather_data['current_conditions']['precip_1hr'] = weatherservice.change_longitude(gvfco('precip_1hr_in',parsed_json),self.units.rain)
		weather_data['current_conditions']['precip_today'] = weatherservice.change_longitude(gvfco('precip_today_in',parsed_json),self.units.rain)
		for i in range(0,4):
			weather_data['forecasts'][i]['low'] = weatherservice.change_temperature(gvff('low',i,parsed_json)['fahrenheit'],self.units.temperature)
			weather_data['forecasts'][i]['high'] = weatherservice.change_temperature(gvff('high',i,parsed_json)['fahrenheit'],self.units.temperature)
			#
			weather_data['forecasts'][i]['qpf_allday'] = weatherservice.change_longitude(gvff('qpf_allday',i,parsed_json)['in'],self.units.rain)
			weather_data['forecasts'][i]['qpf_day'] = weatherservice.change_longitude(gvff('qpf_day',i,parsed_json)['in'],self.units.rain)
			weather_data['forecasts'][i]['qpf_night'] = weatherservice.change_longitude(gvff('qpf_night',i,parsed_json)['in'],self.units.rain)
			weather_data['forecasts'][i]['snow_allday'] = weatherservice.change_longitude(gvff('snow_allday',i,parsed_json)['in'],self.units.snow)
			weather_data['forecasts'][i]['snow_day'] = weatherservice.change_longitude(gvff('snow_day',i,parsed_json)['in'],self.units.snow)
			weather_data['forecasts'][i]['snow_night'] = weatherservice.change_longitude(gvff('snow_night',i,parsed_json)['in'],self.units.snow)
			wind = gvff('maxwind',i,parsed_json)
			weather_data['forecasts'][i]['maxwind'] = weatherservice.get_wind_condition(wind['mph'],wind['dir'],self.units.wind)
			wind = gvff('avewind',i,parsed_json)
			weather_data['forecasts'][i]['avewind'] = weatherservice.get_wind_condition(wind['mph'],wind['dir'],self.units.wind)
			weather_data['forecasts'][i]['avehumidity'] = '%s %%'%gvff('avehumidity',i,parsed_json)
			weather_data['forecasts'][i]['maxhumidity'] = '%s %%'%gvff('maxhumidity',i,parsed_json)
			weather_data['forecasts'][i]['minhumidity'] = '%s %%'%gvff('minhumidity',i,parsed_json)
			#
			condition = gvff('conditions',i,parsed_json).lower()
			weather_data['forecasts'][i]['condition'] = condition
			weather_data['forecasts'][i]['condition_text'] = weatherservice.get_condition(condition,'text')
			weather_data['forecasts'][i]['condition_image'] = weatherservice.get_condition(condition,'image')
			weather_data['forecasts'][i]['condition_icon'] = weatherservice.get_condition(condition,'icon-light')
		weather_data['forecast_information']['city'] = gvfi('city',parsed_json)
		weather_data['forecast_information']['postal_code'] = gvfi('zip',parsed_json)
		weather_data['forecast_information']['latitude_e6'] = gvfi('latitude',parsed_json)
		weather_data['forecast_information']['longitude_e6'] = gvfi('longitude',parsed_json)
		return weather_data
	def get_weather(self):
		weather_data = self.get_default_values()
		xml_response = download_xml(self.url)		
		root = etree.fromstring(xml_response).xpath('/data/parameters/temperature')
		try:
			#
			xml_response = download_xml(self.url)		
			root = etree.fromstring(xml_response).xpath('/data/parameters/temperature')
			if len(root) == 0:
				raise urllib2.URLError('Root 0')
			temperature = get_data(root[0],'temp_f')
			velocity = get_data(root[0],'wind_condition')
			velocity = weatherservice.s2f(velocity.split(' ')[3])
			humidity = weatherservice.get_humidity(get_data(root[0],'humidity'))
			condition = get_data(root[0],'condition').lower()
			weather_data['current_conditions']['condition'] = condition
			weather_data['current_conditions']['condition_text'] = weatherservice.get_condition(condition,'text')
			if weatherservice.is_day_now(weather_data['current_conditions']['sunrise_time'],weather_data['current_conditions']['sunset_time']):
				weather_data['current_conditions']['condition_image'] = weatherservice.get_condition(condition,'image')
				weather_data['current_conditions']['condition_icon_dark'] = weatherservice.get_condition(condition,'icon-dark')
				weather_data['current_conditions']['condition_icon_light'] = weatherservice.get_condition(condition,'icon-light')
			else:
				weather_data['current_conditions']['condition_image'] = weatherservice.get_condition(condition,'image-night')
				weather_data['current_conditions']['condition_icon_dark'] = weatherservice.get_condition(condition,'icon-night-dark')
				weather_data['current_conditions']['condition_icon_light'] = weatherservice.get_condition(condition,'icon-night-light')
			weather_data['current_conditions']['temperature'] = weatherservice.change_temperature(temperature,self.units.temperature)
			weather_data['current_conditions']['pressure'] = None
			weather_data['current_conditions']['humidity'] = '%s %%'%(humidity)
			weather_data['current_conditions']['dew_point'] = weatherservice.get_dew_point(humidity,temperature,self.units.temperature)
			wind =get_data(root[0],'wind_condition')
			wind_direction = wind.split(' ')[1]
			wind_direction = wind_direction.lower()
			wind_velocity = wind.split(' ')
			weather_data['current_conditions']['wind_condition'] = weatherservice.get_wind_condition(wind_velocity,wind_direction,self.units.wind)
			#
			weather_data['current_conditions']['heat_index'] = weatherservice.get_heat_index(temperature,humidity)
			weather_data['current_conditions']['windchill'] = weatherservice.get_wind_chill(temperature,wind_velocity)
			#
			weather_data['current_conditions']['feels_like'] = weatherservice.get_feels_like(temperature,humidity,velocity,self.units.temperature)
			#
			weather_data['current_conditions']['visibility'] = None
			weather_data['current_conditions']['solarradiation'] = None
			weather_data['current_conditions']['UV'] = None
			weather_data['current_conditions']['precip_1hr'] = None
			weather_data['current_conditions']['precip_today'] = None
			#
			root = etree.fromstring(xml_response).xpath('/xml_api_reply/weather/forecast_conditions')
			for i,el in enumerate(root):
				weather_data['forecasts'][i]['low'] = weatherservice.change_temperature(get_data(el,'low'),self.units.temperature)
				weather_data['forecasts'][i]['high'] = weatherservice.change_temperature(get_data(el,'high'),self.units.temperature)
				#
				weather_data['forecasts'][i]['qpf_allday'] = None
				weather_data['forecasts'][i]['qpf_day'] = None
				weather_data['forecasts'][i]['qpf_night'] = None
				weather_data['forecasts'][i]['snow_allday'] = None
				weather_data['forecasts'][i]['snow_day'] = None
				weather_data['forecasts'][i]['snow_night'] = None
				weather_data['forecasts'][i]['maxwind'] = None
				weather_data['forecasts'][i]['avewind'] = None
				weather_data['forecasts'][i]['avehumidity'] = None
				weather_data['forecasts'][i]['maxhumidity'] = None
				weather_data['forecasts'][i]['minhumidity'] = None
				#
				condition = get_data(el,'condition').lower()
				weather_data['forecasts'][i]['condition'] = condition
				weather_data['forecasts'][i]['condition_text'] = weatherservice.get_condition(condition,'text')
				weather_data['forecasts'][i]['condition_image'] = weatherservice.get_condition(condition,'image')
				weather_data['forecasts'][i]['condition_icon'] = weatherservice.get_condition(condition,'icon-light')				
			#
			root = etree.fromstring(xml_response).xpath('/xml_api_reply/weather/forecast_information')
			forecast_information = {}
			weather_data['forecast_information']['city'] = get_data(root[0],'city')
			weather_data['forecast_information']['postal_code'] = get_data(root[0],'postal_code')
			weather_data['forecast_information']['latitude_e6'] = get_data(root[0],'latitude_e6')
			weather_data['forecast_information']['longitude_e6'] = get_data(root[0],'longitude_e6')
			weather_data['forecast_information']['forecast_date'] = get_data(root[0],'forecast_date')
			weather_data['forecast_information']['current_date_time'] = get_data(root[0],'current_date_time')
			weather_data['forecast_information']['unit_system'] = get_data(root[0],'unit_system')
			return weather_data
		except Exception as e:
			print(e)
		return weather_data
 def get_weather(self):
     weather_data = self.get_default_values()
     if self.latlontrouble:
         temp = self.url2
         self.url2 = self.url1
         self.url1 = temp
         self.latlontrouble = False
     for i in range(0, 6):
         if i < 3:
             URL = self.url1
             self.latlontrouble = False
         else:
             URL = self.url2
             self.latlontrouble = True
         try:
             #
             xml_response = download_xml(URL)
             root = etree.fromstring(xml_response).xpath('/xml_api_reply/weather/current_conditions')
             if len(root) == 0:
                 raise Exception('Root 0')
             temperature = get_data(root[0], 'temp_f')
             velocity = get_data(root[0], 'wind_condition')
             velocity = cf.s2f(velocity.split(' ')[3])
             humidity = weatherservice.get_humidity(get_data(root[0], 'humidity'))
             condition = get_data(root[0], 'condition').lower()
             weather_data['current_conditions']['condition'] = condition
             weather_data['current_conditions']['condition_text'] = weatherservice.get_condition(condition, 'text')
             if weatherservice.is_day_now(weather_data['current_conditions']['sunrise_time'], weather_data['current_conditions']['sunset_time']):
                 weather_data['current_conditions']['condition_image'] = weatherservice.get_condition(condition, 'image')
                 weather_data['current_conditions']['condition_icon_dark'] = weatherservice.get_condition(condition, 'icon-dark')
                 weather_data['current_conditions']['condition_icon_light'] = weatherservice.get_condition(condition, 'icon-light')
             else:
                 weather_data['current_conditions']['condition_image'] = weatherservice.get_condition(condition, 'image-night')
                 weather_data['current_conditions']['condition_icon_dark'] = weatherservice.get_condition(condition, 'icon-night-dark')
                 weather_data['current_conditions']['condition_icon_light'] = weatherservice.get_condition(condition, 'icon-night-light')
             weather_data['current_conditions']['temperature'] = cf.change_temperature(temperature, self.units.temperature)
             weather_data['current_conditions']['pressure'] = None
             weather_data['current_conditions']['humidity'] = '%s %%' % (humidity)
             weather_data['current_conditions']['dew_point'] = weatherservice.get_dew_point(humidity, temperature, self.units.temperature)
             wind = get_data(root[0], 'wind_condition')
             wind_direction = wind.split(' ')[1]
             wind_direction = wind_direction.lower()
             wind_velocity = wind.split(' ')
             weather_data['current_conditions']['wind_condition'] = weatherservice.get_wind_condition(wind_velocity, wind_direction, self.units.wind)
             #
             weather_data['current_conditions']['heat_index'] = weatherservice.get_heat_index(temperature, humidity)
             weather_data['current_conditions']['windchill'] = weatherservice.get_wind_chill(temperature, wind_velocity)
             #
             weather_data['current_conditions']['feels_like'] = weatherservice.get_feels_like(temperature, humidity, velocity, self.units.temperature)
             #
             weather_data['current_conditions']['visibility'] = None
             weather_data['current_conditions']['solarradiation'] = None
             weather_data['current_conditions']['UV'] = None
             weather_data['current_conditions']['precip_1hr'] = None
             weather_data['current_conditions']['precip_today'] = None
             #
             root = etree.fromstring(xml_response).xpath('/xml_api_reply/weather/forecast_conditions')
             for i, el in enumerate(root):
                 weather_data['forecasts'][i]['low'] = cf.change_temperature(get_data(el, 'low'), self.units.temperature)
                 weather_data['forecasts'][i]['high'] = cf.change_temperature(get_data(el, 'high'), self.units.temperature)
                 #
                 weather_data['forecasts'][i]['qpf_allday'] = None
                 weather_data['forecasts'][i]['qpf_day'] = None
                 weather_data['forecasts'][i]['qpf_night'] = None
                 weather_data['forecasts'][i]['snow_allday'] = None
                 weather_data['forecasts'][i]['snow_day'] = None
                 weather_data['forecasts'][i]['snow_night'] = None
                 weather_data['forecasts'][i]['maxwind'] = None
                 weather_data['forecasts'][i]['avewind'] = None
                 weather_data['forecasts'][i]['avehumidity'] = None
                 weather_data['forecasts'][i]['maxhumidity'] = None
                 weather_data['forecasts'][i]['minhumidity'] = None
                 #
                 condition = get_data(el, 'condition').lower()
                 weather_data['forecasts'][i]['condition'] = condition
                 weather_data['forecasts'][i]['condition_text'] = weatherservice.get_condition(condition, 'text')
                 weather_data['forecasts'][i]['condition_image'] = weatherservice.get_condition(condition, 'image')
                 weather_data['forecasts'][i]['condition_icon'] = weatherservice.get_condition(condition, 'icon-light')
             #
             root = etree.fromstring(xml_response).xpath('/xml_api_reply/weather/forecast_information')
             weather_data['forecast_information']['city'] = get_data(root[0], 'city')
             weather_data['forecast_information']['postal_code'] = get_data(root[0], 'postal_code')
             weather_data['forecast_information']['latitude_e6'] = get_data(root[0], 'latitude_e6')
             weather_data['forecast_information']['longitude_e6'] = get_data(root[0], 'longitude_e6')
             weather_data['forecast_information']['forecast_date'] = get_data(root[0], 'forecast_date')
             weather_data['forecast_information']['current_date_time'] = get_data(root[0], 'current_date_time')
             weather_data['forecast_information']['unit_system'] = get_data(root[0], 'unit_system')
             return weather_data
         except Exception as e:
             time.sleep(1)
             if i > 3:
                 print(e)
     return weather_data
 def get_weather(self):
     weather_data = self.get_default_values()
     if self.latlontrouble:
         temp = self.url2
         self.url2 = self.url1
         self.url1 = temp
         self.latlontrouble = False
     for i in range(0, 6):
         if i < 3:
             URL = self.url1
             self.latlontrouble = False
         else:
             URL = self.url2
             self.latlontrouble = True
         try:
             #
             xml_response = download_xml(URL)
             root = etree.fromstring(xml_response).xpath("/xml_api_reply/weather/current_conditions")
             if len(root) == 0:
                 raise Exception("Root 0")
             temperature = get_data(root[0], "temp_f")
             velocity = get_data(root[0], "wind_condition")
             velocity = weatherservice.s2f(velocity.split(" ")[3])
             humidity = weatherservice.get_humidity(get_data(root[0], "humidity"))
             condition = get_data(root[0], "condition").lower()
             weather_data["current_conditions"]["condition"] = condition
             weather_data["current_conditions"]["condition_text"] = weatherservice.get_condition(condition, "text")
             if weatherservice.is_day_now(
                 weather_data["current_conditions"]["sunrise_time"],
                 weather_data["current_conditions"]["sunset_time"],
             ):
                 weather_data["current_conditions"]["condition_image"] = weatherservice.get_condition(
                     condition, "image"
                 )
                 weather_data["current_conditions"]["condition_icon_dark"] = weatherservice.get_condition(
                     condition, "icon-dark"
                 )
                 weather_data["current_conditions"]["condition_icon_light"] = weatherservice.get_condition(
                     condition, "icon-light"
                 )
             else:
                 weather_data["current_conditions"]["condition_image"] = weatherservice.get_condition(
                     condition, "image-night"
                 )
                 weather_data["current_conditions"]["condition_icon_dark"] = weatherservice.get_condition(
                     condition, "icon-night-dark"
                 )
                 weather_data["current_conditions"]["condition_icon_light"] = weatherservice.get_condition(
                     condition, "icon-night-light"
                 )
             weather_data["current_conditions"]["temperature"] = weatherservice.change_temperature(
                 temperature, self.units.temperature
             )
             weather_data["current_conditions"]["pressure"] = None
             weather_data["current_conditions"]["humidity"] = "%s %%" % (humidity)
             weather_data["current_conditions"]["dew_point"] = weatherservice.get_dew_point(
                 humidity, temperature, self.units.temperature
             )
             wind = get_data(root[0], "wind_condition")
             wind_direction = wind.split(" ")[1]
             wind_direction = wind_direction.lower()
             wind_velocity = wind.split(" ")
             weather_data["current_conditions"]["wind_condition"] = weatherservice.get_wind_condition(
                 wind_velocity, wind_direction, self.units.wind
             )
             #
             weather_data["current_conditions"]["heat_index"] = weatherservice.get_heat_index(temperature, humidity)
             weather_data["current_conditions"]["windchill"] = weatherservice.get_wind_chill(
                 temperature, wind_velocity
             )
             #
             weather_data["current_conditions"]["feels_like"] = weatherservice.get_feels_like(
                 temperature, humidity, velocity, self.units.temperature
             )
             #
             weather_data["current_conditions"]["visibility"] = None
             weather_data["current_conditions"]["solarradiation"] = None
             weather_data["current_conditions"]["UV"] = None
             weather_data["current_conditions"]["precip_1hr"] = None
             weather_data["current_conditions"]["precip_today"] = None
             #
             root = etree.fromstring(xml_response).xpath("/xml_api_reply/weather/forecast_conditions")
             for i, el in enumerate(root):
                 weather_data["forecasts"][i]["low"] = weatherservice.change_temperature(
                     get_data(el, "low"), self.units.temperature
                 )
                 weather_data["forecasts"][i]["high"] = weatherservice.change_temperature(
                     get_data(el, "high"), self.units.temperature
                 )
                 #
                 weather_data["forecasts"][i]["qpf_allday"] = None
                 weather_data["forecasts"][i]["qpf_day"] = None
                 weather_data["forecasts"][i]["qpf_night"] = None
                 weather_data["forecasts"][i]["snow_allday"] = None
                 weather_data["forecasts"][i]["snow_day"] = None
                 weather_data["forecasts"][i]["snow_night"] = None
                 weather_data["forecasts"][i]["maxwind"] = None
                 weather_data["forecasts"][i]["avewind"] = None
                 weather_data["forecasts"][i]["avehumidity"] = None
                 weather_data["forecasts"][i]["maxhumidity"] = None
                 weather_data["forecasts"][i]["minhumidity"] = None
                 #
                 condition = get_data(el, "condition").lower()
                 weather_data["forecasts"][i]["condition"] = condition
                 weather_data["forecasts"][i]["condition_text"] = weatherservice.get_condition(condition, "text")
                 weather_data["forecasts"][i]["condition_image"] = weatherservice.get_condition(condition, "image")
                 weather_data["forecasts"][i]["condition_icon"] = weatherservice.get_condition(
                     condition, "icon-light"
                 )
             #
             root = etree.fromstring(xml_response).xpath("/xml_api_reply/weather/forecast_information")
             forecast_information = {}
             weather_data["forecast_information"]["city"] = get_data(root[0], "city")
             weather_data["forecast_information"]["postal_code"] = get_data(root[0], "postal_code")
             weather_data["forecast_information"]["latitude_e6"] = get_data(root[0], "latitude_e6")
             weather_data["forecast_information"]["longitude_e6"] = get_data(root[0], "longitude_e6")
             weather_data["forecast_information"]["forecast_date"] = get_data(root[0], "forecast_date")
             weather_data["forecast_information"]["current_date_time"] = get_data(root[0], "current_date_time")
             weather_data["forecast_information"]["unit_system"] = get_data(root[0], "unit_system")
             return weather_data
         except Exception as e:
             time.sleep(1)
             if i > 3:
                 print(e)
     return weather_data