Started implementing functionality to override some global configuration per debug run.

Sun, 14 Mar 2021 19:59:27 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 14 Mar 2021 19:59:27 +0100
changeset 8162
8358c3c95841
parent 8161
3591a85e4da7
child 8163
29fb6d420a25

Started implementing functionality to override some global configuration per debug run.

eric6/Debugger/DebugUI.py file | annotate | diff | comparison | revisions
eric6/Debugger/StartCoverageDialog.ui file | annotate | diff | comparison | revisions
eric6/Debugger/StartDebugDialog.ui file | annotate | diff | comparison | revisions
eric6/Debugger/StartDialog.py file | annotate | diff | comparison | revisions
eric6/Debugger/StartProfileDialog.ui file | annotate | diff | comparison | revisions
eric6/Debugger/StartRunDialog.ui file | annotate | diff | comparison | revisions
--- a/eric6/Debugger/DebugUI.py	Sun Mar 14 13:49:55 2021 +0100
+++ b/eric6/Debugger/DebugUI.py	Sun Mar 14 19:59:27 2021 +0100
@@ -110,6 +110,12 @@
         self.multiprocessNoDebugHistory = Preferences.toList(
             Preferences.Prefs.settings.value(
                 'DebugInfo/MultiprocessNoDebugHistory'))
+        self.overrideGlobalConfig = Preferences.toBool(
+            Preferences.Prefs.settings.value(
+                'DebugInfo/OverrideGlobal', False))
+        self.redirectStdinAndStdout = Preferences.toBool(
+            Preferences.Prefs.settings.value(
+                'DebugInfo/RedirectStdinStdout', True))
         
         self.lastDebuggedFile = None
         self.lastStartAction = 0    # 0=None, 1=Script, 2=Project
@@ -1004,6 +1010,12 @@
         Preferences.Prefs.settings.setValue(
             'DebugInfo/MultiprocessNoDebugHistory',
             self.multiprocessNoDebugHistory)
+        Preferences.Prefs.settings.setValue(
+            'DebugInfo/OverrideGlobal',
+            self.overrideGlobalConfig)
+        Preferences.Prefs.settings.setValue(
+            'DebugInfo/RedirectStdinStdout',
+            self.redirectStdinAndStdout)
         
     def shutdownServer(self):
         """
@@ -1965,10 +1977,13 @@
         dlg = StartDialog(
             cap, self.lastUsedVenvName, self.argvHistory, self.wdHistory,
             self.envHistory, self.exceptions, self.ui, 1,
-            autoClearShell=self.autoClearShell)
+            autoClearShell=self.autoClearShell,
+            enableConfigOverride=self.overrideGlobalConfig,
+            enableRedirect=self.redirectStdinAndStdout)
         if dlg.exec() == QDialog.DialogCode.Accepted:
             (lastUsedVenvName, argv, wd, env, exceptions, clearShell,
              console) = dlg.getData()
+            enableConfigOverride, enableRedirect = dlg.getGlobalOverrideData()
             
             if runProject:
                 fn = self.project.getMainScript(True)
@@ -1988,6 +2003,7 @@
                     doNotStart = True
                 
                 # save the info for later use
+                # TODO: add global config override data
                 self.project.setDbgInfo(
                     lastUsedVenvName, argv, wd, env, exceptions, self.excList,
                     self.excIgnoreList, clearShell
@@ -2034,6 +2050,10 @@
             # Save the run in console flag
             self.runInConsole = console
             
+            # Save the global config override data
+            self.overrideGlobalConfig = enableConfigOverride
+            self.redirectStdinAndStdout = enableRedirect
+            
             # Hide all error highlights
             self.viewmanager.unhighlight()
             
@@ -2046,6 +2066,7 @@
                 self.debugViewer.initCallStackViewer(runProject)
                 
                 # Ask the client to open the new program.
+                # TODO: add global config override data
                 self.debugServer.remoteRun(
                     lastUsedVenvName, fn, argv, wd, env,
                     autoClearShell=self.autoClearShell, forProject=runProject,
@@ -2567,3 +2588,15 @@
         @type bool
         """
         self.enableMultiprocess = enableMultiprocess
+    
+    def setEnableGlobalConfigOverride(self, override, redirect):
+        """
+        Public method to initialize the global config override data.
+        
+        @param override flag indicating to enable global config override
+        @type bool
+        @param redirect flag indicating to redirect stdin/stdout/stderr
+        @type bool
+        """
+        self.overrideGlobalConfig = override
+        self.redirectStdinAndStdout = redirect
--- a/eric6/Debugger/StartCoverageDialog.ui	Sun Mar 14 13:49:55 2021 +0100
+++ b/eric6/Debugger/StartCoverageDialog.ui	Sun Mar 14 19:59:27 2021 +0100
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>550</width>
-    <height>228</height>
+    <height>303</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -16,7 +16,7 @@
   <property name="sizeGripEnabled">
    <bool>true</bool>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
