Skip to content

Commit 288e6e0

Browse files
committed
add loop for try/except block
1 parent 715225e commit 288e6e0

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

PyPortal_Wakeup_Light/wake_up_light.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
default_wake_up)
3030
days_str = ("Mon.", "Tues.", "Wed.", "Thurs.", "Fri.", "Sat.", "Sun.")
3131

32+
# Bool varible for handing errors when getting time from internet
33+
time_true = True
34+
3235
# set neopixel min and max brightness
3336
BRIGHTNESS = 0
3437
MIN_BRIGHTNESS = 0
@@ -84,11 +87,15 @@
8487
pyportal.splash.append(wakeup_time_textarea)
8588
pyportal.splash.append(light_on_time_textarea)
8689

87-
try:
88-
print("Getting time from internet!")
89-
pyportal.get_local_time()
90-
except RuntimeError as e:
91-
print("Some error occured, retrying! -", e)
90+
while time_true:
91+
try:
92+
print("Getting time from internet!")
93+
pyportal.get_local_time()
94+
except RuntimeError as e:
95+
print("Some error occured, retrying! -", e)
96+
time_true = True
97+
continue
98+
time_true = False
9299

93100
# parse given time string into hour minute and AM_PM elements
94101
def parseTime(time_before):

0 commit comments

Comments
 (0)