eric6/Debugger/DebugUI.py

branch
maintenance
changeset 8176
31965986ecd1
parent 8142
43248bafe9b2
parent 8163
29fb6d420a25
child 8273
698ae46f40a4
--- a/eric6/Debugger/DebugUI.py	Sat Mar 06 10:00:52 2021 +0100
+++ b/eric6/Debugger/DebugUI.py	Sun Mar 28 15:00:11 2021 +0200
@@ -8,6 +8,7 @@
 """
 
 import os
+import copy
 
 from PyQt5.QtCore import pyqtSignal, pyqtSlot, QObject, Qt
 from PyQt5.QtGui import QKeySequence
@@ -110,6 +111,12 @@
         self.multiprocessNoDebugHistory = Preferences.toList(
             Preferences.Prefs.settings.value(
                 'DebugInfo/MultiprocessNoDebugHistory'))
+        self.overrideGlobalConfig = {
+            "enable": Preferences.toBool(Preferences.Prefs.settings.value(
+                'DebugInfo/OverrideGlobal', False)),
+            "redirect": Preferences.toBool(Preferences.Prefs.settings.value(
+                'DebugInfo/RedirectStdinStdout', True)),
+        }
         
         self.lastDebuggedFile = None
         self.lastStartAction = 0    # 0=None, 1=Script, 2=Project
@@ -201,7 +208,7 @@
             self.tr('Run Script'),
             UI.PixmapCache.getIcon("runScript"),
             self.tr('&Run Script...'),
-            Qt.Key_F2, 0, self, 'dbg_run_script')
+            Qt.Key.Key_F2, 0, self, 'dbg_run_script')
         self.runAct.setStatusTip(self.tr('Run the current Script'))
         self.runAct.setWhatsThis(self.tr(
             """<b>Run Script</b>"""
@@ -215,8 +222,9 @@
         self.runProjectAct = E5Action(
             self.tr('Run Project'),
             UI.PixmapCache.getIcon("runProject"),
-            self.tr('Run &Project...'), Qt.SHIFT + Qt.Key_F2, 0, self,
-            'dbg_run_project')
+            self.tr('Run &Project...'),
+            Qt.Modifier.SHIFT + Qt.Key.Key_F2,
+            0, self, 'dbg_run_project')
         self.runProjectAct.setStatusTip(self.tr('Run the current Project'))
         self.runProjectAct.setWhatsThis(self.tr(
             """<b>Run Project</b>"""
@@ -293,7 +301,7 @@
         self.debugAct = E5Action(
             self.tr('Debug Script'),
             UI.PixmapCache.getIcon("debugScript"),
-            self.tr('&Debug Script...'), Qt.Key_F5, 0, self,
+            self.tr('&Debug Script...'), Qt.Key.Key_F5, 0, self,
             'dbg_debug_script')
         self.debugAct.setStatusTip(self.tr('Debug the current Script'))
         self.debugAct.setWhatsThis(self.tr(
@@ -309,8 +317,9 @@
         self.debugProjectAct = E5Action(
             self.tr('Debug Project'),
             UI.PixmapCache.getIcon("debugProject"),
-            self.tr('Debug &Project...'), Qt.SHIFT + Qt.Key_F5, 0, self,
-            'dbg_debug_project')
+            self.tr('Debug &Project...'),
+            Qt.Modifier.SHIFT + Qt.Key.Key_F5,
+            0, self, 'dbg_debug_project')
         self.debugProjectAct.setStatusTip(self.tr(
             'Debug the current Project'))
         self.debugProjectAct.setWhatsThis(self.tr(
@@ -326,7 +335,7 @@
         self.restartAct = E5Action(
             self.tr('Restart'),
             UI.PixmapCache.getIcon("debugRestart"),
-            self.tr('Restart'), Qt.Key_F4, 0, self, 'dbg_restart_script')
+            self.tr('Restart'), Qt.Key.Key_F4, 0, self, 'dbg_restart_script')
         self.restartAct.setStatusTip(self.tr(
             'Restart the last debugged script'))
         self.restartAct.setWhatsThis(self.tr(
@@ -342,7 +351,7 @@
         self.stopAct = E5Action(
             self.tr('Stop'),
             UI.PixmapCache.getIcon("stopScript"),
-            self.tr('Stop'), Qt.SHIFT + Qt.Key_F10, 0,
+            self.tr('Stop'), Qt.Modifier.SHIFT + Qt.Key.Key_F10, 0,
             self, 'dbg_stop_script')
         self.stopAct.setStatusTip(self.tr("""Stop the running script."""))
         self.stopAct.setWhatsThis(self.tr(
@@ -357,7 +366,7 @@
         act = E5Action(
             self.tr('Continue'),
             UI.PixmapCache.getIcon("continue"),
-            self.tr('&Continue'), Qt.Key_F6, 0,
+            self.tr('&Continue'), Qt.Key.Key_F6, 0,
             self.debugActGrp, 'dbg_continue')
         act.setStatusTip(
             self.tr('Continue running the program from the current line'))
@@ -373,8 +382,9 @@
         act = E5Action(
             self.tr('Continue to Cursor'),
             UI.PixmapCache.getIcon("continueToCursor"),
-            self.tr('Continue &To Cursor'), Qt.SHIFT + Qt.Key_F6, 0,
-            self.debugActGrp, 'dbg_continue_to_cursor')
+            self.tr('Continue &To Cursor'),
+            Qt.Modifier.SHIFT + Qt.Key.Key_F6,
+            0, self.debugActGrp, 'dbg_continue_to_cursor')
         act.setStatusTip(self.tr(
             """Continue running the program from the"""
             """ current line to the current cursor position"""))
@@ -389,7 +399,7 @@
         act = E5Action(
             self.tr('Continue Until'),
             UI.PixmapCache.getIcon("continueUntil"),
-            self.tr('Continue &Until'), Qt.CTRL + Qt.Key_F6, 0,
+            self.tr('Continue &Until'), Qt.Modifier.CTRL + Qt.Key.Key_F6, 0,
             self.debugActGrp, 'dbg_continue_until')
         act.setStatusTip(self.tr(
             """Continue running the program from the current line to the"""
@@ -406,7 +416,7 @@
         act = E5Action(
             self.tr('Move Instruction Pointer to Cursor'),
             UI.PixmapCache.getIcon("moveInstructionPointer"),
-            self.tr('&Jump To Cursor'), Qt.Key_F12, 0,
+            self.tr('&Jump To Cursor'), Qt.Key.Key_F12, 0,
             self.debugActGrp, 'dbg_jump_to_cursor')
         act.setStatusTip(self.tr(
             """Skip the code from the"""
@@ -426,7 +436,7 @@
         act = E5Action(
             self.tr('Single Step'),
             UI.PixmapCache.getIcon("step"),
-            self.tr('Sin&gle Step'), Qt.Key_F7, 0,
+            self.tr('Sin&gle Step'), Qt.Key.Key_F7, 0,
             self.debugActGrp, 'dbg_single_step')
         act.setStatusTip(self.tr('Execute a single Python statement'))
         act.setWhatsThis(self.tr(
@@ -442,7 +452,7 @@
         act = E5Action(
             self.tr('Step Over'),
             UI.PixmapCache.getIcon("stepOver"),
-            self.tr('Step &Over'), Qt.Key_F8, 0,
+            self.tr('Step &Over'), Qt.Key.Key_F8, 0,
             self.debugActGrp, 'dbg_step_over')
         act.setStatusTip(self.tr(
             """Execute a single Python statement staying"""
@@ -461,7 +471,7 @@
         act = E5Action(
             self.tr('Step Out'),
             UI.PixmapCache.getIcon("stepOut"),
-            self.tr('Step Ou&t'), Qt.Key_F9, 0,
+            self.tr('Step Ou&t'), Qt.Key.Key_F9, 0,
             self.debugActGrp, 'dbg_step_out')
         act.setStatusTip(self.tr(
             """Execute Python statements until leaving"""
@@ -480,7 +490,7 @@
         act = E5Action(
             self.tr('Stop'),
             UI.PixmapCache.getIcon("stepQuit"),
-            self.tr('&Stop'), Qt.Key_F10, 0,
+            self.tr('&Stop'), Qt.Key.Key_F10, 0,
             self.debugActGrp, 'dbg_stop')
         act.setStatusTip(self.tr('Stop debugging'))
         act.setWhatsThis(self.tr(
@@ -1001,6 +1011,12 @@
         Preferences.Prefs.settings.setValue(
             'DebugInfo/MultiprocessNoDebugHistory',
             self.multiprocessNoDebugHistory)
+        Preferences.Prefs.settings.setValue(
+            'DebugInfo/OverrideGlobal',
+            self.overrideGlobalConfig["enable"])
+        Preferences.Prefs.settings.setValue(
+            'DebugInfo/RedirectStdinStdout',
+            self.overrideGlobalConfig["redirect"])
         
     def shutdownServer(self):
         """
