@@ -203,15 +203,17 @@ def url_encode(url):
203
203
"""
204
204
return url .replace (" " , "+" ).replace ("%" , "%25" ).replace (":" , "%3A" )
205
205
206
- def get_strftime (self , time_format , location = None ):
206
+ def get_strftime (self , time_format , location = None , max_attempts = 10 ):
207
207
"""
208
208
Fetch a custom strftime relative to your location.
209
209
210
210
:param str location: Your city and country, e.g. ``"America/New_York"``.
211
+ :param max_attempts: The maximum number of of attempts to connect to WiFi before
212
+ failing or use None to disable. Defaults to 10.
211
213
212
214
"""
213
215
# pylint: disable=line-too-long
214
- self .connect ()
216
+ self .connect (max_attempts = max_attempts )
215
217
api_url = None
216
218
reply = None
217
219
try :
@@ -259,15 +261,19 @@ def get_strftime(self, time_format, location=None):
259
261
260
262
return reply
261
263
262
- def get_local_time (self , location = None ):
264
+ def get_local_time (self , location = None , max_attempts = 10 ):
263
265
# pylint: disable=line-too-long
264
266
"""
265
267
Fetch and "set" the local time of this microcontroller to the local time at the location, using an internet time API.
266
268
267
269
:param str location: Your city and country, e.g. ``"America/New_York"``.
270
+ :param max_attempts: The maximum number of of attempts to connect to WiFi before
271
+ failing or use None to disable. Defaults to 10.
268
272
269
273
"""
270
- reply = self .get_strftime (TIME_SERVICE_FORMAT , location = location )
274
+ reply = self .get_strftime (
275
+ TIME_SERVICE_FORMAT , location = location , max_attempts = max_attempts
276
+ )
271
277
if reply :
272
278
times = reply .split (" " )
273
279
the_date = times [0 ]
@@ -631,7 +637,7 @@ def fetch_data(
631
637
json_path = None ,
632
638
regexp_path = None ,
633
639
timeout = 10 ,
634
- ):
640
+ ): # pylint: disable=too-many-arguments
635
641
"""Fetch data from the specified url and perfom any parsing
636
642
637
643
:param str url: The URL to fetch from.
0 commit comments