Fix exception in location.py.

This commit is contained in:
Mihai Morariu 2022-02-14 15:36:24 +02:00
parent 8458eef1e6
commit 2a77e3a85c
2 changed files with 11 additions and 3 deletions

View file

@ -39,7 +39,11 @@ class Module(core.module.Module):
self.__sun = None self.__sun = None
if not lat or not lon: if not lat or not lon:
lat, lon = util.location.coordinates() try:
lat, lon = util.location.coordinates()
except Exception:
pass
if lat and lon: if lat and lon:
self.__sun = Sun(float(lat), float(lon)) self.__sun = Sun(float(lat), float(lon))
@ -55,6 +59,10 @@ class Module(core.module.Module):
return "n/a" return "n/a"
def __calculate_times(self): def __calculate_times(self):
if not self.__sun:
self.__sunset = self.__sunrise = None
return
self.__isup = False self.__isup = False
order_matters = True order_matters = True

View file

@ -59,11 +59,11 @@ def __load():
__next = time.time() + 60 * 30 # error - try again every 30m __next = time.time() + 60 * 30 # error - try again every 30m
def __get(name, default=None): def __get(name):
global __data global __data
if not __data or __expired(): if not __data or __expired():
__load() __load()
return __data.get(name, default) return __data[name]
def reset(): def reset():