@@ -46,8 +46,8 @@ def get_request(tries, ping):
46
46
for i in range (tries ):
47
47
try :
48
48
n = ping
49
- except RuntimeError as e :
50
- print (e )
49
+ except Exception as error :
50
+ print (error )
51
51
time .sleep (10 )
52
52
if i < tries - 1 :
53
53
continue
@@ -82,7 +82,8 @@ def divide_time(z):
82
82
clock_time = string_time [2 ].split ("T" )
83
83
int_time = clock_time [1 ].split (":" )
84
84
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 )
86
87
)
87
88
# print(event_time)
88
89
return event_time
@@ -96,7 +97,7 @@ def sun_countdown(sun_event):
96
97
remaining = time .mktime (sun_event ) - time .mktime (n )
97
98
# print(remaining)
98
99
# calculate the seconds remaining
99
- secs_remaining = remaining % 60
100
+ secs_remaining = remaining % 60 # pylint: disable=unused-variable
100
101
remaining //= 60
101
102
# calculate the minutes remaining
102
103
minutes_until = remaining % 60
@@ -143,10 +144,10 @@ def sun_countdown(sun_event):
143
144
if not star_glow :
144
145
# every 15 minutes...
145
146
if first_run or ticks_diff (ticks_ms (), clock ) > time_check :
146
- first_run = False
147
147
print ("pinging Open-Meteo" )
148
148
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 )
150
151
print ("%d hour(s) until sunset" % hours_until_sunset )
151
152
print ("%d minutes(s) until sunset" % mins_until_sunset )
152
153
print (sunset )
@@ -170,20 +171,23 @@ def sun_countdown(sun_event):
170
171
time_check = 900000
171
172
percent_red = 0
172
173
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 )
175
179
# if it's nighttime...
176
180
else :
177
181
if first_run or ticks_diff (ticks_ms (), clock ) > time_check :
178
- first_run = False
179
182
if today != now .tm_mday or (first_run and now .tm_hour < rise_time .tm_hour ):
180
183
today = now .tm_mday
181
184
looking_for_sunrise = True
182
185
# begin tracking the incoming sunrise
183
- if looking_for_sunrise :
186
+ elif looking_for_sunrise :
184
187
print ("pinging Open-Meteo" )
185
188
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 )
187
191
print ("%d hour(s) until sunrise" % hours_until_sunrise )
188
192
print ("%d minutes(s) until sunrise" % mins_until_sunrise )
189
193
print (sunrise )
@@ -220,9 +224,11 @@ def sun_countdown(sun_event):
220
224
time_check = 900000
221
225
percent_red = 255
222
226
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 )
226
232
# turn neopixels on using RGB values
227
233
pixels .fill ((percent_red , percent_yellow , 0 ))
228
234
pixels .show ()
0 commit comments