|
|
|
@ -59,7 +59,8 @@ class WeatherToFreemobile(): |
|
|
|
|
fc = self.owm.daily_forecast(city, limit=number_of_days+1) |
|
|
|
|
f = fc.get_forecast() |
|
|
|
|
|
|
|
|
|
return_message = ["{} :".format(city)] |
|
|
|
|
return_message = ["{}".format(city)] |
|
|
|
|
return_message.append("") |
|
|
|
|
for weather in f: |
|
|
|
|
weather_date = weather.get_reference_time('date') |
|
|
|
|
date_diff = weather_date.date() - datetime.date.today() |
|
|
|
@ -78,16 +79,17 @@ class WeatherToFreemobile(): |
|
|
|
|
temp = weather.get_temperature(unit='celsius') |
|
|
|
|
rain = weather.get_rain().get('all', 0) |
|
|
|
|
return_message.append( |
|
|
|
|
'{}: {} (min {}ºC, max {}ºC, rain:{}mm)'.format( |
|
|
|
|
weather_date.strftime('%A %d').title(), |
|
|
|
|
weather.get_detailed_status(), |
|
|
|
|
round(float(temp['min'])), |
|
|
|
|
round(float(temp['max'])), |
|
|
|
|
rain |
|
|
|
|
'{date} : {weather}{rain}, {mini}ºC - {maxi}ºC'.format( |
|
|
|
|
date=weather_date.strftime('%A %d').title(), |
|
|
|
|
weather=weather.get_detailed_status(), |
|
|
|
|
mini=round(float(temp['min'])), |
|
|
|
|
maxi=round(float(temp['max'])), |
|
|
|
|
rain=" ({:.1f}mm)".format(rain) if rain else "" |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
if(rain and date_diff == datetime.timedelta(0)): |
|
|
|
|
return_message.append(self.get_rain()) |
|
|
|
|
return_message.append("") |
|
|
|
|
|
|
|
|
|
logging.info("Got the following weather: {}".format(return_message)) |
|
|
|
|
return "\n".join(return_message) |
|
|
|
|