From 5ba466b7aa289c1f921d42016fefbbe4fdf7a939 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tristan=20Dani=C3=ABl=20Maat?= Date: Sat, 20 May 2023 02:51:46 +0100 Subject: [PATCH] tlsappointmentbot: Don't send warnings on first failure --- src/tlsappointmentbot.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/tlsappointmentbot.py b/src/tlsappointmentbot.py index a458ae5..7243618 100644 --- a/src/tlsappointmentbot.py +++ b/src/tlsappointmentbot.py @@ -37,6 +37,8 @@ class TLSAppointmentBot: while not self.matrix_bot.initial_sync_done: await asyncio.sleep(1) + tries = 0 + while True: try: logger.info("checking for appointment slots") @@ -57,10 +59,18 @@ class TLSAppointmentBot: except Exception: logging.error(traceback.format_exc().strip()) - await self.matrix_bot.send_warning() + if tries > 3: + await self.matrix_bot.send_warning() + break + tries += 1 + continue + + tries = 0 await asyncio.sleep(2 * 60) + self.quit() + def _is_logged_in(self) -> bool: self.driver.get(f"{self.config.tls_instance}/BJS/index.php") button = wait.WebDriverWait(self.driver, 10).until( @@ -87,7 +97,7 @@ class TLSAppointmentBot: # Make sure we're on the page, and that we can see the # appointment table - wait.WebDriverWait(self.driver, 10).until( + wait.WebDriverWait(self.driver, 20).until( ec.visibility_of_element_located((By.XPATH, "//tr[@class='amend']")) )