@@ -1472,7 +1488,7 @@
         dlg = EditBreakpointDialog(
             (fn, line), (cond, temp, enabled, count),
             [], self.ui, modal=True)
-        if dlg.exec() == QDialog.Accepted:
+        if dlg.exec() == QDialog.DialogCode.Accepted:
             cond, temp, enabled, count = dlg.getData()
             model.setBreakPointByIndex(index, fn, line,
                                        (cond, temp, enabled, count))
@@ -1509,7 +1525,7 @@
         from .EditWatchpointDialog import EditWatchpointDialog
         dlg = EditWatchpointDialog(
             (cond, temp, enabled, count, special), self.ui)
-        if dlg.exec() == QDialog.Accepted:
+        if dlg.exec() == QDialog.DialogCode.Accepted:
             cond, temp, enabled, count, special = dlg.getData()
             
             # check for duplicates
@@ -1545,7 +1561,7 @@
         dlg = VariablesFilterDialog(self.ui, 'Filter Dialog', True)
         dlg.setSelection(self.__localsVarFilterList,
                          self.__globalsVarFilterList)
-        if dlg.exec() == QDialog.Accepted:
+        if dlg.exec() == QDialog.DialogCode.Accepted:
             self.__localsVarFilterList, self.__globalsVarFilterList = (
                 dlg.getSelection()
             )
