Debugger/DebugUI.py

changeset 6352
4bdc6503df81
parent 6241
77534fdf0a80
child 6376
201067699041
--- a/Debugger/DebugUI.py	Sun Jun 17 13:09:00 2018 +0200
+++ b/Debugger/DebugUI.py	Sun Jun 17 16:56:10 2018 +0200
@@ -80,8 +80,8 @@
         self.editorOpen = False
         
         # read the saved debug info values
-        self.interpreterHistory = Preferences.toList(
-            Preferences.Prefs.settings.value('DebugInfo/InterpreterHistory'))
+        self.lastUsedVenvName = Preferences.Prefs.settings.value(
+            'DebugInfo/VirtualEnvironment', '')
         self.argvHistory = Preferences.toList(
             Preferences.Prefs.settings.value('DebugInfo/ArgumentsHistory'))
         self.wdHistory = Preferences.toList(
@@ -675,25 +675,6 @@
         
         return [starttb, debugtb]
 
-    def setInterpreterHistory(self, interpreterStr, clearHistories=False,
-                              history=None):
-        """
-        Public slot to initialize the interpreter history.
-        
-        @param interpreterStr interpreter (string)
-        @param clearHistories flag indicating, that the list should
-            be cleared (boolean)
-        @param history list of history entries to be set (list of strings)
-        """
-        if clearHistories:
-            del self.interpreterHistory[1:]
-        elif history is not None:
-            self.interpreterHistory = history[:]
-        else:
-            if interpreterStr in self.interpreterHistory:
-                self.interpreterHistory.remove(interpreterStr)
-            self.interpreterHistory.insert(0, interpreterStr)
-    
     def setArgvHistory(self, argsStr, clearHistories=False, history=None):
         """
         Public slot to initialize the argv history.
@@ -934,14 +915,11 @@
         """
         Public method to clear the various debug histories.
         """
-        self.interpreterHistory = []
         self.argvHistory = []
         self.wdHistory = []
         self.envHistory = []
         
         Preferences.Prefs.settings.setValue(
-            'DebugInfo/InterpreterHistory', self.interpreterHistory)
-        Preferences.Prefs.settings.setValue(
             'DebugInfo/ArgumentsHistory', self.argvHistory)
         Preferences.Prefs.settings.setValue(
             'DebugInfo/WorkingDirectoryHistory', self.wdHistory)
@@ -953,13 +931,12 @@
         Public method to perform shutdown actions.
         """
         # Just save the 10 most recent entries
-        del self.interpreterHistory[10:]
         del self.argvHistory[10:]
         del self.wdHistory[10:]
         del self.envHistory[10:]
         
         Preferences.Prefs.settings.setValue(
-            'DebugInfo/InterpreterHistory', self.interpreterHistory)
+            'DebugInfo/VirtualEnvironment', self.lastUsedVenvName)
         Preferences.Prefs.settings.setValue(
             'DebugInfo/ArgumentsHistory', self.argvHistory)
         Preferences.Prefs.settings.setValue(
@@ -1579,12 +1556,12 @@
         else:
             cap = self.tr("Coverage of Script")
         dlg = StartDialog(
-            cap, self.interpreterHistory, self.argvHistory, self.wdHistory,
+            cap, self.lastUsedVenvName, self.argvHistory, self.wdHistory,
             self.envHistory, self.exceptions, self.ui, 2,
             autoClearShell=self.autoClearShell)
         if dlg.exec_() == QDialog.Accepted:
-            interpreter, argv, wd, env, exceptions, clearShell, console = \
-                dlg.getData()
+            (lastUsedVenvName, argv, wd, env, exceptions, clearShell,
+             console) = dlg.getData()
             eraseCoverage = dlg.getCoverageData()
             
             if runProject:
@@ -1604,7 +1581,7 @@
                 
                 # save the info for later use
                 self.project.setDbgInfo(
-                    interpreter, argv, wd, env, exceptions, self.excList,
+                    lastUsedVenvName, argv, wd, env, exceptions, self.excList,
                     self.excIgnoreList, clearShell)
                 
                 self.lastStartAction = 6
@@ -1628,9 +1605,11 @@
             self.lastDebuggedFile = fn
             self.restartAct.setEnabled(True)
             
+            # save the most recently used virtual environment
+            self.lastUsedVenvName = lastUsedVenvName
+            
             # This moves any previous occurrence of these arguments to the head
             # of the list.
-            self.setInterpreterHistory(interpreter)
             self.setArgvHistory(argv)
             self.setWdHistory(wd)
             self.setEnvHistory(env)
@@ -1660,7 +1639,7 @@
                 
                 # Ask the client to open the new program.
                 self.debugServer.remoteCoverage(
-                    interpreter, fn, argv, wd, env,
+                    lastUsedVenvName, fn, argv, wd, env,
                     autoClearShell=self.autoClearShell, erase=eraseCoverage,
                     forProject=runProject, runInConsole=console,
                     clientType=self.clientType)
@@ -1668,14 +1647,11 @@
                 self.stopAct.setEnabled(True)
         
         if dlg.clearHistories():
-            self.setInterpreterHistory("", clearHistories=True)
             self.setArgvHistory("", clearHistories=True)
             self.setWdHistory("", clearHistories=True)
             self.setEnvHistory("", clearHistories=True)
         elif dlg.historiesModified():
-            argvHistory, wdHistory, envHistory, interpreterHistory = \
-                dlg.getHistories()
-            self.setInterpreterHistory("", history=interpreterHistory)
+            argvHistory, wdHistory, envHistory = dlg.getHistories()
             self.setArgvHistory("", history=argvHistory)
             self.setWdHistory("", history=wdHistory)
             self.setEnvHistory("", history=envHistory)
@@ -1712,12 +1688,12 @@
         else:
             cap = self.tr("Profile of Script")
         dlg = StartDialog(
-            cap, self.interpreterHistory, self.argvHistory, self.wdHistory,
+            cap, self.lastUsedVenvName, self.argvHistory, self.wdHistory,
             self.envHistory, self.exceptions, self.ui, 3,
             autoClearShell=self.autoClearShell)
         if dlg.exec_() == QDialog.Accepted:
-            interpreter, argv, wd, env, exceptions, clearShell, console = \
-                dlg.getData()
+            (lastUsedVenvName, argv, wd, env, exceptions, clearShell,
+             console) = dlg.getData()
             eraseTimings = dlg.getProfilingData()
             
             if runProject:
@@ -1737,7 +1713,7 @@
                 
                 # save the info for later use
                 self.project.setDbgInfo(
-                    interpreter, argv, wd, env, exceptions, self.excList,
+                    lastUsedVenvName, argv, wd, env, exceptions, self.excList,
                     self.excIgnoreList, clearShell)
                 
                 self.lastStartAction = 8
@@ -1761,9 +1737,11 @@
             self.lastDebuggedFile = fn
             self.restartAct.setEnabled(True)
             
+            # save the most recently used virtual environment
+            self.lastUsedVenvName = lastUsedVenvName
+            
             # This moves any previous occurrence of these arguments to the head
             # of the list.
-            self.setInterpreterHistory(interpreter)
             self.setArgvHistory(argv)
             self.setWdHistory(wd)
             self.setEnvHistory(env)
@@ -1793,7 +1771,7 @@
                 
                 # Ask the client to open the new program.
                 self.debugServer.remoteProfile(
-                    interpreter, fn, argv, wd, env,
+                    lastUsedVenvName, fn, argv, wd, env,
                     autoClearShell=self.autoClearShell, erase=eraseTimings,
                     forProject=runProject, runInConsole=console,
                     clientType=self.clientType)
@@ -1801,14 +1779,11 @@
                 self.stopAct.setEnabled(True)
         
         if dlg.clearHistories():
-            self.setInterpreterHistory("", clearHistories=True)
             self.setArgvHistory("", clearHistories=True)
             self.setWdHistory("", clearHistories=True)
             self.setEnvHistory("", clearHistories=True)
         elif dlg.historiesModified():
-            argvHistory, wdHistory, envHistory, interpreterHistory = \
-                dlg.getHistories()
-            self.setInterpreterHistory("", history=interpreterHistory)
+            argvHistory, wdHistory, envHistory = dlg.getHistories()
             self.setArgvHistory("", history=argvHistory)
             self.setWdHistory("", history=wdHistory)
             self.setEnvHistory("", history=envHistory)
@@ -1845,14 +1820,14 @@
         else:
             cap = self.tr("Run Script")
         dlg = StartDialog(
-            cap, self.interpreterHistory, self.argvHistory, self.wdHistory,
+            cap, self.lastUsedVenvName, self.argvHistory, self.wdHistory,
             self.envHistory, self.exceptions, self.ui, 1,
             autoClearShell=self.autoClearShell,
             autoFork=self.forkAutomatically,
             forkChild=self.forkIntoChild)
         if dlg.exec_() == QDialog.Accepted:
-            interpreter, argv, wd, env, exceptions, clearShell, console = \
-                dlg.getData()
+            (lastUsedVenvName, argv, wd, env, exceptions, clearShell,
+             console) = dlg.getData()
             forkAutomatically, forkIntoChild = dlg.getRunData()
             
             if runProject:
@@ -1872,7 +1847,7 @@
                 
                 # save the info for later use
                 self.project.setDbgInfo(
-                    interpreter, argv, wd, env, exceptions, self.excList,
+                    lastUsedVenvName, argv, wd, env, exceptions, self.excList,
                     self.excIgnoreList, clearShell)
                 
                 self.lastStartAction = 4
@@ -1896,9 +1871,11 @@
             self.lastDebuggedFile = fn
             self.restartAct.setEnabled(True)
             
+            # save the most recently used virtual environment
+            self.lastUsedVenvName = lastUsedVenvName
+            
             # This moves any previous occurrence of these arguments to the head
             # of the list.
-            self.setInterpreterHistory(interpreter)
             self.setArgvHistory(argv)
             self.setWdHistory(wd)
             self.setEnvHistory(env)
@@ -1929,7 +1906,7 @@
                 
                 # Ask the client to open the new program.
                 self.debugServer.remoteRun(
-                    interpreter, fn, argv, wd, env,
+                    lastUsedVenvName, fn, argv, wd, env,
                     autoClearShell=self.autoClearShell, forProject=runProject,
                     runInConsole=console, autoFork=forkAutomatically,
                     forkChild=forkIntoChild, clientType=self.clientType)
@@ -1937,14 +1914,11 @@
                 self.stopAct.setEnabled(True)
         
         if dlg.clearHistories():
-            self.setInterpreterHistory("", clearHistories=True)
             self.setArgvHistory("", clearHistories=True)
             self.setWdHistory("", clearHistories=True)
             self.setEnvHistory("", clearHistories=True)
         elif dlg.historiesModified():
-            argvHistory, wdHistory, envHistory, interpreterHistory = \
-                dlg.getHistories()
-            self.setInterpreterHistory("", history=interpreterHistory)
+            argvHistory, wdHistory, envHistory = dlg.getHistories()
             self.setArgvHistory("", history=argvHistory)
             self.setWdHistory("", history=wdHistory)
             self.setEnvHistory("", history=envHistory)
@@ -1981,14 +1955,14 @@
         else:
             cap = self.tr("Debug Script")
         dlg = StartDialog(
-            cap, self.interpreterHistory, self.argvHistory, self.wdHistory,
+            cap, self.lastUsedVenvName, self.argvHistory, self.wdHistory,
             self.envHistory, self.exceptions, self.ui, 0,
             tracePython=self.tracePython, autoClearShell=self.autoClearShell,
             autoContinue=self.autoContinue, autoFork=self.forkAutomatically,
             forkChild=self.forkIntoChild)
         if dlg.exec_() == QDialog.Accepted:
-            interpreter, argv, wd, env, exceptions, clearShell, console = \
-                dlg.getData()
+            (lastUsedVenvName, argv, wd, env, exceptions, clearShell,
+             console) = dlg.getData()
             tracePython, autoContinue, forkAutomatically, forkIntoChild = \
                 dlg.getDebugData()
             
@@ -2009,7 +1983,7 @@
                 
                 # save the info for later use
                 self.project.setDbgInfo(
-                    interpreter, argv, wd, env, exceptions, self.excList,
+                    lastUsedVenvName, argv, wd, env, exceptions, self.excList,
                     self.excIgnoreList, clearShell, tracePython=tracePython,
                     autoContinue=self.autoContinue)
                 
@@ -2034,9 +2008,11 @@
             self.lastDebuggedFile = fn
             self.restartAct.setEnabled(True)
             
+            # save the most recently used virtual environment
+            self.lastUsedVenvName = lastUsedVenvName
+            
             # This moves any previous occurrence of these arguments to the head
             # of the list.
-            self.setInterpreterHistory(interpreter)
             self.setArgvHistory(argv)
             self.setWdHistory(wd)
             self.setEnvHistory(env)
@@ -2079,7 +2055,7 @@
                 
                 # Ask the client to open the new program.
                 self.debugServer.remoteLoad(
-                    interpreter, fn, argv, wd, env,
+                    lastUsedVenvName, fn, argv, wd, env,
                     autoClearShell=self.autoClearShell,
                     tracePython=tracePython,
                     autoContinue=autoContinue, forProject=debugProject,
@@ -2093,14 +2069,11 @@
                 self.stopAct.setEnabled(True)
         
         if dlg.clearHistories():
-            self.setInterpreterHistory("", clearHistories=True)
             self.setArgvHistory("", clearHistories=True)
             self.setWdHistory("", clearHistories=True)
             self.setEnvHistory("", clearHistories=True)
         elif dlg.historiesModified():
-            argvHistory, wdHistory, envHistory, interpreterHistory = \
-                dlg.getHistories()
-            self.setInterpreterHistory("", history=interpreterHistory)
+            argvHistory, wdHistory, envHistory = dlg.getHistories()
             self.setArgvHistory("", history=argvHistory)
             self.setWdHistory("", history=wdHistory)
             self.setEnvHistory("", history=envHistory)
@@ -2131,7 +2104,7 @@
             return      # should not happen
                     
         # get the saved stuff
-        interpreter = self.interpreterHistory[0]
+        venvName = self.lastUsedVenvName
         wd = self.wdHistory[0]
         argv = self.argvHistory[0]
         fn = self.lastDebuggedFile
@@ -2156,7 +2129,7 @@
                 
                 # Ask the client to debug the new program.
                 self.debugServer.remoteLoad(
-                    interpreter, fn, argv, wd, env,
+                    venvName, fn, argv, wd, env,
                     autoClearShell=self.autoClearShell,
                     tracePython=self.tracePython,
                     autoContinue=self.autoContinue,
@@ -2173,7 +2146,7 @@
             elif self.lastStartAction in [3, 4]:
                 # Ask the client to run the new program.
                 self.debugServer.remoteRun(
-                    interpreter, fn, argv, wd, env,
+                    venvName, fn, argv, wd, env,
                     autoClearShell=self.autoClearShell,
                     forProject=forProject,
                     runInConsole=self.runInConsole,
@@ -2184,7 +2157,7 @@
             elif self.lastStartAction in [5, 6]:
                 # Ask the client to coverage run the new program.
                 self.debugServer.remoteCoverage(
-                    interpreter, fn, argv, wd, env,
+                    venvName, fn, argv, wd, env,
                     autoClearShell=self.autoClearShell,
                     erase=self.eraseCoverage,
                     forProject=forProject,
@@ -2194,7 +2167,7 @@
             elif self.lastStartAction in [7, 8]:
                 # Ask the client to profile run the new program.
                 self.debugServer.remoteProfile(
-                    interpreter, fn, argv, wd, env,
+                    venvName, fn, argv, wd, env,
                     autoClearShell=self.autoClearShell,
                     erase=self.eraseTimings,
                     forProject=forProject,

eric ide

mercurial