84 """ |
84 """ |
85 # listen on the debug server socket |
85 # listen on the debug server socket |
86 self.__socket.listen() |
86 self.__socket.listen() |
87 self.__socket.setblocking(False) |
87 self.__socket.setblocking(False) |
88 address = self.__socket.getsockname() |
88 address = self.__socket.getsockname() |
89 print( # noqa: M801 |
89 print( # noqa: M-801 |
90 f"Listening for 'Debug Client' connections on" |
90 f"Listening for 'Debug Client' connections on" |
91 f" {address[0]}, port {address[1]}" |
91 f" {address[0]}, port {address[1]}" |
92 ) |
92 ) |
93 data = types.SimpleNamespace( |
93 data = types.SimpleNamespace( |
94 name="server", acceptHandler=self.__acceptDbgClientConnection |
94 name="server", acceptHandler=self.__acceptDbgClientConnection |
108 @param sock reference to the listening socket |
108 @param sock reference to the listening socket |
109 @type socket.socket |
109 @type socket.socket |
110 """ |
110 """ |
111 connection, address = sock.accept() # Should be ready to read |
111 connection, address = sock.accept() # Should be ready to read |
112 print(f"'Debug Client' connection from {address[0]}, port {address[1]}") |
112 print(f"'Debug Client' connection from {address[0]}, port {address[1]}") |
113 # noqa: M801 |
113 # noqa: M-801 |
114 connection.setblocking(False) |
114 connection.setblocking(False) |
115 self.__pendingConnections.append(connection) |
115 self.__pendingConnections.append(connection) |
116 |
116 |
117 data = types.SimpleNamespace( |
117 data = types.SimpleNamespace( |
118 name="debug_client", |
118 name="debug_client", |
178 with contextlib.suppress(KeyError): |
178 with contextlib.suppress(KeyError): |
179 self._server.getSelector().unregister(sock) |
179 self._server.getSelector().unregister(sock) |
180 |
180 |
181 with contextlib.suppress(OSError): |
181 with contextlib.suppress(OSError): |
182 address = sock.getpeername() |
182 address = sock.getpeername() |
183 print( # noqa: M801 |
183 print( # noqa: M-801 |
184 f"'Debug Client' connection from {address[0]}, port {address[1]}" |
184 f"'Debug Client' connection from {address[0]}, port {address[1]}" |
185 f" closed." |
185 f" closed." |
186 ) |
186 ) |
187 |
187 |
188 for debuggerId in list(self.__connections): |
188 for debuggerId in list(self.__connections): |
343 env=clientEnv, |
343 env=clientEnv, |
344 ) |
344 ) |
345 except (OSError, ValueError, subprocess.SubprocessError) as err: |
345 except (OSError, ValueError, subprocess.SubprocessError) as err: |
346 self.sendError(request="StartClientError", errorMessage=str(err)) |
346 self.sendError(request="StartClientError", errorMessage=str(err)) |
347 |
347 |
348 def __stopClient(self, params): # noqa: U100 |
348 def __stopClient(self, params): # noqa: U-100 |
349 """ |
349 """ |
350 Private method to stop the current debug client process. |
350 Private method to stop the current debug client process. |
351 |
351 |
352 @param params dictionary containing the request data |
352 @param params dictionary containing the request data |
353 @type dict |
353 @type dict |
375 if debuggerId == "<<all>>": |
375 if debuggerId == "<<all>>": |
376 # broadcast to all connected debug clients |
376 # broadcast to all connected debug clients |
377 for sock in self.__connections.values(): |
377 for sock in self.__connections.values(): |
378 self._server.sendJsonCommand(jsonStr, sock) |
378 self._server.sendJsonCommand(jsonStr, sock) |
379 else: |
379 else: |
380 try: # noqa: Y105 |
380 try: # noqa: Y-105 |
381 sock = self.__connections[debuggerId] |
381 sock = self.__connections[debuggerId] |
382 self._server.sendJsonCommand(jsonStr, sock) |
382 self._server.sendJsonCommand(jsonStr, sock) |
383 except KeyError: |
383 except KeyError: |
384 # - print(f"Command for unknown debugger ID '{debuggerId}' received.") |
384 # - print(f"Command for unknown debugger ID '{debuggerId}' received.") |
385 pass |
385 pass |