15 from PyQt4.QtCore import * |
15 from PyQt4.QtCore import * |
16 from PyQt4.QtGui import QInputDialog, QMessageBox |
16 from PyQt4.QtGui import QInputDialog, QMessageBox |
17 |
17 |
18 from E4Gui.E4Application import e4App |
18 from E4Gui.E4Application import e4App |
19 |
19 |
20 from DebugProtocol import * |
20 from .DebugProtocol import * |
21 import DebugClientCapabilities |
21 from . import DebugClientCapabilities |
22 |
22 |
23 import Preferences |
23 import Preferences |
24 import Utilities |
24 import Utilities |
25 |
25 |
26 from eric4config import getConfig |
26 from eric4config import getConfig |
120 @return the process object (QProcess) or None |
120 @return the process object (QProcess) or None |
121 """ |
121 """ |
122 proc = QProcess() |
122 proc = QProcess() |
123 if environment is not None: |
123 if environment is not None: |
124 env = [] |
124 env = [] |
125 for key, value in environment.items(): |
125 for key, value in list(environment.items()): |
126 env.append("%s=%s" % (key, value)) |
126 env.append("%s=%s" % (key, value)) |
127 proc.setEnvironment(env) |
127 proc.setEnvironment(env) |
128 args = [] |
128 args = [] |
129 for arg in arguments: |
129 for arg in arguments: |
130 args.append(arg) |
130 args.append(arg) |
410 """ |
410 """ |
411 Public method to set the environment for a program to debug, run, ... |
411 Public method to set the environment for a program to debug, run, ... |
412 |
412 |
413 @param env environment settings (dictionary) |
413 @param env environment settings (dictionary) |
414 """ |
414 """ |
415 self.__sendCommand('%s%s\n' % (RequestEnv, unicode(env))) |
415 self.__sendCommand('%s%s\n' % (RequestEnv, str(env))) |
416 |
416 |
417 def remoteLoad(self, fn, argv, wd, traceInterpreter = False, autoContinue = True, |
417 def remoteLoad(self, fn, argv, wd, traceInterpreter = False, autoContinue = True, |
418 autoFork = False, forkChild = False): |
418 autoFork = False, forkChild = False): |
419 """ |
419 """ |
420 Public method to load a new program to debug. |
420 Public method to load a new program to debug. |
433 |
433 |
434 wd = self.translate(wd, False) |
434 wd = self.translate(wd, False) |
435 fn = self.translate(os.path.abspath(fn), False) |
435 fn = self.translate(os.path.abspath(fn), False) |
436 self.__sendCommand('%s%s\n' % (RequestForkMode, repr((autoFork, forkChild)))) |
436 self.__sendCommand('%s%s\n' % (RequestForkMode, repr((autoFork, forkChild)))) |
437 self.__sendCommand('%s%s|%s|%s|%d\n' % \ |
437 self.__sendCommand('%s%s|%s|%s|%d\n' % \ |
438 (RequestLoad, wd, fn, unicode(Utilities.parseOptionString(argv)), |
438 (RequestLoad, wd, fn, str(Utilities.parseOptionString(argv)), |
439 traceInterpreter)) |
439 traceInterpreter)) |
440 |
440 |
441 def remoteRun(self, fn, argv, wd): |
441 def remoteRun(self, fn, argv, wd): |
442 """ |
442 """ |
443 Public method to load a new program to run. |
443 Public method to load a new program to run. |
447 @param wd the working directory for the program (string) |
447 @param wd the working directory for the program (string) |
448 """ |
448 """ |
449 wd = self.translate(wd, False) |
449 wd = self.translate(wd, False) |
450 fn = self.translate(os.path.abspath(fn), False) |
450 fn = self.translate(os.path.abspath(fn), False) |
451 self.__sendCommand('%s%s|%s|%s\n' % \ |
451 self.__sendCommand('%s%s|%s|%s\n' % \ |
452 (RequestRun, wd, fn, unicode(Utilities.parseOptionString(argv)))) |
452 (RequestRun, wd, fn, str(Utilities.parseOptionString(argv)))) |
453 |
453 |
454 def remoteCoverage(self, fn, argv, wd, erase = False): |
454 def remoteCoverage(self, fn, argv, wd, erase = False): |
455 """ |
455 """ |
456 Public method to load a new program to collect coverage data. |
456 Public method to load a new program to collect coverage data. |
457 |
457 |
462 cleared first (boolean) |
462 cleared first (boolean) |
463 """ |
463 """ |
464 wd = self.translate(wd, False) |
464 wd = self.translate(wd, False) |
465 fn = self.translate(os.path.abspath(fn), False) |
465 fn = self.translate(os.path.abspath(fn), False) |
466 self.__sendCommand('%s%s@@%s@@%s@@%d\n' % \ |
466 self.__sendCommand('%s%s@@%s@@%s@@%d\n' % \ |
467 (RequestCoverage, wd, fn, unicode(Utilities.parseOptionString(argv)), |
467 (RequestCoverage, wd, fn, str(Utilities.parseOptionString(argv)), |
468 erase)) |
468 erase)) |
469 |
469 |
470 def remoteProfile(self, fn, argv, wd, erase = False): |
470 def remoteProfile(self, fn, argv, wd, erase = False): |
471 """ |
471 """ |
472 Public method to load a new program to collect profiling data. |
472 Public method to load a new program to collect profiling data. |
477 @keyparam erase flag indicating that timing info should be cleared first (boolean) |
477 @keyparam erase flag indicating that timing info should be cleared first (boolean) |
478 """ |
478 """ |
479 wd = self.translate(wd, False) |
479 wd = self.translate(wd, False) |
480 fn = self.translate(os.path.abspath(fn), False) |
480 fn = self.translate(os.path.abspath(fn), False) |
481 self.__sendCommand('%s%s|%s|%s|%d\n' % \ |
481 self.__sendCommand('%s%s|%s|%s|%d\n' % \ |
482 (RequestProfile, wd, fn, unicode(Utilities.parseOptionString(argv)), erase)) |
482 (RequestProfile, wd, fn, str(Utilities.parseOptionString(argv)), erase)) |
483 |
483 |
484 def remoteStatement(self, stmt): |
484 def remoteStatement(self, stmt): |
485 """ |
485 """ |
486 Public method to execute a Python statement. |
486 Public method to execute a Python statement. |
487 |
487 |
619 @param scope the scope of the variables (0 = local, 1 = global) |
619 @param scope the scope of the variables (0 = local, 1 = global) |
620 @param filter list of variable types to filter out (list of int) |
620 @param filter list of variable types to filter out (list of int) |
621 @param framenr framenumber of the variables to retrieve (int) |
621 @param framenr framenumber of the variables to retrieve (int) |
622 """ |
622 """ |
623 self.__sendCommand('%s%d, %d, %s\n' % \ |
623 self.__sendCommand('%s%d, %d, %s\n' % \ |
624 (RequestVariables, framenr, scope, unicode(filter))) |
624 (RequestVariables, framenr, scope, str(filter))) |
625 |
625 |
626 def remoteClientVariable(self, scope, filter, var, framenr = 0): |
626 def remoteClientVariable(self, scope, filter, var, framenr = 0): |
627 """ |
627 """ |
628 Public method to request the variables of the debugged program. |
628 Public method to request the variables of the debugged program. |
629 |
629 |
631 @param filter list of variable types to filter out (list of int) |
631 @param filter list of variable types to filter out (list of int) |
632 @param var list encoded name of variable to retrieve (string) |
632 @param var list encoded name of variable to retrieve (string) |
633 @param framenr framenumber of the variables to retrieve (int) |
633 @param framenr framenumber of the variables to retrieve (int) |
634 """ |
634 """ |
635 self.__sendCommand('%s%s, %d, %d, %s\n' % \ |
635 self.__sendCommand('%s%s, %d, %d, %s\n' % \ |
636 (RequestVariable, unicode(var), framenr, scope, str(filter))) |
636 (RequestVariable, str(var), framenr, scope, str(filter))) |
637 |
637 |
638 def remoteClientSetFilter(self, scope, filter): |
638 def remoteClientSetFilter(self, scope, filter): |
639 """ |
639 """ |
640 Public method to set a variables filter list. |
640 Public method to set a variables filter list. |
641 |
641 |
730 Private method to handle data from the client. |
730 Private method to handle data from the client. |
731 """ |
731 """ |
732 while self.qsock and self.qsock.canReadLine(): |
732 while self.qsock and self.qsock.canReadLine(): |
733 qs = self.qsock.readLine() |
733 qs = self.qsock.readLine() |
734 if self.codec is not None: |
734 if self.codec is not None: |
735 us = self.codec.fromUnicode(unicode(qs)) |
735 line = self.codec.toUnicode(qs) |
736 else: |
736 else: |
737 us = qs |
737 line = bytes(qs).decode() |
738 line = str(us) |
|
739 if line.endswith(EOT): |
738 if line.endswith(EOT): |
740 line = line[:-len(EOT)] |
739 line = line[:-len(EOT)] |
741 if not line: |
740 if not line: |
742 continue |
741 continue |
743 |
742 |
744 ## print "Server: ", line ##debug |
743 ## print("Server: ", line) ##debug |
745 |
744 |
746 eoc = line.find('<') + 1 |
745 eoc = line.find('<') + 1 |
747 |
746 |
748 # Deal with case where user has written directly to stdout |
747 # Deal with case where user has written directly to stdout |
749 # or stderr, but not line terminated and we stepped over the |
748 # or stderr, but not line terminated and we stepped over the |