10 import contextlib |
10 import contextlib |
11 import enum |
11 import enum |
12 import pathlib |
12 import pathlib |
13 import re |
13 import re |
14 import sys |
14 import sys |
|
15 import time |
15 |
16 |
16 from PyQt6.Qsci import QsciScintilla |
17 from PyQt6.Qsci import QsciScintilla |
17 from PyQt6.QtCore import QEvent, QPoint, Qt, pyqtSignal, pyqtSlot |
18 from PyQt6.QtCore import QEvent, QPoint, Qt, pyqtSignal, pyqtSlot |
18 from PyQt6.QtGui import QClipboard, QFont, QPalette, QShortcut |
19 from PyQt6.QtGui import QClipboard, QFont, QPalette, QShortcut |
19 from PyQt6.QtWidgets import ( |
20 from PyQt6.QtWidgets import ( |
1923 self.__getBanner() |
1924 self.__getBanner() |
1924 elif cmd == "%clear": |
1925 elif cmd == "%clear": |
1925 # Display the banner. |
1926 # Display the banner. |
1926 self.__getBanner() |
1927 self.__getBanner() |
1927 elif cmd in ["%reset", "%restart"]: |
1928 elif cmd in ["%reset", "%restart"]: |
1928 self.dbs.startClient( |
1929 self.doRestart() |
1929 False, |
|
1930 venvName=self.__currentVenv, |
|
1931 workingDir=self.__currentWorkingDirectory, |
|
1932 ) |
|
1933 elif cmd in ["%envs", "%environments"]: |
1930 elif cmd in ["%envs", "%environments"]: |
1934 venvs = ( |
1931 venvs = ( |
1935 ericApp().getObject("VirtualEnvManager").getVirtualenvNames() |
1932 ericApp().getObject("VirtualEnvManager").getVirtualenvNames() |
1936 ) |
1933 ) |
1937 s = self.tr("Available Virtual Environments:\n{0}\n").format( |
1934 s = self.tr("Available Virtual Environments:\n{0}\n").format( |
1979 self.__write(s) |
1976 self.__write(s) |
1980 self.__clientStatement(False) |
1977 self.__clientStatement(False) |
1981 self.setFocus(Qt.FocusReason.OtherFocusReason) |
1978 self.setFocus(Qt.FocusReason.OtherFocusReason) |
1982 else: |
1979 else: |
1983 self.dbs.remoteStatement(self.__getSelectedDebuggerId(), cmd) |
1980 self.dbs.remoteStatement(self.__getSelectedDebuggerId(), cmd) |
1984 while self.inCommandExecution: |
1981 now = time.monotonic() |
|
1982 while self.inCommandExecution and time.monotonic() - now < 10: |
|
1983 # 10 seconds timeout |
1985 with contextlib.suppress(KeyboardInterrupt): |
1984 with contextlib.suppress(KeyboardInterrupt): |
1986 QApplication.processEvents() |
1985 QApplication.processEvents() |
1987 else: |
1986 else: |
1988 if not self.__echoInput: |
1987 if not self.__echoInput: |
1989 cmd = self.buff |
1988 cmd = self.buff |