From 932e56cca70c35a530c74ab3a0cfb6aa2933e46b Mon Sep 17 00:00:00 2001 From: Keith Schincke Date: Tue, 4 Jun 2024 12:03:00 -0500 Subject: [PATCH] Add default ma_attempts param to get_local_time --- adafruit_portalbase/network.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/adafruit_portalbase/network.py b/adafruit_portalbase/network.py index 57a6369..9cf7ef2 100755 --- a/adafruit_portalbase/network.py +++ b/adafruit_portalbase/network.py @@ -203,11 +203,13 @@ class NetworkBase: """ return url.replace(" ", "+").replace("%", "%25").replace(":", "%3A") - def get_strftime(self, time_format, location=None): + def get_strftime(self, time_format, location=None, max_attempts=10): """ Fetch a custom strftime relative to your location. :param str location: Your city and country, e.g. ``"America/New_York"``. + :param max_attempts: The maximum number of of attempts to connect to WiFi before + failing or use None to disable. Defaults to 10. """ # pylint: disable=line-too-long @@ -259,12 +261,14 @@ class NetworkBase: return reply - def get_local_time(self, location=None): + def get_local_time(self, location=None, max_attempts=10): # pylint: disable=line-too-long """ Fetch and "set" the local time of this microcontroller to the local time at the location, using an internet time API. :param str location: Your city and country, e.g. ``"America/New_York"``. + :param max_attempts: The maximum number of of attempts to connect to WiFi before + failing or use None to disable. Defaults to 10. """ reply = self.get_strftime(TIME_SERVICE_FORMAT, location=location)