+  <layout class="QVBoxLayout" name="verticalLayout_2">
    <item>
     <layout class="QGridLayout" name="gridLayout_3">
      <item row="2" column="0">
@@ -161,6 +161,31 @@
     </layout>
    </item>
    <item>
+    <widget class="QGroupBox" name="globalOverrideGroup">
+     <property name="title">
+      <string>Override Global Configuration</string>
+     </property>
+     <property name="checkable">
+      <bool>true</bool>
+     </property>
+     <property name="checked">
+      <bool>false</bool>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout">
+      <item>
+       <widget class="QCheckBox" name="redirectCheckBox">
+        <property name="toolTip">
+         <string>Select, to redirect stdin, stdout and stderr of the program being debugged to the eric IDE</string>
+        </property>
+        <property name="text">
+         <string>Redirect stdin/stdout/stderr</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
     <layout class="QGridLayout" name="gridLayout_2">
      <item row="0" column="0">
       <widget class="QCheckBox" name="exceptionCheckBox">
@@ -257,6 +282,8 @@
   <tabstop>cmdlineCombo</tabstop>
   <tabstop>workdirPicker</tabstop>
   <tabstop>environmentCombo</tabstop>
+  <tabstop>globalOverrideGroup</tabstop>
+  <tabstop>redirectCheckBox</tabstop>
   <tabstop>exceptionCheckBox</tabstop>
   <tabstop>clearShellCheckBox</tabstop>
   <tabstop>consoleCheckBox</tabstop>
--- a/eric6/Debugger/StartDebugDialog.ui	Sun Mar 14 13:49:55 2021 +0100
+++ b/eric6/Debugger/StartDebugDialog.ui	Sun Mar 14 19:59:27 2021 +0100
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>550</width>
-    <height>335</height>
+    <height>410</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -16,7 +16,7 @@
   <property name="sizeGripEnabled">
    <bool>true</bool>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
+  <layout class="QVBoxLayout" name="verticalLayout_2">
    <item>
     <layout class="QGridLayout" name="gridLayout_3">
      <item row="0" column="0">
@@ -158,6 +158,31 @@
     </layout>
    </item>
    <item>
+    <widget class="QGroupBox" name="globalOverrideGroup">
+     <property name="title">
+      <string>Override Global Configuration</string>
+     </property>
+     <property name="checkable">
+      <bool>true</bool>
+     </property>
+     <property name="checked">
+      <bool>false</bool>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout">
+      <item>
+       <widget class="QCheckBox" name="redirectCheckBox">
+        <property name="toolTip">
+         <string>Select, to redirect stdin, stdout and stderr of the program being debugged to the eric IDE</string>
+        </property>
+        <property name="text">
+         <string>Redirect stdin/stdout/stderr</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
     <layout class="QGridLayout" name="gridLayout">
      <item row="2" column="0">
       <widget class="QCheckBox" name="tracePythonCheckBox">
@@ -254,7 +279,7 @@
      <property name="checkable">
       <bool>true</bool>
      </property>
-     <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <layout class="QHBoxLayout" name="horizontalLayout">
       <item>
        <widget class="QLabel" name="TextLabel1_2">
         <property name="text">
@@ -322,6 +347,8 @@
   <tabstop>cmdlineCombo</tabstop>
   <tabstop>workdirPicker</tabstop>
   <tabstop>environmentCombo</tabstop>
+  <tabstop>globalOverrideGroup</tabstop>
+  <tabstop>redirectCheckBox</tabstop>
   <tabstop>exceptionCheckBox</tabstop>
   <tabstop>clearShellCheckBox</tabstop>
   <tabstop>consoleCheckBox</tabstop>
--- a/eric6/Debugger/StartDialog.py	Sun Mar 14 13:49:55 2021 +0100
+++ b/eric6/Debugger/StartDialog.py	Sun Mar 14 19:59:27 2021 +0100
@@ -30,7 +30,8 @@
                  exceptions,
                  parent=None, dialogType=0, modfuncList=None,
                  tracePython=False, autoClearShell=True, autoContinue=True,
-                 enableMultiprocess=False, multiprocessNoDebugHistory=None):
+                 enableMultiprocess=False, multiprocessNoDebugHistory=None,
+                 enableConfigOverride=False, enableRedirect=True):
         """
         Constructor
         
@@ -74,6 +75,11 @@
         @param multiprocessNoDebugHistory list of lists with programs not to be
             debugged
         @type list of str
+        @param enableConfigOverride flag indicating to enable global config
+            override
+        @type bool
+        @param enableRedirect flag indicating to redirect stdin/stdout/stderr
+        @type bool
         """
         super(StartDialog, self).__init__(parent)
         self.setModal(True)
@@ -129,6 +135,8 @@
         self.ui.consoleCheckBox.setChecked(False)
         venvIndex = max(0, self.ui.venvComboBox.findText(lastUsedVenvName))
         self.ui.venvComboBox.setCurrentIndex(venvIndex)
