def wetter(bot, update): gotten_chat = bot.get_chat(chat_id=update.message.chat.id) # query weather data for "Weida, Germany" yweather = YahooWeather(704463, UNIT_C) print("Wetterdaten wurden empfangen") if yweather.updateWeather(): bot.send_message( chat_id=update.message.chat_id, text="Wetter f�r Weida, TH, Germany:" + "\nBeschreibung: " + str(yweather.Forecast[0]['text']) + "\nAktuelle Temperatur: " + emojize(" :arrow_right:", use_aliases=True) + " " + str(yweather.Now['temp']) + " �C" + emojize(" :arrow_left:", use_aliases=True) + "\nH�chsttemperatur: " + emojize(" :arrow_up:", use_aliases=True) + " " + str(yweather.Forecast[0]['high']) + " �C" + emojize(" :arrow_up:", use_aliases=True) + "\nNiedrigsttemperatur: " + emojize(" :arrow_down:", use_aliases=True) + " " + str(yweather.Forecast[0]['low']) + " �C" + emojize(" :arrow_down:", use_aliases=True) + "\nSonnenaufgang: " + str(yweather.Astronomy['sunrise']) + emojize(" :arrow_heading_up:", use_aliases=True) + "\nSonnenuntergang: " + str(yweather.Astronomy['sunset']) + emojize(" :arrow_heading_down:", use_aliases=True)) # schickt aktuelle Wetterdaten print("und zu " + gotten_chat.first_name + " geschickt\n") else: bot.send_message( chat_id=update.message.chat_id, text="Konnte yahoo-Wetterdaten nicht empfangen!") # Fehlermeldung print("und konnten nicht zu " + gotten_chat.first_name + " geschickt werden\n") # Statusmeldung: Fehler bei Wetterdaten
class YahooWeatherData: """Handle the Yahoo! API object and limit updates.""" def __init__(self, woeid, temp_unit): """Initialize the data object.""" self._yahoo = YahooWeather(woeid, temp_unit) @property def yahoo(self): """Return Yahoo! API object.""" return self._yahoo def update(self): """Get the latest data from Yahoo!.""" return self._yahoo.updateWeather()
def predictWeather(woeid): logging.basicConfig(level=logging.WARNING) yweather = YahooWeather(woeid, UNIT_C) if yweather.updateWeather(): print("RawData: %s" % str(yweather.RawData)) print("Units: %s" % str(yweather.Units)) print("Now: %s" % str(yweather.Now)) print("Forecast: %s" % str(yweather.Forecast)) print("Wind: %s" % str(yweather.Wind)) print("Atmosphere: %s" % str(yweather.Atmosphere)) print("Astronomy: %s" % str(yweather.Astronomy)) return yweather.Now,yweather.Forecast,yweather.Wind,yweather.Atmosphere,yweather.Astronomy else: print("Can't read data from yahoo!")
class YahooWeatherData: """Handle Yahoo! API object and limit updates.""" def __init__(self, woeid, temp_unit): """Initialize the data object.""" from yahooweather import YahooWeather self._yahoo = YahooWeather(woeid, temp_unit) @property def yahoo(self): """Return Yahoo! API object.""" return self._yahoo @Throttle(MIN_TIME_BETWEEN_UPDATES) def update(self): """Get the latest data from Yahoo!.""" return self._yahoo.updateWeather()
class YahooWeatherData: """Handle the Yahoo! API object and limit updates.""" def __init__(self, woeid, temp_unit): """Initialize the data object.""" from yahooweather import YahooWeather self._yahoo = YahooWeather(woeid, temp_unit) @property def yahoo(self): """Return Yahoo! API object.""" return self._yahoo def update(self): """Get the latest data from Yahoo!.""" return self._yahoo.updateWeather()
class YahooWeatherData(object): """Handle yahoo api object and limit updates.""" def __init__(self, woeid, temp_unit): """Initialize the data object.""" from yahooweather import YahooWeather # init yahoo api object self._yahoo = YahooWeather(woeid, temp_unit) @property def yahoo(self): """Return yahoo api object.""" return self._yahoo @Throttle(MIN_TIME_BETWEEN_UPDATES) def update(self): """Get the latest data from yahoo. True is success.""" return self._yahoo.updateWeather()
import logging from yahooweather import YahooWeather, get_woeid, UNIT_C logging.basicConfig(level=logging.DEBUG) yweather = YahooWeather(91543049, UNIT_C) if yweather.updateWeather(): print("RawData: %s" % str(yweather.RawData)) print("Units: %s" % str(yweather.Units)) print("Now: %s" % str(yweather.Now)) print("Forecast: %s" % str(yweather.Forecast)) print("Wind: %s" % str(yweather.Wind)) print("Atmosphere: %s" % str(yweather.Atmosphere)) print("Astronomy: %s" % str(yweather.Astronomy)) data = yweather.Now print("Weather image from current: %s" % yweather.getWeatherImage(data["code"])) print("The woeid from Gstaad is: %s" % get_woeid(46.475661, 7.283469)) else: print("Can't read data from yahoo!")