10 |
10 |
11 import sys |
11 import sys |
12 import os |
12 import os |
13 import logging |
13 import logging |
14 |
14 |
15 from PyQt5.QtCore import QObject, QTextCodec, QProcess, QProcessEnvironment, \ |
15 from PyQt5.QtCore import ( |
16 QTimer |
16 QObject, QTextCodec, QProcess, QProcessEnvironment, QTimer |
|
17 ) |
17 from PyQt5.QtWidgets import QInputDialog |
18 from PyQt5.QtWidgets import QInputDialog |
18 |
19 |
19 from E5Gui.E5Application import e5App |
20 from E5Gui.E5Application import e5App |
20 from E5Gui import E5MessageBox |
21 from E5Gui import E5MessageBox |
21 |
22 |
70 str(Preferences.getSystem("StringEncoding"))) |
71 str(Preferences.getSystem("StringEncoding"))) |
71 |
72 |
72 if passive: |
73 if passive: |
73 # set translation function |
74 # set translation function |
74 if Preferences.getDebugger("PathTranslation"): |
75 if Preferences.getDebugger("PathTranslation"): |
75 self.translateRemote = \ |
76 self.translateRemote = Preferences.getDebugger( |
76 Preferences.getDebugger("PathTranslationRemote") |
77 "PathTranslationRemote") |
77 self.translateRemoteWindows = "\\" in self.translateRemote |
78 self.translateRemoteWindows = "\\" in self.translateRemote |
78 self.translateLocal = \ |
79 self.translateLocal = Preferences.getDebugger( |
79 Preferences.getDebugger("PathTranslationLocal") |
80 "PathTranslationLocal") |
80 self.translateLocalWindows = "\\" in self.translateLocal |
81 self.translateLocalWindows = "\\" in self.translateLocal |
81 self.translate = self.__remoteTranslation |
82 self.translate = self.__remoteTranslation |
82 else: |
83 else: |
83 self.translate = self.__identityTranslation |
84 self.translate = self.__identityTranslation |
84 |
85 |
175 else: |
176 else: |
176 venvName = Preferences.getDebugger("Python3VirtualEnv") |
177 venvName = Preferences.getDebugger("Python3VirtualEnv") |
177 venvManager = e5App().getObject("VirtualEnvManager") |
178 venvManager = e5App().getObject("VirtualEnvManager") |
178 interpreter = venvManager.getVirtualenvInterpreter(venvName) |
179 interpreter = venvManager.getVirtualenvInterpreter(venvName) |
179 execPath = venvManager.getVirtualenvExecPath(venvName) |
180 execPath = venvManager.getVirtualenvExecPath(venvName) |
180 if interpreter == "" and \ |
181 if (interpreter == "" and |
181 int(self.__variant[-1]) == sys.version_info[0]: |
182 int(self.__variant[-1]) == sys.version_info[0]): |
182 # use the interpreter used to run eric for identical variants |
183 # use the interpreter used to run eric for identical variants |
183 interpreter = sys.executable.replace("w.exe", ".exe") |
184 interpreter = sys.executable.replace("w.exe", ".exe") |
184 if interpreter == "": |
185 if interpreter == "": |
185 E5MessageBox.critical( |
186 E5MessageBox.critical( |
186 None, |
187 None, |
208 "DebugClients", "Python", |
209 "DebugClients", "Python", |
209 "DebugClient.py") |
210 "DebugClient.py") |
210 |
211 |
211 if self.__variant == "Python2": |
212 if self.__variant == "Python2": |
212 redirect = str(Preferences.getDebugger("PythonRedirect")) |
213 redirect = str(Preferences.getDebugger("PythonRedirect")) |
213 noencoding = Preferences.getDebugger("PythonNoEncoding") and \ |
214 noencoding = (Preferences.getDebugger("PythonNoEncoding") and |
214 '--no-encoding' or '' |
215 '--no-encoding' or '') |
215 else: |
216 else: |
216 redirect = str(Preferences.getDebugger("Python3Redirect")) |
217 redirect = str(Preferences.getDebugger("Python3Redirect")) |
217 noencoding = Preferences.getDebugger("Python3NoEncoding") and \ |
218 noencoding = (Preferences.getDebugger("Python3NoEncoding") and |
218 '--no-encoding' or '' |
219 '--no-encoding' or '') |
219 |
220 |
220 if Preferences.getDebugger("RemoteDbgEnabled"): |
221 if Preferences.getDebugger("RemoteDbgEnabled"): |
221 ipaddr = self.debugServer.getHostAddress(False) |
222 ipaddr = self.debugServer.getHostAddress(False) |
222 rexec = Preferences.getDebugger("RemoteExecution") |
223 rexec = Preferences.getDebugger("RemoteExecution") |
223 rhost = Preferences.getDebugger("RemoteHost") |
224 rhost = Preferences.getDebugger("RemoteHost") |
224 if rhost == "": |
225 if rhost == "": |
225 rhost = "localhost" |
226 rhost = "localhost" |
226 if rexec: |
227 if rexec: |
227 args = Utilities.parseOptionString(rexec) + \ |
228 args = Utilities.parseOptionString(rexec) + [ |
228 [rhost, interpreter, debugClient, |
229 rhost, interpreter, debugClient, noencoding, str(port), |
229 noencoding, str(port), redirect, ipaddr] |
230 redirect, ipaddr] |
230 if Utilities.isWindowsPlatform(): |
231 if Utilities.isWindowsPlatform(): |
231 if not os.path.splitext(args[0])[1]: |
232 if not os.path.splitext(args[0])[1]: |
232 for ext in [".exe", ".com", ".cmd", ".bat"]: |
233 for ext in [".exe", ".com", ".cmd", ".bat"]: |
233 prog = Utilities.getExecutablePath(args[0] + ext) |
234 prog = Utilities.getExecutablePath(args[0] + ext) |
234 if prog: |
235 if prog: |
246 """<p>The debugger backend could not be""" |
247 """<p>The debugger backend could not be""" |
247 """ started.</p>""")) |
248 """ started.</p>""")) |
248 |
249 |
249 # set translation function |
250 # set translation function |
250 if Preferences.getDebugger("PathTranslation"): |
251 if Preferences.getDebugger("PathTranslation"): |
251 self.translateRemote = \ |
252 self.translateRemote = Preferences.getDebugger( |
252 Preferences.getDebugger("PathTranslationRemote") |
253 "PathTranslationRemote") |
253 self.translateRemoteWindows = "\\" in self.translateRemote |
254 self.translateRemoteWindows = "\\" in self.translateRemote |
254 self.translateLocal = \ |
255 self.translateLocal = Preferences.getDebugger( |
255 Preferences.getDebugger("PathTranslationLocal") |
256 "PathTranslationLocal") |
256 self.translate = self.__remoteTranslation |
257 self.translate = self.__remoteTranslation |
257 self.translateLocalWindows = "\\" in self.translateLocal |
258 self.translateLocalWindows = "\\" in self.translateLocal |
258 else: |
259 else: |
259 self.translate = self.__identityTranslation |
260 self.translate = self.__identityTranslation |
260 return process, self.__isNetworked, "" |
261 return process, self.__isNetworked, "" |
288 |
289 |
289 ipaddr = self.debugServer.getHostAddress(True) |
290 ipaddr = self.debugServer.getHostAddress(True) |
290 if runInConsole or Preferences.getDebugger("ConsoleDbgEnabled"): |
291 if runInConsole or Preferences.getDebugger("ConsoleDbgEnabled"): |
291 ccmd = Preferences.getDebugger("ConsoleDbgCommand") |
292 ccmd = Preferences.getDebugger("ConsoleDbgCommand") |
292 if ccmd: |
293 if ccmd: |
293 args = Utilities.parseOptionString(ccmd) + \ |
294 args = Utilities.parseOptionString(ccmd) + [ |
294 [interpreter, os.path.abspath(debugClient), |
295 interpreter, os.path.abspath(debugClient), noencoding, |
295 noencoding, str(port), '0', ipaddr] |
296 str(port), '0', ipaddr] |
296 args[0] = Utilities.getExecutablePath(args[0]) |
297 args[0] = Utilities.getExecutablePath(args[0]) |
297 process = self.__startProcess(args[0], args[1:], clientEnv, |
298 process = self.__startProcess(args[0], args[1:], clientEnv, |
298 workingDir=workingDir) |
299 workingDir=workingDir) |
299 if process is None: |
300 if process is None: |
300 E5MessageBox.critical( |
301 E5MessageBox.critical( |
357 venvName = Preferences.getDebugger("Python2VirtualEnv") |
358 venvName = Preferences.getDebugger("Python2VirtualEnv") |
358 elif project.getProjectLanguage() == "Python3": |
359 elif project.getProjectLanguage() == "Python3": |
359 venvName = Preferences.getDebugger("Python3VirtualEnv") |
360 venvName = Preferences.getDebugger("Python3VirtualEnv") |
360 |
361 |
361 redirect = str(project.getDebugProperty("REDIRECT")) |
362 redirect = str(project.getDebugProperty("REDIRECT")) |
362 noencoding = \ |
363 noencoding = ( |
363 project.getDebugProperty("NOENCODING") and '--no-encoding' or '' |
364 project.getDebugProperty("NOENCODING") and '--no-encoding' or '') |
364 |
365 |
365 venvManager = e5App().getObject("VirtualEnvManager") |
366 venvManager = e5App().getObject("VirtualEnvManager") |
366 interpreter = venvManager.getVirtualenvInterpreter(venvName) |
367 interpreter = venvManager.getVirtualenvInterpreter(venvName) |
367 execPath = venvManager.getVirtualenvExecPath(venvName) |
368 execPath = venvManager.getVirtualenvExecPath(venvName) |
368 if interpreter == "" and \ |
369 if (interpreter == "" and |
369 project.getProjectLanguage().startswith("Python") and \ |
370 project.getProjectLanguage().startswith("Python") and |
370 sys.version_info[0] == int(project.getProjectLanguage()[-1]): |
371 sys.version_info[0] == int(project.getProjectLanguage()[-1])): |
371 interpreter = sys.executable.replace("w.exe", ".exe") |
372 interpreter = sys.executable.replace("w.exe", ".exe") |
372 if interpreter == "": |
373 if interpreter == "": |
373 E5MessageBox.critical( |
374 E5MessageBox.critical( |
374 None, |
375 None, |
375 self.tr("Start Debugger"), |
376 self.tr("Start Debugger"), |
383 rexec = project.getDebugProperty("REMOTECOMMAND") |
384 rexec = project.getDebugProperty("REMOTECOMMAND") |
384 rhost = project.getDebugProperty("REMOTEHOST") |
385 rhost = project.getDebugProperty("REMOTEHOST") |
385 if rhost == "": |
386 if rhost == "": |
386 rhost = "localhost" |
387 rhost = "localhost" |
387 if rexec: |
388 if rexec: |
388 args = Utilities.parseOptionString(rexec) + \ |
389 args = Utilities.parseOptionString(rexec) + [ |
389 [rhost, interpreter, debugClient, noencoding, |
390 rhost, interpreter, debugClient, noencoding, str(port), |
390 str(port), redirect, ipaddr] |
391 redirect, ipaddr] |
391 if Utilities.isWindowsPlatform(): |
392 if Utilities.isWindowsPlatform(): |
392 if not os.path.splitext(args[0])[1]: |
393 if not os.path.splitext(args[0])[1]: |
393 for ext in [".exe", ".com", ".cmd", ".bat"]: |
394 for ext in [".exe", ".com", ".cmd", ".bat"]: |
394 prog = Utilities.getExecutablePath(args[0] + ext) |
395 prog = Utilities.getExecutablePath(args[0] + ext) |
395 if prog: |
396 if prog: |
406 self.tr( |
407 self.tr( |
407 """<p>The debugger backend could not be""" |
408 """<p>The debugger backend could not be""" |
408 """ started.</p>""")) |
409 """ started.</p>""")) |
409 # set translation function |
410 # set translation function |
410 if project.getDebugProperty("PATHTRANSLATION"): |
411 if project.getDebugProperty("PATHTRANSLATION"): |
411 self.translateRemote = \ |
412 self.translateRemote = project.getDebugProperty( |
412 project.getDebugProperty("REMOTEPATH") |
413 "REMOTEPATH") |
413 self.translateRemoteWindows = "\\" in self.translateRemote |
414 self.translateRemoteWindows = "\\" in self.translateRemote |
414 self.translateLocal = \ |
415 self.translateLocal = project.getDebugProperty("LOCALPATH") |
415 project.getDebugProperty("LOCALPATH") |
|
416 self.translateLocalWindows = "\\" in self.translateLocal |
416 self.translateLocalWindows = "\\" in self.translateLocal |
417 self.translate = self.__remoteTranslation |
417 self.translate = self.__remoteTranslation |
418 else: |
418 else: |
419 self.translate = self.__identityTranslation |
419 self.translate = self.__identityTranslation |
420 return process, self.__isNetworked, "" |
420 return process, self.__isNetworked, "" |
449 else: |
449 else: |
450 clientEnv["PATH"] = execPath |
450 clientEnv["PATH"] = execPath |
451 |
451 |
452 ipaddr = self.debugServer.getHostAddress(True) |
452 ipaddr = self.debugServer.getHostAddress(True) |
453 if runInConsole or project.getDebugProperty("CONSOLEDEBUGGER"): |
453 if runInConsole or project.getDebugProperty("CONSOLEDEBUGGER"): |
454 ccmd = project.getDebugProperty("CONSOLECOMMAND") or \ |
454 ccmd = (project.getDebugProperty("CONSOLECOMMAND") or |
455 Preferences.getDebugger("ConsoleDbgCommand") |
455 Preferences.getDebugger("ConsoleDbgCommand")) |
456 if ccmd: |
456 if ccmd: |
457 args = Utilities.parseOptionString(ccmd) + \ |
457 args = Utilities.parseOptionString(ccmd) + [ |
458 [interpreter, os.path.abspath(debugClient), |
458 interpreter, os.path.abspath(debugClient), noencoding, |
459 noencoding, str(port), '0', ipaddr] |
459 str(port), '0', ipaddr] |
460 args[0] = Utilities.getExecutablePath(args[0]) |
460 args[0] = Utilities.getExecutablePath(args[0]) |
461 process = self.__startProcess(args[0], args[1:], clientEnv, |
461 process = self.__startProcess(args[0], args[1:], clientEnv, |
462 workingDir=workingDir) |
462 workingDir=workingDir) |
463 if process is None: |
463 if process is None: |
464 E5MessageBox.critical( |
464 E5MessageBox.critical( |