@@ -203,15 +203,17 @@ def url_encode(url):
203203 """
204204 return url .replace (" " , "+" ).replace ("%" , "%25" ).replace (":" , "%3A" )
205205
206- def get_strftime (self , time_format , location = None ):
206+ def get_strftime (self , time_format , location = None , max_attempts = 10 ):
207207 """
208208 Fetch a custom strftime relative to your location.
209209
210210 :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.
211213
212214 """
213215 # pylint: disable=line-too-long
214- self .connect ()
216+ self .connect (max_attempts = max_attempts )
215217 api_url = None
216218 reply = None
217219 try :
@@ -259,15 +261,19 @@ def get_strftime(self, time_format, location=None):
259261
260262 return reply
261263
262- def get_local_time (self , location = None ):
264+ def get_local_time (self , location = None , max_attempts = 10 ):
263265 # pylint: disable=line-too-long
264266 """
265267 Fetch and "set" the local time of this microcontroller to the local time at the location, using an internet time API.
266268
267269 :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.
268272
269273 """
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+ )
271277 if reply :
272278 times = reply .split (" " )
273279 the_date = times [0 ]
@@ -631,7 +637,7 @@ def fetch_data(
631637 json_path = None ,
632638 regexp_path = None ,
633639 timeout = 10 ,
634- ):
640+ ): # pylint: disable=too-many-arguments
635641 """Fetch data from the specified url and perfom any parsing
636642
637643 :param str url: The URL to fetch from.
0 commit comments