@@ -1558,7 +1574,7 @@
         """
         from .ExceptionsFilterDialog import ExceptionsFilterDialog
         dlg = ExceptionsFilterDialog(self.excList, ignore=False)
-        if dlg.exec() == QDialog.Accepted:
+        if dlg.exec() == QDialog.DialogCode.Accepted:
             self.excList = dlg.getExceptionsList()[:]   # keep a copy
         
     def __configureIgnoredExceptions(self):
@@ -1567,7 +1583,7 @@
         """
         from .ExceptionsFilterDialog import ExceptionsFilterDialog
         dlg = ExceptionsFilterDialog(self.excIgnoreList, ignore=True)
-        if dlg.exec() == QDialog.Accepted:
+        if dlg.exec() == QDialog.DialogCode.Accepted:
             self.excIgnoreList = dlg.getExceptionsList()[:]   # keep a copy
         
     def __toggleBreakpoint(self):
@@ -1688,10 +1704,12 @@
         dlg = StartDialog(
             cap, self.lastUsedVenvName, self.argvHistory, self.wdHistory,
             self.envHistory, self.exceptions, self.ui, 2,
-            autoClearShell=self.autoClearShell)
-        if dlg.exec() == QDialog.Accepted:
+            autoClearShell=self.autoClearShell,
+            configOverride=self.overrideGlobalConfig)
+        if dlg.exec() == QDialog.DialogCode.Accepted:
             (lastUsedVenvName, argv, wd, env, exceptions, clearShell,
              console) = dlg.getData()
+            configOverride = dlg.getGlobalOverrideData()
             eraseCoverage = dlg.getCoverageData()
             
             if runProject:
@@ -1714,7 +1732,8 @@
                 # save the info for later use
                 self.project.setDbgInfo(
                     lastUsedVenvName, argv, wd, env, exceptions, self.excList,
-                    self.excIgnoreList, clearShell
+                    self.excIgnoreList, clearShell,
+                    configOverride=configOverride
                 )
                 
                 self.lastStartAction = 6
@@ -1760,6 +1779,9 @@
             # Save the run in console flag
             self.runInConsole = console
             
