49 |
49 |
50 address = ("127.0.0.1", 0) |
50 address = ("127.0.0.1", 0) |
51 self.__socket = socket.create_server(address, family=socket.AF_INET) |
51 self.__socket = socket.create_server(address, family=socket.AF_INET) |
52 |
52 |
53 self.__originalPathString = os.getenv("PATH") |
53 self.__originalPathString = os.getenv("PATH") |
|
54 |
|
55 def sendError(self, request, reqestUuid="", errorMessage=None): |
|
56 """ |
|
57 Public method to send an error report to the IDE. |
|
58 |
|
59 @param request request name |
|
60 @type str |
|
61 @param reqestUuid UUID of the associated request as sent by the eric IDE |
|
62 (defaults to "", i.e. no UUID received) |
|
63 @type str |
|
64 @param errorMessage error message to be sent back (defaults to None) |
|
65 @type str (optional) |
|
66 """ |
|
67 if errorMessage: |
|
68 self._server.sendJson( |
|
69 category=self._category, |
|
70 reply=request, |
|
71 params={ |
|
72 "Error": f"Error during request type '{request}': {errorMessage}" |
|
73 }, |
|
74 reqestUuid=reqestUuid, |
|
75 ) |
|
76 else: |
|
77 super().sendError(request=request, reqestUuid=reqestUuid) |
54 |
78 |
55 def initServerSocket(self): |
79 def initServerSocket(self): |
56 """ |
80 """ |
57 Public method to initialize the server socket listening for debug client |
81 Public method to initialize the server socket listening for debug client |
58 connections. |
82 connections. |
279 |
303 |
280 clientEnv = os.environ.copy() |
304 clientEnv = os.environ.copy() |
281 if self.__originalPathString: |
305 if self.__originalPathString: |
282 clientEnv["PATH"] = self.__originalPathString |
306 clientEnv["PATH"] = self.__originalPathString |
283 |
307 |
284 self.__client = subprocess.Popen( |
308 try: |
285 args, |
309 self.__client = subprocess.Popen( |
286 stdout=subprocess.PIPE, |
310 args, |
287 stderr=subprocess.PIPE, |
311 stdout=subprocess.PIPE, |
288 cwd=workingDir, |
312 stderr=subprocess.PIPE, |
289 env=clientEnv, |
313 cwd=workingDir, |
290 ) |
314 env=clientEnv, |
|
315 ) |
|
316 except (OSError, ValueError, subprocess.SubprocessError) as err: |
|
317 self.sendError(request="StartClient", errorMessage=str(err)) |
291 |
318 |
292 def __stopClient(self, params): # noqa: U100 |
319 def __stopClient(self, params): # noqa: U100 |
293 """ |
320 """ |
294 Private method to stop the current debug client process. |
321 Private method to stop the current debug client process. |
295 |
322 |