@@ -46,8 +46,8 @@ def get_request(tries, ping):
4646 for i in range (tries ):
4747 try :
4848 n = ping
49- except RuntimeError as e :
50- print (e )
49+ except Exception as error :
50+ print (error )
5151 time .sleep (10 )
5252 if i < tries - 1 :
5353 continue
@@ -82,7 +82,8 @@ def divide_time(z):
8282 clock_time = string_time [2 ].split ("T" )
8383 int_time = clock_time [1 ].split (":" )
8484 event_time = time .struct_time (
85- (int (string_time [0 ]), int (string_time [1 ]), int (clock_time [0 ]), int (int_time [0 ]), int (int_time [1 ]), 0 , - 1 , - 1 , False )
85+ (int (string_time [0 ]), int (string_time [1 ]), int (clock_time [0 ]), int (int_time [0 ]),
86+ int (int_time [1 ]), 0 , - 1 , - 1 , False )
8687 )
8788 # print(event_time)
8889 return event_time
@@ -96,7 +97,7 @@ def sun_countdown(sun_event):
9697 remaining = time .mktime (sun_event ) - time .mktime (n )
9798 # print(remaining)
9899 # calculate the seconds remaining
99- secs_remaining = remaining % 60
100+ secs_remaining = remaining % 60 # pylint: disable=unused-variable
100101 remaining //= 60
101102 # calculate the minutes remaining
102103 minutes_until = remaining % 60
@@ -143,10 +144,10 @@ def sun_countdown(sun_event):
143144 if not star_glow :
144145 # every 15 minutes...
145146 if first_run or ticks_diff (ticks_ms (), clock ) > time_check :
146- first_run = False
147147 print ("pinging Open-Meteo" )
148148 sunrise , sunset = sun_clock ()
149- total_until_set , hours_until_sunset , mins_until_sunset , now = sun_countdown (set_time )
149+ (total_until_set , hours_until_sunset ,
150+ mins_until_sunset , now ) = sun_countdown (set_time )
150151 print ("%d hour(s) until sunset" % hours_until_sunset )
151152 print ("%d minutes(s) until sunset" % mins_until_sunset )
152153 print (sunset )
@@ -170,20 +171,23 @@ def sun_countdown(sun_event):
170171 time_check = 900000
171172 percent_red = 0
172173 percent_yellow = 0
173- # reset clock
174- clock = ticks_add (clock , time_check )
174+ if first_run :
175+ first_run = False
176+ else :
177+ # reset clock
178+ clock = ticks_add (clock , time_check )
175179 # if it's nighttime...
176180 else :
177181 if first_run or ticks_diff (ticks_ms (), clock ) > time_check :
178- first_run = False
179182 if today != now .tm_mday or (first_run and now .tm_hour < rise_time .tm_hour ):
180183 today = now .tm_mday
181184 looking_for_sunrise = True
182185 # begin tracking the incoming sunrise
183- if looking_for_sunrise :
186+ elif looking_for_sunrise :
184187 print ("pinging Open-Meteo" )
185188 sunrise , sunset = sun_clock ()
186- total_until_set , hours_until_sunset , mins_until_sunset , now = sun_countdown (rise_time )
189+ (total_until_set , hours_until_sunset ,
190+ mins_until_sunset , now ) = sun_countdown (rise_time )
187191 print ("%d hour(s) until sunrise" % hours_until_sunrise )
188192 print ("%d minutes(s) until sunrise" % mins_until_sunrise )
189193 print (sunrise )
@@ -220,9 +224,11 @@ def sun_countdown(sun_event):
220224 time_check = 900000
221225 percent_red = 255
222226 percent_yellow = 125
223- first_run = False
224- # reset clock
225- clock = ticks_add (clock , time_check )
227+ if first_run :
228+ first_run = False
229+ else :
230+ # reset clock
231+ clock = ticks_add (clock , time_check )
226232 # turn neopixels on using RGB values
227233 pixels .fill ((percent_red , percent_yellow , 0 ))
228234 pixels .show ()
0 commit comments