+            # Save the global config override data
+            self.overrideGlobalConfig = copy.deepcopy(configOverride)
+            
             # Hide all error highlights
             self.viewmanager.unhighlight()
             
@@ -1776,7 +1798,8 @@
                     lastUsedVenvName, fn, argv, wd, env,
                     autoClearShell=self.autoClearShell, erase=eraseCoverage,
                     forProject=runProject, runInConsole=console,
-                    clientType=self.clientType)
+                    clientType=self.clientType,
+                    configOverride=self.overrideGlobalConfig)
                 
                 self.stopAct.setEnabled(True)
         
@@ -1825,10 +1848,12 @@
         dlg = StartDialog(
             cap, self.lastUsedVenvName, self.argvHistory, self.wdHistory,
             self.envHistory, self.exceptions, self.ui, 3,
-            autoClearShell=self.autoClearShell)
-        if dlg.exec() == QDialog.Accepted:
+            autoClearShell=self.autoClearShell,
+            configOverride=self.overrideGlobalConfig)
+        if dlg.exec() == QDialog.DialogCode.Accepted:
             (lastUsedVenvName, argv, wd, env, exceptions, clearShell,
              console) = dlg.getData()
+            configOverride = dlg.getGlobalOverrideData()
             eraseTimings = dlg.getProfilingData()
             
             if runProject:
@@ -1851,7 +1876,8 @@
                 # save the info for later use
                 self.project.setDbgInfo(
                     lastUsedVenvName, argv, wd, env, exceptions, self.excList,
-                    self.excIgnoreList, clearShell
+                    self.excIgnoreList, clearShell,
+                    configOverride=configOverride
                 )
                 
                 self.lastStartAction = 8
@@ -1897,6 +1923,9 @@
             # Save the run in console flag
             self.runInConsole = console
             
+            # Save the global config override data
+            self.overrideGlobalConfig = copy.deepcopy(configOverride)
+            
             # Hide all error highlights
             self.viewmanager.unhighlight()
             
@@ -1913,7 +1942,8 @@
                     lastUsedVenvName, fn, argv, wd, env,
                     autoClearShell=self.autoClearShell, erase=eraseTimings,
                     forProject=runProject, runInConsole=console,
-                    clientType=self.clientType)
+                    clientType=self.clientType,
+                    configOverride=self.overrideGlobalConfig)
                 
                 self.stopAct.setEnabled(True)
         
@@ -1962,10 +1992,12 @@
         dlg = StartDialog(
             cap, self.lastUsedVenvName, self.argvHistory, self.wdHistory,
             self.envHistory, self.exceptions, self.ui, 1,
-            autoClearShell=self.autoClearShell)
-        if dlg.exec() == QDialog.Accepted:
+            autoClearShell=self.autoClearShell,
+            configOverride=self.overrideGlobalConfig)
+        if dlg.exec() == QDialog.DialogCode.Accepted:
             (lastUsedVenvName, argv, wd, env, exceptions, clearShell,
              console) = dlg.getData()
+            configOverride = dlg.getGlobalOverrideData()
             
             if runProject:
                 fn = self.project.getMainScript(True)
@@ -1987,7 +2019,8 @@
                 # save the info for later use
                 self.project.setDbgInfo(
                     lastUsedVenvName, argv, wd, env, exceptions, self.excList,
-                    self.excIgnoreList, clearShell
+                    self.excIgnoreList, clearShell,
+                    configOverride=configOverride
                 )
                 
                 self.lastStartAction = 4
@@ -2031,6 +2064,9 @@
             # Save the run in console flag
             self.runInConsole = console
             
+            # Save the global config override data
+            self.overrideGlobalConfig = copy.deepcopy(configOverride)
+            
             # Hide all error highlights
             self.viewmanager.unhighlight()
             
@@ -2046,7 +2082,8 @@
                 self.debugServer.remoteRun(
                     lastUsedVenvName, fn, argv, wd, env,
                     autoClearShell=self.autoClearShell, forProject=runProject,
-                    runInConsole=console, clientType=self.clientType)
+                    runInConsole=console, clientType=self.clientType,
+                    configOverride=self.overrideGlobalConfig)
                 
                 self.stopAct.setEnabled(True)
         
