|
|
|
@ -47,24 +47,27 @@ class WeatherToFreemobile(): |
|
|
|
|
city = self.config['openweathermap_city'] |
|
|
|
|
apikey = self.config['openweathermap_apikey'] |
|
|
|
|
apilanguage = self.config['openweathermap_language'] |
|
|
|
|
number_of_days = self.config['number_of_days'] |
|
|
|
|
|
|
|
|
|
logging.info('Opening OpenWeatherMap API') |
|
|
|
|
owm = pyowm.OWM(apikey,language=apilanguage) |
|
|
|
|
|
|
|
|
|
fc = owm.daily_forecast(city,limit=1) |
|
|
|
|
fc = owm.daily_forecast(city,limit=number_of_days) |
|
|
|
|
f = fc.get_forecast() |
|
|
|
|
return_message="" |
|
|
|
|
return_message=[] |
|
|
|
|
for weather in f: |
|
|
|
|
temp = weather.get_temperature(unit='celsius') |
|
|
|
|
return_message += '{} : {} (min {}ºC, max {}ºC, rain:{}mm)'.format( |
|
|
|
|
return_message.append( |
|
|
|
|
'{} : {} (min {}ºC, max {}ºC, rain:{}mm)'.format( |
|
|
|
|
weather.get_reference_time('date').strftime('%A %d').title(), |
|
|
|
|
weather.get_detailed_status(), |
|
|
|
|
round(float(temp['min'])), |
|
|
|
|
round(float(temp['max'])), |
|
|
|
|
weather.get_rain().get('all',0) |
|
|
|
|
weather.get_detailed_status(), |
|
|
|
|
round(float(temp['min'])), |
|
|
|
|
round(float(temp['max'])), |
|
|
|
|
weather.get_rain().get('all',0) |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
logging.info("Got the following weather: {}".format(return_message)) |
|
|
|
|
return return_message |
|
|
|
|
return "\n".join(return_message) |
|
|
|
|
|
|
|
|
|
if __name__ == "__main__": |
|
|
|
|
logging.basicConfig(level=logging.WARNING, format=' %(asctime)s - %(levelname)s - %(message)s') |
|
|
|
|