@require(internet)<EOL><INDENT>def check_weather(self):<DEDENT>
if self.units not in ('<STR_LIT>', '<STR_LIT>'):<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>if self.location_code is None:<EOL><INDENT>self.logger.error(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>)<EOL>self.data['<STR_LIT>'] = self.update_error<EOL>return<EOL><DEDENT>self.data['<STR_LIT>'] = '<STR_LIT>'<EOL>try:<EOL><INDENT>self.parser.get_weather_data(self.forecast_url)<EOL>if self.parser.weather_data is None:<EOL><INDENT>self.logger.error(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>)<EOL>self.data['<STR_LIT>'] = self.update_error<EOL>return<EOL><DEDENT>try:<EOL><INDENT>observed = self.parser.weather_data['<STR_LIT>']<EOL>observed = observed[next(iter(observed))]['<STR_LIT:data>']['<STR_LIT>']<EOL><DEDENT>except KeyError:<EOL><INDENT>self.logger.error(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>)<EOL>self.data['<STR_LIT>'] = self.update_error<EOL>return<EOL><DEDENT>try:<EOL><INDENT>forecast = self.parser.weather_data['<STR_LIT>']<EOL>forecast = forecast[next(iter(forecast))]<EOL>forecast = forecast['<STR_LIT:data>']['<STR_LIT>'][<NUM_LIT:0>]<EOL><DEDENT>except (IndexError, KeyError):<EOL><INDENT>self.logger.error(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>)<EOL>self.data['<STR_LIT>'] = self.update_error<EOL>return<EOL><DEDENT>try:<EOL><INDENT>self.city_name = self.parser.weather_data['<STR_LIT>']<EOL>self.city_name = self.city_name[next(iter(self.city_name))]<EOL>self.city_name = self.city_name['<STR_LIT:data>']['<STR_LIT>']<EOL><DEDENT>except KeyError:<EOL><INDENT>self.logger.warning(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>', self.location_code<EOL>)<EOL>self.city_name = self.location_code<EOL><DEDENT>try:<EOL><INDENT>observation_time_str = str(observed.get('<STR_LIT>', '<STR_LIT>'))<EOL>observation_time = datetime.strptime(observation_time_str,<EOL>'<STR_LIT>')<EOL><DEDENT>except (ValueError, AttributeError):<EOL><INDENT>observation_time = datetime.fromtimestamp(<NUM_LIT:0>)<EOL><DEDENT>try:<EOL><INDENT>pressure_trend_str = observed.get('<STR_LIT>', '<STR_LIT>').lower()<EOL><DEDENT>except AttributeError:<EOL><INDENT>pressure_trend_str = '<STR_LIT>'<EOL><DEDENT>if pressure_trend_str == '<STR_LIT>':<EOL><INDENT>pressure_trend = '<STR_LIT:+>'<EOL><DEDENT>elif pressure_trend_str == '<STR_LIT>':<EOL><INDENT>pressure_trend = '<STR_LIT:->'<EOL><DEDENT>else:<EOL><INDENT>pressure_trend = '<STR_LIT>'<EOL><DEDENT>try:<EOL><INDENT>high_temp = forecast.get('<STR_LIT>', {}).get('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>except (AttributeError, IndexError):<EOL><INDENT>high_temp = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>if high_temp is None:<EOL><INDENT>high_temp = '<STR_LIT>'<EOL><DEDENT><DEDENT>try:<EOL><INDENT>low_temp = forecast.get('<STR_LIT>', {}).get('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>except (AttributeError, IndexError):<EOL><INDENT>low_temp = '<STR_LIT>'<EOL><DEDENT>if self.units == '<STR_LIT>':<EOL><INDENT>temp_unit = '<STR_LIT>'<EOL>wind_unit = '<STR_LIT>'<EOL>pressure_unit = '<STR_LIT>'<EOL>visibility_unit = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>temp_unit = '<STR_LIT>'<EOL>wind_unit = '<STR_LIT>'<EOL>pressure_unit = '<STR_LIT>'<EOL>visibility_unit = '<STR_LIT>'<EOL><DEDENT>self.data['<STR_LIT>'] = self.city_name<EOL>self.data['<STR_LIT>'] = str(observed.get('<STR_LIT>', '<STR_LIT>'))<EOL>self.data['<STR_LIT>'] = observation_time<EOL>self.data['<STR_LIT>'] = str(observed.get('<STR_LIT>', '<STR_LIT>'))<EOL>self.data['<STR_LIT>'] = str(low_temp)<EOL>self.data['<STR_LIT>'] = str(high_temp)<EOL>self.data['<STR_LIT>'] = temp_unit<EOL>self.data['<STR_LIT>'] = str(observed.get('<STR_LIT>', '<STR_LIT>'))<EOL>self.data['<STR_LIT>'] = str(observed.get('<STR_LIT>', '<STR_LIT>'))<EOL>self.data['<STR_LIT>'] = str(observed.get('<STR_LIT>', '<STR_LIT>'))<EOL>self.data['<STR_LIT>'] = wind_unit<EOL>self.data['<STR_LIT>'] = str(observed.get('<STR_LIT>', '<STR_LIT>'))<EOL>self.data['<STR_LIT>'] = str(observed.get('<STR_LIT>', '<STR_LIT>') or '<STR_LIT>')<EOL>self.data['<STR_LIT>'] = str(observed.get('<STR_LIT>', '<STR_LIT>'))<EOL>self.data['<STR_LIT>'] = pressure_unit<EOL>self.data['<STR_LIT>'] = pressure_trend<EOL>self.data['<STR_LIT>'] = str(observed.get('<STR_LIT>', '<STR_LIT>'))<EOL>self.data['<STR_LIT>'] = visibility_unit<EOL>self.data['<STR_LIT>'] = str(observed.get('<STR_LIT>', '<STR_LIT>'))<EOL>self.data['<STR_LIT>'] = str(observed.get('<STR_LIT>', '<STR_LIT>'))<EOL><DEDENT>except Exception:<EOL><INDENT>self.logger.error(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>', exc_info=True<EOL>)<EOL>self.data['<STR_LIT>'] = self.update_error<EOL><DEDENT>
Fetches the current weather from wxdata.weather.com service.