mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
Version 2.3.8
Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
This commit is contained in:
@ -1 +1 @@
|
|||||||
__version__ = '2.3.7'
|
__version__ = '2.3.8'
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import requests
|
import requests
|
||||||
import websockets
|
import websockets
|
||||||
import backoff
|
|
||||||
|
|
||||||
from requests.auth import HTTPBasicAuth
|
from requests.auth import HTTPBasicAuth
|
||||||
import asyncio # Add asyncio for async functionality
|
import asyncio # Add asyncio for async functionality
|
||||||
@ -42,29 +41,23 @@ class Client(object):
|
|||||||
r = requests.get("%s/%s" % (self.url, sess), auth=self.auth)
|
r = requests.get("%s/%s" % (self.url, sess), auth=self.auth)
|
||||||
return decode(r)
|
return decode(r)
|
||||||
|
|
||||||
@backoff.on_exception(backoff.expo, requests.exceptions.ConnectionError, max_tries=10)
|
|
||||||
async def start_websocket(self, consumer):
|
async def start_websocket(self, consumer):
|
||||||
async with self.websocket_semaphore:
|
s = "%s/events" % self.websocket
|
||||||
s = "%s/events" % self.websocket
|
while True:
|
||||||
while True:
|
try:
|
||||||
try:
|
async with websockets.connect(s, ping_interval=60, ping_timeout=90) as ws:
|
||||||
async with websockets.connect(s, ping_interval=60, ping_timeout=90) as ws:
|
async for msg in ws:
|
||||||
async for msg in ws:
|
try:
|
||||||
try:
|
await consumer(msg)
|
||||||
await consumer(msg)
|
except Exception as ex:
|
||||||
except Exception as ex:
|
logging.debug("Error while parsing event (%s)", ex)
|
||||||
logging.debug("Error while parsing event (%s)", ex)
|
except websockets.ConnectionClosedError:
|
||||||
except websockets.ConnectionClosedError:
|
logging.debug("Lost websocket connection. Reconnecting...")
|
||||||
logging.debug("Lost websocket connection. Reconnecting...")
|
except websockets.WebSocketException as wex:
|
||||||
await asyncio.sleep(5) # Sleep for x seconds before reconnecting
|
logging.debug("Websocket exception (%s)", wex)
|
||||||
except websockets.WebSocketException as wex:
|
except Exception as e:
|
||||||
logging.debug("Websocket exception (%s)", wex)
|
logging.exception("Other error while opening websocket (%s) with parameter %s", e, s)
|
||||||
await asyncio.sleep(5) # Sleep for x seconds before reconnecting
|
|
||||||
except Exception as e:
|
|
||||||
logging.exception("Other error while opening websocket (%s) with parameter %s", e, s)
|
|
||||||
await asyncio.sleep(5) # Sleep for x seconds before reconnecting
|
|
||||||
|
|
||||||
@backoff.on_exception(backoff.expo, requests.exceptions.ConnectionError, max_tries=10)
|
|
||||||
def run(self, command, verbose_errors=True):
|
def run(self, command, verbose_errors=True):
|
||||||
for _ in range(0, 2):
|
for _ in range(0, 2):
|
||||||
try:
|
try:
|
||||||
|
Reference in New Issue
Block a user