eric7/Debugger/DebuggerInterfacePython.py

branch
eric7
changeset 8356
68ec9c3d4de5
parent 8322
b422b4e77d19
child 8358
144a6b854f70
equal deleted inserted replaced
8355:8a7677a63c8d 8356:68ec9c3d4de5
15 15
16 from PyQt6.QtCore import ( 16 from PyQt6.QtCore import (
17 QObject, QProcess, QProcessEnvironment, QTimer 17 QObject, QProcess, QProcessEnvironment, QTimer
18 ) 18 )
19 19
20 from E5Gui.E5Application import e5App 20 from E5Gui.EricApplication import ericApp
21 from E5Gui import E5MessageBox 21 from E5Gui import EricMessageBox
22 22
23 from . import DebugClientCapabilities 23 from . import DebugClientCapabilities
24 24
25 import Preferences 25 import Preferences
26 import Utilities 26 import Utilities
178 """ 178 """
179 global origPathEnv 179 global origPathEnv
180 180
181 if not venvName: 181 if not venvName:
182 venvName = Preferences.getDebugger("Python3VirtualEnv") 182 venvName = Preferences.getDebugger("Python3VirtualEnv")
183 venvManager = e5App().getObject("VirtualEnvManager") 183 venvManager = ericApp().getObject("VirtualEnvManager")
184 interpreter = venvManager.getVirtualenvInterpreter(venvName) 184 interpreter = venvManager.getVirtualenvInterpreter(venvName)
185 execPath = venvManager.getVirtualenvExecPath(venvName) 185 execPath = venvManager.getVirtualenvExecPath(venvName)
186 if interpreter == "": 186 if interpreter == "":
187 # use the interpreter used to run eric for identical variants 187 # use the interpreter used to run eric for identical variants
188 interpreter = sys.executable.replace("w.exe", ".exe") 188 interpreter = sys.executable.replace("w.exe", ".exe")
189 if interpreter == "": 189 if interpreter == "":
190 E5MessageBox.critical( 190 EricMessageBox.critical(
191 None, 191 None,
192 self.tr("Start Debugger"), 192 self.tr("Start Debugger"),
193 self.tr( 193 self.tr(
194 """<p>No suitable Python3 environment configured.</p>""") 194 """<p>No suitable Python3 environment configured.</p>""")
195 ) 195 )
245 else: 245 else:
246 args[0] = Utilities.getExecutablePath(args[0]) 246 args[0] = Utilities.getExecutablePath(args[0])
247 process = self.__startProcess(args[0], args[1:], 247 process = self.__startProcess(args[0], args[1:],
248 workingDir=workingDir) 248 workingDir=workingDir)
249 if process is None: 249 if process is None:
250 E5MessageBox.critical( 250 EricMessageBox.critical(
251 None, 251 None,
252 self.tr("Start Debugger"), 252 self.tr("Start Debugger"),
253 self.tr( 253 self.tr(
254 """<p>The debugger backend could not be""" 254 """<p>The debugger backend could not be"""
255 """ started.</p>""")) 255 """ started.</p>"""))
303 args.extend([str(port), '0', ipaddr]) 303 args.extend([str(port), '0', ipaddr])
304 args[0] = Utilities.getExecutablePath(args[0]) 304 args[0] = Utilities.getExecutablePath(args[0])
305 process = self.__startProcess(args[0], args[1:], clientEnv, 305 process = self.__startProcess(args[0], args[1:], clientEnv,
306 workingDir=workingDir) 306 workingDir=workingDir)
307 if process is None: 307 if process is None:
308 E5MessageBox.critical( 308 EricMessageBox.critical(
309 None, 309 None,
310 self.tr("Start Debugger"), 310 self.tr("Start Debugger"),
311 self.tr( 311 self.tr(
312 """<p>The debugger backend could not be""" 312 """<p>The debugger backend could not be"""
313 """ started.</p>""")) 313 """ started.</p>"""))
321 args.extend([str(port), redirect, ipaddr]) 321 args.extend([str(port), redirect, ipaddr])
322 process = self.__startProcess(interpreter, args, clientEnv, 322 process = self.__startProcess(interpreter, args, clientEnv,
323 workingDir=workingDir) 323 workingDir=workingDir)
324 if process is None: 324 if process is None:
325 self.__startedVenv = "" 325 self.__startedVenv = ""
326 E5MessageBox.critical( 326 EricMessageBox.critical(
327 None, 327 None,
328 self.tr("Start Debugger"), 328 self.tr("Start Debugger"),
329 self.tr( 329 self.tr(
330 """<p>The debugger backend could not be started.</p>""")) 330 """<p>The debugger backend could not be started.</p>"""))
331 else: 331 else:
357 and the name of the interpreter in case of a local execution 357 and the name of the interpreter in case of a local execution
358 @rtype tuple of (QProcess, bool, str) 358 @rtype tuple of (QProcess, bool, str)
359 """ 359 """
360 global origPathEnv 360 global origPathEnv
361 361
362 project = e5App().getObject("Project") 362 project = ericApp().getObject("Project")
363 if not project.isDebugPropertiesLoaded(): 363 if not project.isDebugPropertiesLoaded():
364 return None, self.__isNetworked, "" 364 return None, self.__isNetworked, ""
365 365
366 # start debugger with project specific settings 366 # start debugger with project specific settings
367 debugClient = project.getDebugProperty("DEBUGCLIENT") 367 debugClient = project.getDebugProperty("DEBUGCLIENT")
381 multiprocessEnabled = ( 381 multiprocessEnabled = (
382 '--multiprocess' if Preferences.getDebugger("MultiProcessEnabled") 382 '--multiprocess' if Preferences.getDebugger("MultiProcessEnabled")
383 else '' 383 else ''
384 ) 384 )
385 385
386 venvManager = e5App().getObject("VirtualEnvManager") 386 venvManager = ericApp().getObject("VirtualEnvManager")
387 interpreter = venvManager.getVirtualenvInterpreter(venvName) 387 interpreter = venvManager.getVirtualenvInterpreter(venvName)
388 execPath = venvManager.getVirtualenvExecPath(venvName) 388 execPath = venvManager.getVirtualenvExecPath(venvName)
389 if ( 389 if (
390 interpreter == "" and 390 interpreter == "" and
391 project.getProjectLanguage().startswith("Python") 391 project.getProjectLanguage().startswith("Python")
392 ): 392 ):
393 interpreter = sys.executable.replace("w.exe", ".exe") 393 interpreter = sys.executable.replace("w.exe", ".exe")
394 if interpreter == "": 394 if interpreter == "":
395 E5MessageBox.critical( 395 EricMessageBox.critical(
396 None, 396 None,
397 self.tr("Start Debugger"), 397 self.tr("Start Debugger"),
398 self.tr( 398 self.tr(
399 """<p>No suitable Python3 environment configured.</p>""") 399 """<p>No suitable Python3 environment configured.</p>""")
400 ) 400 )
426 else: 426 else:
427 args[0] = Utilities.getExecutablePath(args[0]) 427 args[0] = Utilities.getExecutablePath(args[0])
428 process = self.__startProcess(args[0], args[1:], 428 process = self.__startProcess(args[0], args[1:],
429 workingDir=workingDir) 429 workingDir=workingDir)
430 if process is None: 430 if process is None:
431 E5MessageBox.critical( 431 EricMessageBox.critical(
432 None, 432 None,
433 self.tr("Start Debugger"), 433 self.tr("Start Debugger"),
434 self.tr( 434 self.tr(
435 """<p>The debugger backend could not be""" 435 """<p>The debugger backend could not be"""
436 """ started.</p>""")) 436 """ started.</p>"""))
486 args.extend([str(port), '0', ipaddr]) 486 args.extend([str(port), '0', ipaddr])
487 args[0] = Utilities.getExecutablePath(args[0]) 487 args[0] = Utilities.getExecutablePath(args[0])
488 process = self.__startProcess(args[0], args[1:], clientEnv, 488 process = self.__startProcess(args[0], args[1:], clientEnv,
489 workingDir=workingDir) 489 workingDir=workingDir)
490 if process is None: 490 if process is None:
491 E5MessageBox.critical( 491 EricMessageBox.critical(
492 None, 492 None,
493 self.tr("Start Debugger"), 493 self.tr("Start Debugger"),
494 self.tr( 494 self.tr(
495 """<p>The debugger backend could not be""" 495 """<p>The debugger backend could not be"""
496 """ started.</p>""")) 496 """ started.</p>"""))
504 args.extend([str(port), redirect, ipaddr]) 504 args.extend([str(port), redirect, ipaddr])
505 process = self.__startProcess(interpreter, args, clientEnv, 505 process = self.__startProcess(interpreter, args, clientEnv,
506 workingDir=workingDir) 506 workingDir=workingDir)
507 if process is None: 507 if process is None:
508 self.__startedVenv = "" 508 self.__startedVenv = ""
509 E5MessageBox.critical( 509 EricMessageBox.critical(
510 None, 510 None,
511 self.tr("Start Debugger"), 511 self.tr("Start Debugger"),
512 self.tr( 512 self.tr(
513 """<p>The debugger backend could not be started.</p>""")) 513 """<p>The debugger backend could not be started.</p>"""))
514 else: 514 else:
1342 import json 1342 import json
1343 1343
1344 try: 1344 try:
1345 commandDict = json.loads(jsonStr.strip()) 1345 commandDict = json.loads(jsonStr.strip())
1346 except (TypeError, ValueError) as err: 1346 except (TypeError, ValueError) as err:
1347 E5MessageBox.critical( 1347 EricMessageBox.critical(
1348 None, 1348 None,
1349 self.tr("Debug Protocol Error"), 1349 self.tr("Debug Protocol Error"),
1350 self.tr("""<p>The response received from the debugger""" 1350 self.tr("""<p>The response received from the debugger"""
1351 """ backend could not be decoded. Please report""" 1351 """ backend could not be decoded. Please report"""
1352 """ this issue with the received data to the""" 1352 """ this issue with the received data to the"""
1353 """ eric bugs email address.</p>""" 1353 """ eric bugs email address.</p>"""
1354 """<p>Error: {0}</p>""" 1354 """<p>Error: {0}</p>"""
1355 """<p>Data:<br/>{1}</p>""").format( 1355 """<p>Data:<br/>{1}</p>""").format(
1356 str(err), Utilities.html_encode(jsonStr.strip())), 1356 str(err), Utilities.html_encode(jsonStr.strip())),
1357 E5MessageBox.Ok) 1357 EricMessageBox.Ok)
1358 return 1358 return
1359 1359
1360 method = commandDict["method"] 1360 method = commandDict["method"]
1361 params = commandDict["params"] 1361 params = commandDict["params"]
1362 1362

eric ide

mercurial