Fix buggy fix for #3
This commit is contained in:
@ -59,13 +59,16 @@ class WeatherToFreemobile():
|
|||||||
return_message=[]
|
return_message=[]
|
||||||
for weather in f:
|
for weather in f:
|
||||||
weather_date = weather.get_reference_time('date')
|
weather_date = weather.get_reference_time('date')
|
||||||
|
date_diff = weather_date.date() - datetime.date.today()
|
||||||
|
|
||||||
#Workaround API returning yesterday's weather"
|
#Workaround API returning yesterday's weather"
|
||||||
#https://openweathermap.desk.com/customer/en/portal/questions/
|
#https://openweathermap.desk.com/customer/en/portal/questions/
|
||||||
#17649060-between-hours-of-12-midnight-and-7am-gmt-we-are-receiving
|
#17649060-between-hours-of-12-midnight-and-7am-gmt-we-are-receiving
|
||||||
#-the-wrong-data-for-most-locations
|
#-the-wrong-data-for-most-locations
|
||||||
if( abs(weather_date.date()-datetime.date.today())
|
if(
|
||||||
>= datetime.timedelta(days=number_of_days)
|
date_diff < datetime.timedelta(0)
|
||||||
|
or
|
||||||
|
date_diff >= datetime.timedelta(number_of_days)
|
||||||
):
|
):
|
||||||
logging.info('Skipped {} (cf. API Bug)'.format(weather_date))
|
logging.info('Skipped {} (cf. API Bug)'.format(weather_date))
|
||||||
else:
|
else:
|
||||||
@ -86,7 +89,7 @@ class WeatherToFreemobile():
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.WARNING,
|
level=logging.INFO,
|
||||||
format=' %(asctime)s - %(levelname)s - %(message)s'
|
format=' %(asctime)s - %(levelname)s - %(message)s'
|
||||||
)
|
)
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
|
Reference in New Issue
Block a user