@@ -2098,10 +2135,12 @@
             tracePython=self.tracePython, autoClearShell=self.autoClearShell,
             autoContinue=self.autoContinue,
             enableMultiprocess=self.enableMultiprocess,
-            multiprocessNoDebugHistory=self.multiprocessNoDebugHistory)
-        if dlg.exec() == QDialog.Accepted:
+            multiprocessNoDebugHistory=self.multiprocessNoDebugHistory,
+            configOverride=self.overrideGlobalConfig)
+        if dlg.exec() == QDialog.DialogCode.Accepted:
             (lastUsedVenvName, argv, wd, env, exceptions, clearShell,
              console) = dlg.getData()
+            configOverride = dlg.getGlobalOverrideData()
             (tracePython, autoContinue, enableMultiprocess,
              multiprocessNoDebug) = dlg.getDebugData()
             
@@ -2128,7 +2167,8 @@
                     self.excIgnoreList, clearShell, tracePython=tracePython,
                     autoContinue=autoContinue,
                     enableMultiprocess=enableMultiprocess,
-                    multiprocessNoDebug=multiprocessNoDebug
+                    multiprocessNoDebug=multiprocessNoDebug,
+                    configOverride=configOverride
                 )
                 
                 self.lastStartAction = 2
@@ -2181,6 +2221,9 @@
             self.enableMultiprocess = enableMultiprocess
             self.setMultiprocessNoDebugHistory(multiprocessNoDebug)
             
+            # Save the global config override data
+            self.overrideGlobalConfig = copy.deepcopy(configOverride)
+            
             # Hide all error highlights
             self.viewmanager.unhighlight()
             
@@ -2207,7 +2250,8 @@
                     runInConsole=console, clientType=self.clientType,
                     enableCallTrace=enableCallTrace,
                     enableMultiprocess=enableMultiprocess,
-                    multiprocessNoDebug=multiprocessNoDebug)
+                    multiprocessNoDebug=multiprocessNoDebug,
+                    configOverride=self.overrideGlobalConfig)
                 
                 if (
                     self.debugServer.isClientProcessUp() and
@@ -2296,7 +2340,8 @@
                     clientType=self.clientType,
                     enableCallTrace=enableCallTrace,
                     enableMultiprocess=self.enableMultiprocess,
-                    multiprocessNoDebug=multiprocessNoDebug)
+                    multiprocessNoDebug=multiprocessNoDebug,
+                    configOverride=self.overrideGlobalConfig)
                 
                 # Signal that we have started a debugging session
                 self.debuggingStarted.emit(fn)
@@ -2308,7 +2353,8 @@
                     autoClearShell=self.autoClearShell,
                     forProject=forProject,
                     runInConsole=self.runInConsole,
-                    clientType=self.clientType)
+                    clientType=self.clientType,
+                    configOverride=self.overrideGlobalConfig)
             
             elif self.lastStartAction in [5, 6]:
                 # Ask the client to coverage run the new program.
@@ -2318,7 +2364,8 @@
                     erase=self.eraseCoverage,
                     forProject=forProject,
                     runInConsole=self.runInConsole,
-                    clientType=self.clientType)
+                    clientType=self.clientType,
+                    configOverride=self.overrideGlobalConfig)
             
             elif self.lastStartAction in [7, 8]:
                 # Ask the client to profile run the new program.
@@ -2328,7 +2375,8 @@
                     erase=self.eraseTimings,
                     forProject=forProject,
                     runInConsole=self.runInConsole,
-                    clientType=self.clientType)
+                    clientType=self.clientType,
+                    configOverride=self.overrideGlobalConfig)
             
             self.stopAct.setEnabled(True)
         
@@ -2564,3 +2612,14 @@
         @type bool
         """
         self.enableMultiprocess = enableMultiprocess
+    
+    def setEnableGlobalConfigOverride(self, overrideData):
+        """
+        Public method to initialize the global config override data.
+        
+        @param overrideData dictionary containing a flag indicating to enable
+            global config override and a flag indicating to redirect
+            stdin/stdout/stderr
+        @type dict
+        """
+        self.overrideGlobalConfig = copy.deepcopy(overrideData)

eric ide

mercurial