Update webrepl_connection.py
@@ -3,6 +3,7 @@ import threading
import time
from queue import Queue
+from thonny.common import ConnectionFailedException
from thonny.plugins.micropython.connection import MicroPythonConnection
DEBUG = False
@@ -67,12 +68,15 @@ class WebReplConnection(MicroPythonConnection):
async def _ws_connect(self):
import websockets
+ try:
try:
self._ws = await websockets.connect(self._url, ping_interval=None)
except websockets.exceptions.InvalidMessage:
# try once more
self._ws = await websockets.connect(self._url, ping_interval=None)
-
+ except OSError as e:
+ #print("\nCould not connect:", e, file=sys.stderr)
+ raise ConnectionFailedException(str(e))
debug("GOT WS", self._ws)
# read password prompt and send password
@@ -143,6 +147,8 @@ class WebReplConnection(MicroPythonConnection):
class WebreplBinaryMsg:
+ """This wrapper helps distinguishing between bytes which should
+ be decoded and sent as text frame and bytes sent as binary frame"""
def __init__(self, data):
self.data = data
