diff -r b0d14cba79b1 -r 552a790fd9bc src/eric7/RemoteServer/EricServerDebuggerRequestHandler.py --- a/src/eric7/RemoteServer/EricServerDebuggerRequestHandler.py Tue Feb 27 15:05:53 2024 +0100 +++ b/src/eric7/RemoteServer/EricServerDebuggerRequestHandler.py Fri Mar 08 15:30:23 2024 +0100 @@ -47,6 +47,9 @@ address = ("127.0.0.1", 0) self.__socket = socket.create_server(address, family=socket.AF_INET) + self.__originalPathString = os.getenv("PATH") + + def initServerSocket(self): """ Public method to initialize the server socket listening for debug client @@ -55,9 +58,10 @@ # listen on the debug server socket self.__socket.listen() self.__socket.setblocking(False) + address = self.__socket.getsockname() print( # noqa: M801 - f"Listening for 'debug client' connections on" - f" {self.__socket.getsockname()}" + f"Listening for 'Debug Client' connections on" + f" {address[0]}, port {address[1]}" ) data = types.SimpleNamespace( name="server", acceptHandler=self.__acceptDbgClientConnection @@ -106,7 +110,7 @@ @type socket.socket """ connection, address = sock.accept() # Should be ready to read - print(f"'Debug client' connection from {address[0]}, port {address[1]}") + print(f"'Debug Client' connection from {address[0]}, port {address[1]}") # noqa: M801 connection.setblocking(False) self.__pendingConnections.append(connection) @@ -173,6 +177,11 @@ """ self.__server.getSelector().unregister(sock) + address = sock.getpeername() + print( + f"'Debug Client' connection from {address[0]}, port {address[1]} closed." + ) + # noqa: M801 for debuggerId in list(self.__connections): if self.__connections[debuggerId] is sock: del self.__connections[debuggerId] @@ -291,8 +300,18 @@ args.extend(params["arguments"]) args.extend([str(port), "True", ipaddr]) + workingDir = params["working_dir"] if params["working_dir"] else None + + clientEnv = os.environ.copy() + if self.__originalPathString: + clientEnv["PATH"] = self.__originalPathString + self.__client = subprocess.Popen( - args, stdout=subprocess.PIPE, stderr=subprocess.PIPE + args, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + cwd=workingDir, + env=clientEnv, ) def __stopClient(self, params): # noqa: U100 @@ -327,9 +346,9 @@ for sock in self.__connections.values(): self.__server.sendJsonCommand(jsonStr, sock) else: - try: + try: # noqa: Y105 sock = self.__connections[debuggerId] self.__server.sendJsonCommand(jsonStr, sock) except KeyError: - print(f"Command for unknown debugger ID '{debuggerId}' received.") - # noqa: M801 + pass + # - print(f"Command for unknown debugger ID '{debuggerId}' received.")