[modules/sun] quotes
This commit is contained in:
parent
b29c0594c9
commit
635373e9a0
1 changed files with 12 additions and 12 deletions
|
@ -38,13 +38,13 @@ class Module(bumblebee.engine.Module):
|
||||||
bumblebee.output.Widget(full_text=self.suntimes)
|
bumblebee.output.Widget(full_text=self.suntimes)
|
||||||
)
|
)
|
||||||
self.interval(3600)
|
self.interval(3600)
|
||||||
self._lat = self.parameter("lat", None)
|
self._lat = self.parameter('lat', None)
|
||||||
self._lon = self.parameter("lon", None)
|
self._lon = self.parameter('lon', None)
|
||||||
try:
|
try:
|
||||||
if not self._lat or not self._lon:
|
if not self._lat or not self._lon:
|
||||||
location_url = "http://ipinfo.io/json"
|
location_url = 'http://ipinfo.io/json'
|
||||||
location = requests.get(location_url).json()
|
location = requests.get(location_url).json()
|
||||||
self._lat, self._lon = location["loc"].split(",")
|
self._lat, self._lon = location['loc'].split(',')
|
||||||
self._lat = float(self._lat)
|
self._lat = float(self._lat)
|
||||||
self._lon = float(self._lon)
|
self._lon = float(self._lon)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
@ -54,12 +54,12 @@ class Module(bumblebee.engine.Module):
|
||||||
def suntimes(self, _):
|
def suntimes(self, _):
|
||||||
if self._sunset and self._sunrise:
|
if self._sunset and self._sunrise:
|
||||||
if self._isup:
|
if self._isup:
|
||||||
return u"\u21A7{} \u21A5{}".format(
|
return u'\u21A7{} \u21A5{}'.format(
|
||||||
self._sunset.strftime('%H:%M'),
|
self._sunset.strftime('%H:%M'),
|
||||||
self._sunrise.strftime('%H:%M'))
|
self._sunrise.strftime('%H:%M'))
|
||||||
return u"\u21A5{} \u21A7{}".format(self._sunrise.strftime('%H:%M'),
|
return u'\u21A5{} \u21A7{}'.format(self._sunrise.strftime('%H:%M'),
|
||||||
self._sunset.strftime('%H:%M'))
|
self._sunset.strftime('%H:%M'))
|
||||||
return "?"
|
return '?'
|
||||||
|
|
||||||
def _calculate_times(self):
|
def _calculate_times(self):
|
||||||
self._isup = False
|
self._isup = False
|
||||||
|
@ -77,13 +77,13 @@ class Module(bumblebee.engine.Module):
|
||||||
try:
|
try:
|
||||||
self._sunrise = sun.get_local_sunrise_time()
|
self._sunrise = sun.get_local_sunrise_time()
|
||||||
except SunTimeException:
|
except SunTimeException:
|
||||||
self._sunrise = "no sunrise"
|
self._sunrise = 'no sunrise'
|
||||||
order_matters = False
|
order_matters = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self._sunset = sun.get_local_sunset_time()
|
self._sunset = sun.get_local_sunset_time()
|
||||||
except SunTimeException:
|
except SunTimeException:
|
||||||
self._sunset = "no sunset"
|
self._sunset = 'no sunset'
|
||||||
order_matters = False
|
order_matters = False
|
||||||
|
|
||||||
if not order_matters:
|
if not order_matters:
|
||||||
|
@ -96,15 +96,15 @@ class Module(bumblebee.engine.Module):
|
||||||
self._sunrise = sun.get_local_sunrise_time(tomorrow)
|
self._sunrise = sun.get_local_sunrise_time(tomorrow)
|
||||||
self._sunset = sun.get_local_sunset_time(tomorrow)
|
self._sunset = sun.get_local_sunset_time(tomorrow)
|
||||||
except SunTimeException:
|
except SunTimeException:
|
||||||
self._sunrise = "no sunrise"
|
self._sunrise = 'no sunrise'
|
||||||
self._sunset = "no sunset"
|
self._sunset = 'no sunset'
|
||||||
|
|
||||||
elif now > self._sunrise:
|
elif now > self._sunrise:
|
||||||
tomorrow = (now + datetime.timedelta(days=1)).date()
|
tomorrow = (now + datetime.timedelta(days=1)).date()
|
||||||
try:
|
try:
|
||||||
self._sunrise = sun.get_local_sunrise_time(tomorrow)
|
self._sunrise = sun.get_local_sunrise_time(tomorrow)
|
||||||
except SunTimeException:
|
except SunTimeException:
|
||||||
self._sunrise = "no sunrise"
|
self._sunrise = 'no sunrise'
|
||||||
return
|
return
|
||||||
self._isup = True
|
self._isup = True
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue