From 56079dfd9d0f3f2ffbbd6a5dee901b22850cb4b3 Mon Sep 17 00:00:00 2001 From: Simone Margaritelli Date: Mon, 21 Oct 2019 16:26:07 +0200 Subject: [PATCH] fix: waiting for bettercap's API to start --- pwnagotchi/agent.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pwnagotchi/agent.py b/pwnagotchi/agent.py index cd4dcfae..16fa722a 100644 --- a/pwnagotchi/agent.py +++ b/pwnagotchi/agent.py @@ -135,8 +135,18 @@ class Agent(Client, AsyncAdvertiser, AsyncTrainer): self.start_advertising() + def _wait_bettercap(self): + while True: + try: + s = self.session() + return + except: + logging.info("waiting for bettercap API to be available ...") + time.sleep(1) + def start(self): self.start_ai() + self._wait_bettercap() self.setup_events() self.set_starting() self.start_monitor_mode()