src/eric7/MicroPython/MicroPythonWebreplDeviceInterface.py

branch
eric7
changeset 10019
e56089d00750
parent 10016
8db27a64d434
child 10033
91b0939626ff
equal deleted inserted replaced
10018:53315c3db26b 10019:e56089d00750
197 if not ok: 197 if not ok:
198 self.__blockReadyRead = False 198 self.__blockReadyRead = False
199 return (b"", b"Could not switch to paste mode. Is the device switched on?") 199 return (b"", b"Could not switch to paste mode. Is the device switched on?")
200 200
201 # send commands 201 # send commands
202 commandBytes = commands.encode("utf-8") 202 for command in commands.splitlines(keepends=True):
203 self.__socket.writeTextMessage(commandBytes) 203 # send the data as single lines
204 ok = self.__socket.readUntil(commandBytes) 204 commandBytes = command.encode("utf-8")
205 if ok != commandBytes: 205 self.__socket.writeTextMessage(commandBytes)
206 self.__blockReadyRead = False 206 ok = self.__socket.readUntil(commandBytes)
207 return ( 207 if ok != commandBytes:
208 b"", 208 self.__blockReadyRead = False
209 "Expected '{0}', got '{1}', followed by '{2}'".format( 209 return (
210 commandBytes, ok, self.__socket.readAll() 210 b"",
211 ).encode("utf-8"), 211 "Expected '{0}', got '{1}', followed by '{2}'".format(
212 ) 212 commandBytes, ok, self.__socket.readAll()
213 ).encode("utf-8"),
214 )
213 215
214 # switch off paste mode causing the commands to be executed 216 # switch off paste mode causing the commands to be executed
215 self.__pasteOff() 217 self.__pasteOff()
216 218
217 # read until Python prompt 219 # read until Python prompt

eric ide

mercurial