273 self.translateLocalWindows = "\\" in self.translateLocal |
276 self.translateLocalWindows = "\\" in self.translateLocal |
274 else: |
277 else: |
275 self.translate = self.__identityTranslation |
278 self.translate = self.__identityTranslation |
276 return process, self.__isNetworked, "" |
279 return process, self.__isNetworked, "" |
277 |
280 |
278 # set translation function |
|
279 self.translate = self.__identityTranslation |
|
280 |
|
281 # setup the environment for the debugger |
|
282 if Preferences.getDebugger("DebugEnvironmentReplace"): |
|
283 clientEnv = {} |
|
284 else: |
281 else: |
285 clientEnv = os.environ.copy() |
282 # local debugging code below |
286 if originalPathString: |
283 debugClient = self.__determineDebugClient() |
287 clientEnv["PATH"] = originalPathString |
284 |
288 envlist = shlex.split(Preferences.getDebugger("DebugEnvironment")) |
285 # set translation function |
289 for el in envlist: |
286 self.translate = self.__identityTranslation |
290 with contextlib.suppress(ValueError): |
287 |
291 key, value = el.split("=", 1) |
288 # setup the environment for the debugger |
292 clientEnv[str(key)] = str(value) |
289 if Preferences.getDebugger("DebugEnvironmentReplace"): |
293 if execPath: |
290 clientEnv = {} |
294 if "PATH" in clientEnv: |
|
295 clientEnv["PATH"] = os.pathsep.join([execPath, clientEnv["PATH"]]) |
|
296 else: |
291 else: |
297 clientEnv["PATH"] = execPath |
292 clientEnv = os.environ.copy() |
298 |
293 if originalPathString: |
299 ipaddr = self.debugServer.getHostAddress(True) |
294 clientEnv["PATH"] = originalPathString |
300 if runInConsole or Preferences.getDebugger("ConsoleDbgEnabled"): |
295 envlist = shlex.split(Preferences.getDebugger("DebugEnvironment")) |
301 ccmd = Preferences.getDebugger("ConsoleDbgCommand") |
296 for el in envlist: |
302 if ccmd: |
297 with contextlib.suppress(ValueError): |
303 args = Utilities.parseOptionString(ccmd) + [ |
298 key, value = el.split("=", 1) |
304 interpreter, |
299 clientEnv[str(key)] = str(value) |
305 os.path.abspath(debugClient), |
300 if execPath: |
306 ] |
301 if "PATH" in clientEnv: |
307 if noencoding: |
302 clientEnv["PATH"] = os.pathsep.join([execPath, clientEnv["PATH"]]) |
308 args.append(noencoding) |
303 else: |
309 if multiprocessEnabled: |
304 clientEnv["PATH"] = execPath |
310 args.append(multiprocessEnabled) |
305 |
311 if callTraceOptimization: |
306 ipaddr = self.debugServer.getHostAddress(True) |
312 args.append(callTraceOptimization) |
307 if runInConsole or Preferences.getDebugger("ConsoleDbgEnabled"): |
313 args.extend([str(port), "0", ipaddr]) |
308 ccmd = Preferences.getDebugger("ConsoleDbgCommand") |
314 args[0] = FileSystemUtilities.getExecutablePath(args[0]) |
309 if ccmd: |
315 process = self.__startProcess( |
310 args = Utilities.parseOptionString(ccmd) + [ |
316 args[0], args[1:], clientEnv, workingDir=workingDir |
311 interpreter, |
|
312 os.path.abspath(debugClient), |
|
313 ] |
|
314 if noencoding: |
|
315 args.append(noencoding) |
|
316 if multiprocessEnabled: |
|
317 args.append(multiprocessEnabled) |
|
318 if callTraceOptimization: |
|
319 args.append(callTraceOptimization) |
|
320 args.extend([str(port), "0", ipaddr]) |
|
321 args[0] = FileSystemUtilities.getExecutablePath(args[0]) |
|
322 process = self.__startProcess( |
|
323 args[0], args[1:], clientEnv, workingDir=workingDir |
|
324 ) |
|
325 if process is None: |
|
326 EricMessageBox.critical( |
|
327 None, |
|
328 self.tr("Start Debugger"), |
|
329 self.tr( |
|
330 """<p>The debugger backend could not be""" |
|
331 """ started.</p>""" |
|
332 ), |
|
333 ) |
|
334 return process, self.__isNetworked, interpreter |
|
335 |
|
336 args = [debugClient] |
|
337 if noencoding: |
|
338 args.append(noencoding) |
|
339 if multiprocessEnabled: |
|
340 args.append(multiprocessEnabled) |
|
341 if callTraceOptimization: |
|
342 args.append(callTraceOptimization) |
|
343 args.extend([str(port), redirect, ipaddr]) |
|
344 process = self.__startProcess( |
|
345 interpreter, args, clientEnv, workingDir=workingDir |
|
346 ) |
|
347 if process is None: |
|
348 self.__startedVenv = "" |
|
349 EricMessageBox.critical( |
|
350 None, |
|
351 self.tr("Start Debugger"), |
|
352 self.tr("""<p>The debugger backend could not be started.</p>"""), |
317 ) |
353 ) |
318 if process is None: |
354 else: |
319 EricMessageBox.critical( |
355 self.__startedVenv = venvName |
320 None, |
356 |
321 self.tr("Start Debugger"), |
357 return process, self.__isNetworked, interpreter |
322 self.tr( |
|
323 """<p>The debugger backend could not be""" |
|
324 """ started.</p>""" |
|
325 ), |
|
326 ) |
|
327 return process, self.__isNetworked, interpreter |
|
328 |
|
329 args = [debugClient] |
|
330 if noencoding: |
|
331 args.append(noencoding) |
|
332 if multiprocessEnabled: |
|
333 args.append(multiprocessEnabled) |
|
334 if callTraceOptimization: |
|
335 args.append(callTraceOptimization) |
|
336 args.extend([str(port), redirect, ipaddr]) |
|
337 process = self.__startProcess( |
|
338 interpreter, args, clientEnv, workingDir=workingDir |
|
339 ) |
|
340 if process is None: |
|
341 self.__startedVenv = "" |
|
342 EricMessageBox.critical( |
|
343 None, |
|
344 self.tr("Start Debugger"), |
|
345 self.tr("""<p>The debugger backend could not be started.</p>"""), |
|
346 ) |
|
347 else: |
|
348 self.__startedVenv = venvName |
|
349 |
|
350 return process, self.__isNetworked, interpreter |
|
351 |
358 |
352 def __determineDebugClient(self): |
359 def __determineDebugClient(self): |
353 """ |
360 """ |
354 Private method to determine the debug client to be started. |
361 Private method to determine the debug client to be started. |
355 |
362 |
447 return None, self.__isNetworked, "" |
447 return None, self.__isNetworked, "" |
448 |
448 |
449 self.__inShutdown = False |
449 self.__inShutdown = False |
450 |
450 |
451 if project.getDebugProperty("REMOTEDEBUGGER"): |
451 if project.getDebugProperty("REMOTEDEBUGGER"): |
|
452 # remote debugging code |
452 ipaddr = self.debugServer.getHostAddress(False) |
453 ipaddr = self.debugServer.getHostAddress(False) |
453 rexec = project.getDebugProperty("REMOTECOMMAND") |
454 rexec = project.getDebugProperty("REMOTECOMMAND") |
454 rhost = project.getDebugProperty("REMOTEHOST") |
455 rhost = project.getDebugProperty("REMOTEHOST") |
455 if rhost == "": |
456 if rhost == "": |
456 rhost = "localhost" |
457 rhost = "localhost" |
457 if rexec: |
458 if rexec: |
|
459 rdebugClient = project.getDebugProperty("REMOTEDEBUGCLIENT") |
|
460 if not rdebugClient and rhost == "localhost": |
|
461 # it is a remote debugging session on the same host |
|
462 rdebugClient = self.__determineDebugClient() |
458 args = Utilities.parseOptionString(rexec) + [ |
463 args = Utilities.parseOptionString(rexec) + [ |
459 rhost, |
464 rhost, |
460 interpreter, |
465 interpreter, |
461 debugClient, |
466 rdebugClient, |
462 ] |
467 ] |
463 if noencoding: |
468 if noencoding: |
464 args.append(noencoding) |
469 args.append(noencoding) |
465 if multiprocessEnabled: |
470 if multiprocessEnabled: |
466 args.append(multiprocessEnabled) |
471 args.append(multiprocessEnabled) |
498 return process, self.__isNetworked, "" |
503 return process, self.__isNetworked, "" |
499 else: |
504 else: |
500 # remote shell command is missing |
505 # remote shell command is missing |
501 return None, self.__isNetworked, "" |
506 return None, self.__isNetworked, "" |
502 |
507 |
503 # set translation function |
|
504 self.translate = self.__identityTranslation |
|
505 |
|
506 # setup the environment for the debugger |
|
507 if project.getDebugProperty("ENVIRONMENTOVERRIDE"): |
|
508 clientEnv = {} |
|
509 else: |
508 else: |
510 clientEnv = os.environ.copy() |
509 # local debugging code below |
511 if originalPathString: |
510 debugClient = project.getDebugProperty("DEBUGCLIENT") |
512 clientEnv["PATH"] = originalPathString |
511 if not bool(debugClient) or not os.path.exists(debugClient): |
513 envlist = shlex.split(project.getDebugProperty("ENVIRONMENTSTRING")) |
512 debugClient = self.__determineDebugClient() |
514 for el in envlist: |
513 |
515 with contextlib.suppress(ValueError): |
514 # set translation function |
516 key, value = el.split("=", 1) |
515 self.translate = self.__identityTranslation |
517 clientEnv[str(key)] = str(value) |
516 |
518 if execPath: |
517 # setup the environment for the debugger |
519 if "PATH" in clientEnv: |
518 if project.getDebugProperty("ENVIRONMENTOVERRIDE"): |
520 clientEnv["PATH"] = os.pathsep.join([execPath, clientEnv["PATH"]]) |
519 clientEnv = {} |
521 else: |
520 else: |
522 clientEnv["PATH"] = execPath |
521 clientEnv = os.environ.copy() |
523 |
522 if originalPathString: |
524 ipaddr = self.debugServer.getHostAddress(True) |
523 clientEnv["PATH"] = originalPathString |
525 if runInConsole or project.getDebugProperty("CONSOLEDEBUGGER"): |
524 envlist = shlex.split(project.getDebugProperty("ENVIRONMENTSTRING")) |
526 ccmd = project.getDebugProperty( |
525 for el in envlist: |
527 "CONSOLECOMMAND" |
526 with contextlib.suppress(ValueError): |
528 ) or Preferences.getDebugger("ConsoleDbgCommand") |
527 key, value = el.split("=", 1) |
529 if ccmd: |
528 clientEnv[str(key)] = str(value) |
530 args = Utilities.parseOptionString(ccmd) + [ |
529 if execPath: |
531 interpreter, |
530 if "PATH" in clientEnv: |
532 os.path.abspath(debugClient), |
531 clientEnv["PATH"] = os.pathsep.join([execPath, clientEnv["PATH"]]) |
533 ] |
532 else: |
534 if noencoding: |
533 clientEnv["PATH"] = execPath |
535 args.append(noencoding) |
534 |
536 if multiprocessEnabled: |
535 ipaddr = self.debugServer.getHostAddress(True) |
537 args.append(multiprocessEnabled) |
536 if runInConsole or project.getDebugProperty("CONSOLEDEBUGGER"): |
538 if callTraceOptimization: |
537 ccmd = project.getDebugProperty( |
539 args.append(callTraceOptimization) |
538 "CONSOLECOMMAND" |
540 args.extend([str(port), "0", ipaddr]) |
539 ) or Preferences.getDebugger("ConsoleDbgCommand") |
541 args[0] = FileSystemUtilities.getExecutablePath(args[0]) |
540 if ccmd: |
542 process = self.__startProcess( |
541 args = Utilities.parseOptionString(ccmd) + [ |
543 args[0], args[1:], clientEnv, workingDir=workingDir |
542 interpreter, |
|
543 os.path.abspath(debugClient), |
|
544 ] |
|
545 if noencoding: |
|
546 args.append(noencoding) |
|
547 if multiprocessEnabled: |
|
548 args.append(multiprocessEnabled) |
|
549 if callTraceOptimization: |
|
550 args.append(callTraceOptimization) |
|
551 args.extend([str(port), "0", ipaddr]) |
|
552 args[0] = FileSystemUtilities.getExecutablePath(args[0]) |
|
553 process = self.__startProcess( |
|
554 args[0], args[1:], clientEnv, workingDir=workingDir |
|
555 ) |
|
556 if process is None: |
|
557 EricMessageBox.critical( |
|
558 None, |
|
559 self.tr("Start Debugger"), |
|
560 self.tr( |
|
561 """<p>The debugger backend could not be""" |
|
562 """ started.</p>""" |
|
563 ), |
|
564 ) |
|
565 return process, self.__isNetworked, interpreter |
|
566 |
|
567 args = [debugClient] |
|
568 if noencoding: |
|
569 args.append(noencoding) |
|
570 if multiprocessEnabled: |
|
571 args.append(multiprocessEnabled) |
|
572 if callTraceOptimization: |
|
573 args.append(callTraceOptimization) |
|
574 args.extend([str(port), redirect, ipaddr]) |
|
575 process = self.__startProcess( |
|
576 interpreter, args, clientEnv, workingDir=workingDir |
|
577 ) |
|
578 if process is None: |
|
579 self.__startedVenv = "" |
|
580 EricMessageBox.critical( |
|
581 None, |
|
582 self.tr("Start Debugger"), |
|
583 self.tr("""<p>The debugger backend could not be started.</p>"""), |
544 ) |
584 ) |
545 if process is None: |
585 else: |
546 EricMessageBox.critical( |
586 self.__startedVenv = venvName |
547 None, |
587 |
548 self.tr("Start Debugger"), |
588 return process, self.__isNetworked, interpreter |
549 self.tr( |
|
550 """<p>The debugger backend could not be""" |
|
551 """ started.</p>""" |
|
552 ), |
|
553 ) |
|
554 return process, self.__isNetworked, interpreter |
|
555 |
|
556 args = [debugClient] |
|
557 if noencoding: |
|
558 args.append(noencoding) |
|
559 if multiprocessEnabled: |
|
560 args.append(multiprocessEnabled) |
|
561 if callTraceOptimization: |
|
562 args.append(callTraceOptimization) |
|
563 args.extend([str(port), redirect, ipaddr]) |
|
564 process = self.__startProcess( |
|
565 interpreter, args, clientEnv, workingDir=workingDir |
|
566 ) |
|
567 if process is None: |
|
568 self.__startedVenv = "" |
|
569 EricMessageBox.critical( |
|
570 None, |
|
571 self.tr("Start Debugger"), |
|
572 self.tr("""<p>The debugger backend could not be started.</p>"""), |
|
573 ) |
|
574 else: |
|
575 self.__startedVenv = venvName |
|
576 |
|
577 return process, self.__isNetworked, interpreter |
|
578 |
589 |
579 def getClientCapabilities(self): |
590 def getClientCapabilities(self): |
580 """ |
591 """ |
581 Public method to retrieve the debug clients capabilities. |
592 Public method to retrieve the debug clients capabilities. |
582 |
593 |