+        self.ui.globalOverrideGroup.setChecked(enableConfigOverride)
+        self.ui.redirectCheckBox.setChecked(enableRedirect)
         
         if dialogType == 0:        # start debug dialog
             enableMultiprocessGlobal = Preferences.getDebugger(
@@ -187,7 +195,21 @@
                 self.ui.clearShellCheckBox.isChecked(),
                 self.ui.consoleCheckBox.isChecked(),
                 )
+    
+    def getGlobalOverrideData(self):
+        """
+        Public method to retrieve the global configuration override data
+        entered into this dialog.
         
+        @return tuple containing a flag indicating to activate the global
+            override and a flag indicating a redirect of stdin/stdout/stderr
+        @rtype tuple of (bool, bool)
+        """
+        return (
+            self.ui.globalOverrideGroup.isChecked(),
+            self.ui.redirectCheckBox.isChecked(),
+        )
+    
     def getDebugData(self):
         """
         Public method to retrieve the debug related data entered into this
--- a/eric6/Debugger/StartProfileDialog.ui	Sun Mar 14 13:49:55 2021 +0100
+++ b/eric6/Debugger/StartProfileDialog.ui	Sun Mar 14 19:59:27 2021 +0100
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>550</width>
-    <height>228</height>
+    <height>303</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -16,7 +16,7 @@
   <property name="sizeGripEnabled">
    <bool>true</bool>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
+  <layout class="QVBoxLayout" name="verticalLayout_2">
    <item>
     <layout class="QGridLayout" name="gridLayout_3">
      <item row="0" column="0">
@@ -158,6 +158,31 @@
     </layout>
    </item>
    <item>
+    <widget class="QGroupBox" name="globalOverrideGroup">
+     <property name="title">
+      <string>Override Global Configuration</string>
+     </property>
+     <property name="checkable">
+      <bool>true</bool>
+     </property>
+     <property name="checked">
+      <bool>false</bool>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout">
+      <item>
+       <widget class="QCheckBox" name="redirectCheckBox">
+        <property name="toolTip">
+         <string>Select, to redirect stdin, stdout and stderr of the program being debugged to the eric IDE</string>
+        </property>
+        <property name="text">
+         <string>Redirect stdin/stdout/stderr</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
     <layout class="QGridLayout" name="gridLayout_2">
      <item row="0" column="0">
       <widget class="QCheckBox" name="exceptionCheckBox">
@@ -254,6 +279,8 @@
   <tabstop>cmdlineCombo</tabstop>
   <tabstop>workdirPicker</tabstop>
   <tabstop>environmentCombo</tabstop>
+  <tabstop>globalOverrideGroup</tabstop>
+  <tabstop>redirectCheckBox</tabstop>
   <tabstop>exceptionCheckBox</tabstop>
   <tabstop>clearShellCheckBox</tabstop>
   <tabstop>consoleCheckBox</tabstop>
--- a/eric6/Debugger/StartRunDialog.ui	Sun Mar 14 13:49:55 2021 +0100
+++ b/eric6/Debugger/StartRunDialog.ui	Sun Mar 14 19:59:27 2021 +0100
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>550</width>
-    <height>228</height>
+    <height>303</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -16,7 +16,7 @@
   <property name="sizeGripEnabled">
    <bool>true</bool>
   </property>
-  <layout class="QVBoxLayout" name="verticalLayout">
+  <layout class="QVBoxLayout" name="verticalLayout_2">
    <item>
     <layout class="QGridLayout" name="gridLayout_2">
      <item row="0" column="0">
@@ -158,6 +158,31 @@
     </layout>
    </item>
    <item>
+    <widget class="QGroupBox" name="globalOverrideGroup">
+     <property name="title">
+      <string>Override Global Configuration</string>
+     </property>
+     <property name="checkable">
+      <bool>true</bool>
+     </property>
+     <property name="checked">
+      <bool>false</bool>
+     </property>
+     <layout class="QVBoxLayout" name="verticalLayout">
+      <item>
+       <widget class="QCheckBox" name="redirectCheckBox">
+        <property name="toolTip">
+         <string>Select, to redirect stdin, stdout and stderr of the program being debugged to the eric IDE</string>
+        </property>
+        <property name="text">
+         <string>Redirect stdin/stdout/stderr</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
     <layout class="QGridLayout" name="gridLayout">
      <item row="0" column="0">
       <widget class="QCheckBox" name="exceptionCheckBox">
@@ -237,6 +262,8 @@
   <tabstop>cmdlineCombo</tabstop>
   <tabstop>workdirPicker</tabstop>
   <tabstop>environmentCombo</tabstop>
+  <tabstop>globalOverrideGroup</tabstop>
+  <tabstop>redirectCheckBox</tabstop>
   <tabstop>exceptionCheckBox</tabstop>
   <tabstop>clearShellCheckBox</tabstop>
   <tabstop>consoleCheckBox</tabstop>

eric ide

mercurial