13 import os |
13 import os |
14 import shlex |
14 import shlex |
15 |
15 |
16 from PyQt6.QtCore import QObject, QProcess, QProcessEnvironment, QTimer |
16 from PyQt6.QtCore import QObject, QProcess, QProcessEnvironment, QTimer |
17 |
17 |
18 from eric7 import Globals, Preferences, Utilities |
18 from eric7 import Preferences, Utilities |
19 from eric7.EricWidgets import EricMessageBox |
19 from eric7.EricWidgets import EricMessageBox |
20 from eric7.EricWidgets.EricApplication import ericApp |
20 from eric7.EricWidgets.EricApplication import ericApp |
21 from eric7.Globals import getConfig |
21 from eric7.Globals import getConfig |
|
22 from eric7.SystemUtilities import FileSystemUtilities, OSUtilities, PythonUtilities |
22 |
23 |
23 from . import DebugClientCapabilities |
24 from . import DebugClientCapabilities |
24 |
25 |
25 ClientDefaultCapabilities = DebugClientCapabilities.HasAll |
26 ClientDefaultCapabilities = DebugClientCapabilities.HasAll |
26 |
27 |
188 venvManager = ericApp().getObject("VirtualEnvManager") |
189 venvManager = ericApp().getObject("VirtualEnvManager") |
189 interpreter = venvManager.getVirtualenvInterpreter(venvName) |
190 interpreter = venvManager.getVirtualenvInterpreter(venvName) |
190 execPath = venvManager.getVirtualenvExecPath(venvName) |
191 execPath = venvManager.getVirtualenvExecPath(venvName) |
191 if interpreter == "": |
192 if interpreter == "": |
192 # use the interpreter used to run eric for identical variants |
193 # use the interpreter used to run eric for identical variants |
193 interpreter = Globals.getPythonExecutable() |
194 interpreter = PythonUtilities.getPythonExecutable() |
194 if interpreter == "": |
195 if interpreter == "": |
195 EricMessageBox.critical( |
196 EricMessageBox.critical( |
196 None, |
197 None, |
197 self.tr("Start Debugger"), |
198 self.tr("Start Debugger"), |
198 self.tr("""<p>No suitable Python3 environment configured.</p>"""), |
199 self.tr("""<p>No suitable Python3 environment configured.</p>"""), |
230 if noencoding: |
231 if noencoding: |
231 args.append(noencoding) |
232 args.append(noencoding) |
232 if multiprocessEnabled: |
233 if multiprocessEnabled: |
233 args.append(multiprocessEnabled) |
234 args.append(multiprocessEnabled) |
234 args.extend([str(port), redirect, ipaddr]) |
235 args.extend([str(port), redirect, ipaddr]) |
235 if Utilities.isWindowsPlatform(): |
236 if OSUtilities.isWindowsPlatform(): |
236 if not os.path.splitext(args[0])[1]: |
237 if not os.path.splitext(args[0])[1]: |
237 for ext in [".exe", ".com", ".cmd", ".bat"]: |
238 for ext in [".exe", ".com", ".cmd", ".bat"]: |
238 prog = Utilities.getExecutablePath(args[0] + ext) |
239 prog = FileSystemUtilities.getExecutablePath(args[0] + ext) |
239 if prog: |
240 if prog: |
240 args[0] = prog |
241 args[0] = prog |
241 break |
242 break |
242 else: |
243 else: |
243 args[0] = Utilities.getExecutablePath(args[0]) |
244 args[0] = FileSystemUtilities.getExecutablePath(args[0]) |
244 process = self.__startProcess(args[0], args[1:], workingDir=workingDir) |
245 process = self.__startProcess(args[0], args[1:], workingDir=workingDir) |
245 if process is None: |
246 if process is None: |
246 EricMessageBox.critical( |
247 EricMessageBox.critical( |
247 None, |
248 None, |
248 self.tr("Start Debugger"), |
249 self.tr("Start Debugger"), |
299 if noencoding: |
300 if noencoding: |
300 args.append(noencoding) |
301 args.append(noencoding) |
301 if multiprocessEnabled: |
302 if multiprocessEnabled: |
302 args.append(multiprocessEnabled) |
303 args.append(multiprocessEnabled) |
303 args.extend([str(port), "0", ipaddr]) |
304 args.extend([str(port), "0", ipaddr]) |
304 args[0] = Utilities.getExecutablePath(args[0]) |
305 args[0] = FileSystemUtilities.getExecutablePath(args[0]) |
305 process = self.__startProcess( |
306 process = self.__startProcess( |
306 args[0], args[1:], clientEnv, workingDir=workingDir |
307 args[0], args[1:], clientEnv, workingDir=workingDir |
307 ) |
308 ) |
308 if process is None: |
309 if process is None: |
309 EricMessageBox.critical( |
310 EricMessageBox.critical( |
443 if noencoding: |
444 if noencoding: |
444 args.append(noencoding) |
445 args.append(noencoding) |
445 if multiprocessEnabled: |
446 if multiprocessEnabled: |
446 args.append(multiprocessEnabled) |
447 args.append(multiprocessEnabled) |
447 args.extend([str(port), redirect, ipaddr]) |
448 args.extend([str(port), redirect, ipaddr]) |
448 if Utilities.isWindowsPlatform(): |
449 if OSUtilities.isWindowsPlatform(): |
449 if not os.path.splitext(args[0])[1]: |
450 if not os.path.splitext(args[0])[1]: |
450 for ext in [".exe", ".com", ".cmd", ".bat"]: |
451 for ext in [".exe", ".com", ".cmd", ".bat"]: |
451 prog = Utilities.getExecutablePath(args[0] + ext) |
452 prog = FileSystemUtilities.getExecutablePath(args[0] + ext) |
452 if prog: |
453 if prog: |
453 args[0] = prog |
454 args[0] = prog |
454 break |
455 break |
455 else: |
456 else: |
456 args[0] = Utilities.getExecutablePath(args[0]) |
457 args[0] = FileSystemUtilities.getExecutablePath(args[0]) |
457 process = self.__startProcess(args[0], args[1:], workingDir=workingDir) |
458 process = self.__startProcess(args[0], args[1:], workingDir=workingDir) |
458 if process is None: |
459 if process is None: |
459 EricMessageBox.critical( |
460 EricMessageBox.critical( |
460 None, |
461 None, |
461 self.tr("Start Debugger"), |
462 self.tr("Start Debugger"), |
512 if noencoding: |
513 if noencoding: |
513 args.append(noencoding) |
514 args.append(noencoding) |
514 if multiprocessEnabled: |
515 if multiprocessEnabled: |
515 args.append(multiprocessEnabled) |
516 args.append(multiprocessEnabled) |
516 args.extend([str(port), "0", ipaddr]) |
517 args.extend([str(port), "0", ipaddr]) |
517 args[0] = Utilities.getExecutablePath(args[0]) |
518 args[0] = FileSystemUtilities.getExecutablePath(args[0]) |
518 process = self.__startProcess( |
519 process = self.__startProcess( |
519 args[0], args[1:], clientEnv, workingDir=workingDir |
520 args[0], args[1:], clientEnv, workingDir=workingDir |
520 ) |
521 ) |
521 if process is None: |
522 if process is None: |
522 EricMessageBox.critical( |
523 EricMessageBox.critical( |