Merge pull request #854 from mihaimorariu/fix/publicip-exception

Fix publicip
This commit is contained in:
tobi-wan-kenobi 2022-02-14 15:19:58 +01:00 committed by GitHub
commit 8897c1bde5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View file

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

View file

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