Version 2.2.9:

Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
This commit is contained in:
Jeroen Oudshoorn
2023-09-05 20:29:09 +02:00
parent 173c0eced2
commit 8c9519f2ee
10 changed files with 66 additions and 217 deletions

View File

@ -51,7 +51,18 @@ class Client(object):
logging.debug("Lost websocket connection. Reconnecting...")
except websockets.exceptions.WebSocketException as wex:
logging.debug("Websocket exception (%s)", wex)
except Exception as e:
logging.exception("Other error while opening websocket (%s) with parameter %s", e, s)
def run(self, command, verbose_errors=True):
r = requests.post("%s/session" % self.url, auth=self.auth, json={'cmd': command})
return decode(r, verbose_errors=verbose_errors)
def run(self, command, verbose_errors=True):
for _ in range(0, 2):
try:
r = requests.post("%s/session" % self.url, auth=self.auth, json={'cmd': command})
except requests.exceptions.ConnectionError as e:
logging.exception("Request connection error (%s) while running command (%s)", e, command)
sleep(1) # Sleep for 1-s before trying a second time
else:
break
return decode(r, verbose_errors=verbose_errors)