Fixed timeout exception realated to weather
This commit is contained in:
parent
c09a5d51c4
commit
077d841cab
2 changed files with 14 additions and 7 deletions
|
@ -22,12 +22,15 @@ class OwmForecasts (WeatherInterface):
|
||||||
if self.is_available() is False:
|
if self.is_available() is False:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
location = self.location if location is None else location
|
try:
|
||||||
|
location = self.location if location is None else location
|
||||||
|
|
||||||
observation = self.api.weather_at_place(location)
|
observation = self.api.weather_at_place(location)
|
||||||
weather = observation.get_weather()
|
weather = observation.get_weather()
|
||||||
|
|
||||||
return self.__get_forecast_from_weather__(weather, location=location)
|
return self.__get_forecast_from_weather__(weather, location=location)
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
def get_forecast_in_days (self, offset_by_days, location=None):
|
def get_forecast_in_days (self, offset_by_days, location=None):
|
||||||
if offset_by_days is 0:
|
if offset_by_days is 0:
|
||||||
|
@ -42,7 +45,7 @@ class OwmForecasts (WeatherInterface):
|
||||||
target_weather = forecast.get_forecast().get_weathers()[-1]
|
target_weather = forecast.get_forecast().get_weathers()[-1]
|
||||||
|
|
||||||
return self.__get_forecast_from_weather__(target_weather, location=location)
|
return self.__get_forecast_from_weather__(target_weather, location=location)
|
||||||
except: # only allowed for paied membership
|
except: # only allowed for paid membership
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def __get_forecast_from_weather__ (self, weather, location):
|
def __get_forecast_from_weather__ (self, weather, location):
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from DesignEntity import DesignEntity
|
from DesignEntity import DesignEntity
|
||||||
from Assets import *
|
from Assets import no_response, windicon, tempicon, sunseticon, sunriseicon, wpath, weathericons, humicon
|
||||||
from TextDesign import TextDesign
|
from TextDesign import TextDesign
|
||||||
from settings import units, hours
|
from settings import units, hours
|
||||||
|
|
||||||
|
@ -24,6 +24,10 @@ class WeatherHeaderDesign (DesignEntity):
|
||||||
|
|
||||||
cur_weather = self.__weather__.get_today_forecast()
|
cur_weather = self.__weather__.get_today_forecast()
|
||||||
|
|
||||||
|
if cur_weather == None:
|
||||||
|
self.__render_missing_connection__()
|
||||||
|
return
|
||||||
|
|
||||||
temperature = cur_weather.air_temperature + " " + self.__get_unit__(("°C", "°F"))
|
temperature = cur_weather.air_temperature + " " + self.__get_unit__(("°C", "°F"))
|
||||||
windspeed = cur_weather.wind_speed + " " + self.__get_unit__(("km/h", "mph"))
|
windspeed = cur_weather.wind_speed + " " + self.__get_unit__(("km/h", "mph"))
|
||||||
|
|
||||||
|
@ -42,7 +46,7 @@ class WeatherHeaderDesign (DesignEntity):
|
||||||
self.draw_image(wpath + weathericons[cur_weather.icon] + '.jpeg', self.__abs_pos__(wiconplace))
|
self.draw_image(wpath + weathericons[cur_weather.icon] + '.jpeg', self.__abs_pos__(wiconplace))
|
||||||
|
|
||||||
def __render_missing_connection__ (self):
|
def __render_missing_connection__ (self):
|
||||||
self.draw_image(no_response, self.__abs_pos__(wiconplace))
|
self.draw(no_response, self.__abs_pos__(wiconplace))
|
||||||
|
|
||||||
def __abs_pos__ (self, pos):
|
def __abs_pos__ (self, pos):
|
||||||
return (int(pos[0] * self.size[0]), int(pos[1] * self.size[1]))
|
return (int(pos[0] * self.size[0]), int(pos[1] * self.size[1]))
|
||||||
|
|
Loading…
Reference in a new issue