Finished to change the file browser model such, that the sys.path entry is dependent on the running interpreter.

Wed, 12 Mar 2014 18:44:34 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 12 Mar 2014 18:44:34 +0100
changeset 3358
57af7e9fda48
parent 3357
2390df6f42ba
child 3359
6b6c224d67d6

Finished to change the file browser model such, that the sys.path entry is dependent on the running interpreter.

APIs/Python3/eric5.api file | annotate | diff | comparison | revisions
Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Debugger.DebugServer.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Debugger.DebuggerInterfaceNone.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Debugger.DebuggerInterfacePython.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Debugger.DebuggerInterfacePython3.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Debugger.DebuggerInterfaceRuby.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.UI.Browser.html file | annotate | diff | comparison | revisions
Documentation/Source/eric5.UI.BrowserModel.html file | annotate | diff | comparison | revisions
UI/BrowserModel.py file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric5.api	Tue Mar 11 20:07:05 2014 +0100
+++ b/APIs/Python3/eric5.api	Wed Mar 12 18:44:34 2014 +0100
@@ -675,6 +675,7 @@
 eric5.Debugger.DebugServer.DebugServer.clientException?7
 eric5.Debugger.DebugServer.DebugServer.clientExit?7
 eric5.Debugger.DebugServer.DebugServer.clientGone?7
+eric5.Debugger.DebugServer.DebugServer.clientInterpreterChanged?7
 eric5.Debugger.DebugServer.DebugServer.clientLine?7
 eric5.Debugger.DebugServer.DebugServer.clientOutput?7
 eric5.Debugger.DebugServer.DebugServer.clientProcessStderr?7
@@ -700,6 +701,7 @@
 eric5.Debugger.DebugServer.DebugServer.clientWatchConditionError?7
 eric5.Debugger.DebugServer.DebugServer.getBreakPointModel?4()
 eric5.Debugger.DebugServer.DebugServer.getClientCapabilities?4(type)
+eric5.Debugger.DebugServer.DebugServer.getClientInterpreter?4()
 eric5.Debugger.DebugServer.DebugServer.getExtensions?4(language)
 eric5.Debugger.DebugServer.DebugServer.getHostAddress?4(localhost)
 eric5.Debugger.DebugServer.DebugServer.getSupportedLanguages?4(shellOnly=False)
@@ -7813,6 +7815,7 @@
 eric5.UI.Browser.Browser.getSelectedItems?4(filter=None)
 eric5.UI.Browser.Browser.getSelectedItemsCount?4(filter=None)
 eric5.UI.Browser.Browser.getSelectedItemsCountCategorized?4(filter=None)
+eric5.UI.Browser.Browser.handleInterpreterChanged?4(interpreter)
 eric5.UI.Browser.Browser.handlePreferencesChanged?4()
 eric5.UI.Browser.Browser.handleProgramChange?4(fn)
 eric5.UI.Browser.Browser.handleUnittest?4()
@@ -7923,6 +7926,7 @@
 eric5.UI.BrowserModel.BrowserModel.hasChildren?4(parent=QModelIndex())
 eric5.UI.BrowserModel.BrowserModel.headerData?4(section, orientation, role=Qt.DisplayRole)
 eric5.UI.BrowserModel.BrowserModel.index?4(row, column, parent=QModelIndex())
+eric5.UI.BrowserModel.BrowserModel.interpreterChanged?4(interpreter)
 eric5.UI.BrowserModel.BrowserModel.item?4(index)
 eric5.UI.BrowserModel.BrowserModel.parent?4(index)
 eric5.UI.BrowserModel.BrowserModel.populateClassAttributesItem?4(parentItem, repopulate=False)
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Help/source.qhp	Tue Mar 11 20:07:05 2014 +0100
+++ b/Documentation/Help/source.qhp	Wed Mar 12 18:44:34 2014 +0100
@@ -1796,6 +1796,7 @@
       <keyword name="Browser.getSelectedItems" id="Browser.getSelectedItems" ref="eric5.UI.Browser.html#Browser.getSelectedItems" />
       <keyword name="Browser.getSelectedItemsCount" id="Browser.getSelectedItemsCount" ref="eric5.UI.Browser.html#Browser.getSelectedItemsCount" />
       <keyword name="Browser.getSelectedItemsCountCategorized" id="Browser.getSelectedItemsCountCategorized" ref="eric5.UI.Browser.html#Browser.getSelectedItemsCountCategorized" />
+      <keyword name="Browser.handleInterpreterChanged" id="Browser.handleInterpreterChanged" ref="eric5.UI.Browser.html#Browser.handleInterpreterChanged" />
       <keyword name="Browser.handlePreferencesChanged" id="Browser.handlePreferencesChanged" ref="eric5.UI.Browser.html#Browser.handlePreferencesChanged" />
       <keyword name="Browser.handleProgramChange" id="Browser.handleProgramChange" ref="eric5.UI.Browser.html#Browser.handleProgramChange" />
       <keyword name="Browser.handleUnittest" id="Browser.handleUnittest" ref="eric5.UI.Browser.html#Browser.handleUnittest" />
@@ -1899,6 +1900,7 @@
       <keyword name="BrowserModel.hasChildren" id="BrowserModel.hasChildren" ref="eric5.UI.BrowserModel.html#BrowserModel.hasChildren" />
       <keyword name="BrowserModel.headerData" id="BrowserModel.headerData" ref="eric5.UI.BrowserModel.html#BrowserModel.headerData" />
       <keyword name="BrowserModel.index" id="BrowserModel.index" ref="eric5.UI.BrowserModel.html#BrowserModel.index" />
+      <keyword name="BrowserModel.interpreterChanged" id="BrowserModel.interpreterChanged" ref="eric5.UI.BrowserModel.html#BrowserModel.interpreterChanged" />
       <keyword name="BrowserModel.item" id="BrowserModel.item" ref="eric5.UI.BrowserModel.html#BrowserModel.item" />
       <keyword name="BrowserModel.parent" id="BrowserModel.parent" ref="eric5.UI.BrowserModel.html#BrowserModel.parent" />
       <keyword name="BrowserModel.populateClassAttributesItem" id="BrowserModel.populateClassAttributesItem" ref="eric5.UI.BrowserModel.html#BrowserModel.populateClassAttributesItem" />
@@ -3020,6 +3022,7 @@
       <keyword name="DebugServer.clientUtTestSucceededUnexpected" id="DebugServer.clientUtTestSucceededUnexpected" ref="eric5.Debugger.DebugServer.html#DebugServer.clientUtTestSucceededUnexpected" />
       <keyword name="DebugServer.getBreakPointModel" id="DebugServer.getBreakPointModel" ref="eric5.Debugger.DebugServer.html#DebugServer.getBreakPointModel" />
       <keyword name="DebugServer.getClientCapabilities" id="DebugServer.getClientCapabilities" ref="eric5.Debugger.DebugServer.html#DebugServer.getClientCapabilities" />
+      <keyword name="DebugServer.getClientInterpreter" id="DebugServer.getClientInterpreter" ref="eric5.Debugger.DebugServer.html#DebugServer.getClientInterpreter" />
       <keyword name="DebugServer.getExtensions" id="DebugServer.getExtensions" ref="eric5.Debugger.DebugServer.html#DebugServer.getExtensions" />
       <keyword name="DebugServer.getHostAddress" id="DebugServer.getHostAddress" ref="eric5.Debugger.DebugServer.html#DebugServer.getHostAddress" />
       <keyword name="DebugServer.getSupportedLanguages" id="DebugServer.getSupportedLanguages" ref="eric5.Debugger.DebugServer.html#DebugServer.getSupportedLanguages" />
--- a/Documentation/Source/eric5.Debugger.DebugServer.html	Tue Mar 11 20:07:05 2014 +0100
+++ b/Documentation/Source/eric5.Debugger.DebugServer.html	Wed Mar 12 18:44:34 2014 +0100
@@ -86,6 +86,10 @@
 <dd>
 emitted if the client went away (planned or
         unplanned)
+</dd><dt>clientInterpreterChanged(str)</dt>
+<dd>
+emitted to signal a change of the
+        client interpreter
 </dd><dt>clientLine(filename, lineno, forStack)</dt>
 <dd>
 emitted after the
@@ -313,6 +317,9 @@
 <td><a href="#DebugServer.getClientCapabilities">getClientCapabilities</a></td>
 <td>Public method to retrieve the debug clients capabilities.</td>
 </tr><tr>
+<td><a href="#DebugServer.getClientInterpreter">getClientInterpreter</a></td>
+<td>Public method to get the interpreter of the debug client.</td>
+</tr><tr>
 <td><a href="#DebugServer.getExtensions">getExtensions</a></td>
 <td>Public slot to get the extensions associated with the given language.</td>
 </tr><tr>
@@ -956,6 +963,16 @@
 <dd>
 debug client capabilities (integer)
 </dd>
+</dl><a NAME="DebugServer.getClientInterpreter" ID="DebugServer.getClientInterpreter"></a>
+<h4>DebugServer.getClientInterpreter</h4>
+<b>getClientInterpreter</b>(<i></i>)
+<p>
+        Public method to get the interpreter of the debug client.
+</p><dl>
+<dt>Returns:</dt>
+<dd>
+interpreter of the debug client (string)
+</dd>
 </dl><a NAME="DebugServer.getExtensions" ID="DebugServer.getExtensions"></a>
 <h4>DebugServer.getExtensions</h4>
 <b>getExtensions</b>(<i>language</i>)
--- a/Documentation/Source/eric5.Debugger.DebuggerInterfaceNone.html	Tue Mar 11 20:07:05 2014 +0100
+++ b/Documentation/Source/eric5.Debugger.DebuggerInterfaceNone.html	Wed Mar 12 18:44:34 2014 +0100
@@ -676,8 +676,9 @@
 </dl><dl>
 <dt>Returns:</dt>
 <dd>
-client process object (QProcess) and a flag to indicate
-            a network connection (boolean)
+client process object (QProcess), a flag to indicate
+            a network connection (boolean) and the name of the interpreter
+            in case of a local execution (string)
 </dd>
 </dl><a NAME="DebuggerInterfaceNone.startRemoteForProject" ID="DebuggerInterfaceNone.startRemoteForProject"></a>
 <h4>DebuggerInterfaceNone.startRemoteForProject</h4>
@@ -696,8 +697,9 @@
 </dl><dl>
 <dt>Returns:</dt>
 <dd>
-client process object (QProcess) and a flag to indicate
-            a network connection (boolean)
+client process object (QProcess), a flag to indicate
+            a network connection (boolean) and the name of the interpreter
+            in case of a local execution (string)
 </dd>
 </dl>
 <div align="right"><a href="#top">Up</a></div>
--- a/Documentation/Source/eric5.Debugger.DebuggerInterfacePython.html	Tue Mar 11 20:07:05 2014 +0100
+++ b/Documentation/Source/eric5.Debugger.DebuggerInterfacePython.html	Wed Mar 12 18:44:34 2014 +0100
@@ -774,8 +774,9 @@
 </dl><dl>
 <dt>Returns:</dt>
 <dd>
-client process object (QProcess) and a flag to indicate
-            a network connection (boolean)
+client process object (QProcess), a flag to indicate
+            a network connection (boolean) and the name of the interpreter
+            in case of a local execution (string)
 </dd>
 </dl><a NAME="DebuggerInterfacePython.startRemoteForProject" ID="DebuggerInterfacePython.startRemoteForProject"></a>
 <h4>DebuggerInterfacePython.startRemoteForProject</h4>
@@ -794,8 +795,9 @@
 </dl><dl>
 <dt>Returns:</dt>
 <dd>
-client process object (QProcess) and a flag to indicate
-            a network connection (boolean)
+client process object (QProcess), a flag to indicate
+            a network connection (boolean) and the name of the interpreter
+            in case of a local execution (string)
 </dd>
 </dl>
 <div align="right"><a href="#top">Up</a></div>
--- a/Documentation/Source/eric5.Debugger.DebuggerInterfacePython3.html	Tue Mar 11 20:07:05 2014 +0100
+++ b/Documentation/Source/eric5.Debugger.DebuggerInterfacePython3.html	Wed Mar 12 18:44:34 2014 +0100
@@ -774,8 +774,9 @@
 </dl><dl>
 <dt>Returns:</dt>
 <dd>
-client process object (QProcess) and a flag to indicate
-            a network connection (boolean)
+client process object (QProcess), a flag to indicate
+            a network connection (boolean) and the name of the interpreter
+            in case of a local execution (string)
 </dd>
 </dl><a NAME="DebuggerInterfacePython3.startRemoteForProject" ID="DebuggerInterfacePython3.startRemoteForProject"></a>
 <h4>DebuggerInterfacePython3.startRemoteForProject</h4>
@@ -794,8 +795,9 @@
 </dl><dl>
 <dt>Returns:</dt>
 <dd>
-client process object (QProcess) and a flag to indicate
-            a network connection (boolean)
+client process object (QProcess), a flag to indicate
+            a network connection (boolean) and the name of the interpreter
+            in case of a local execution (string)
 </dd>
 </dl>
 <div align="right"><a href="#top">Up</a></div>
--- a/Documentation/Source/eric5.Debugger.DebuggerInterfaceRuby.html	Tue Mar 11 20:07:05 2014 +0100
+++ b/Documentation/Source/eric5.Debugger.DebuggerInterfaceRuby.html	Wed Mar 12 18:44:34 2014 +0100
@@ -798,8 +798,9 @@
 </dl><dl>
 <dt>Returns:</dt>
 <dd>
-client process object (QProcess) and a flag to indicate
-            a network connection (boolean)
+client process object (QProcess), a flag to indicate
+            a network connection (boolean) and the name of the interpreter
+            in case of a local execution (string)
 </dd>
 </dl><a NAME="DebuggerInterfaceRuby.startRemoteForProject" ID="DebuggerInterfaceRuby.startRemoteForProject"></a>
 <h4>DebuggerInterfaceRuby.startRemoteForProject</h4>
@@ -818,8 +819,9 @@
 </dl><dl>
 <dt>Returns:</dt>
 <dd>
-pid of the client process (integer) and a flag to indicate
-            a network connection (boolean)
+client process object (QProcess), a flag to indicate
+            a network connection (boolean) and the name of the interpreter
+            in case of a local execution (string)
 </dd>
 </dl>
 <div align="right"><a href="#top">Up</a></div>
--- a/Documentation/Source/eric5.UI.Browser.html	Tue Mar 11 20:07:05 2014 +0100
+++ b/Documentation/Source/eric5.UI.Browser.html	Wed Mar 12 18:44:34 2014 +0100
@@ -159,6 +159,9 @@
 <td><a href="#Browser.getSelectedItemsCountCategorized">getSelectedItemsCountCategorized</a></td>
 <td>Public method to get a categorized count of selected items.</td>
 </tr><tr>
+<td><a href="#Browser.handleInterpreterChanged">handleInterpreterChanged</a></td>
+<td>Public slot to handle a change of the debug client's interpreter.</td>
+</tr><tr>
 <td><a href="#Browser.handlePreferencesChanged">handlePreferencesChanged</a></td>
 <td>Public slot used to handle the preferencesChanged signal.</td>
 </tr><tr>
@@ -346,6 +349,16 @@
             an additional entry with key "sum", that stores the sum of
             all selected entries fulfilling the filter criteria.
 </dd>
+</dl><a NAME="Browser.handleInterpreterChanged" ID="Browser.handleInterpreterChanged"></a>
+<h4>Browser.handleInterpreterChanged</h4>
+<b>handleInterpreterChanged</b>(<i>interpreter</i>)
+<p>
+        Public slot to handle a change of the debug client's interpreter.
+</p><dl>
+<dt><i>interpreter</i></dt>
+<dd>
+interpreter of the debug client (string)
+</dd>
 </dl><a NAME="Browser.handlePreferencesChanged" ID="Browser.handlePreferencesChanged"></a>
 <h4>Browser.handlePreferencesChanged</h4>
 <b>handlePreferencesChanged</b>(<i></i>)
--- a/Documentation/Source/eric5.UI.BrowserModel.html	Tue Mar 11 20:07:05 2014 +0100
+++ b/Documentation/Source/eric5.UI.BrowserModel.html	Wed Mar 12 18:44:34 2014 +0100
@@ -1407,6 +1407,9 @@
 <td><a href="#BrowserModel.index">index</a></td>
 <td>Public method to create an index.</td>
 </tr><tr>
+<td><a href="#BrowserModel.interpreterChanged">interpreterChanged</a></td>
+<td>Public method to handle a change of the debug client's interpreter.</td>
+</tr><tr>
 <td><a href="#BrowserModel.item">item</a></td>
 <td>Public method to get a reference to an item.</td>
 </tr><tr>
@@ -1649,6 +1652,16 @@
 <dd>
 index object (QModelIndex)
 </dd>
+</dl><a NAME="BrowserModel.interpreterChanged" ID="BrowserModel.interpreterChanged"></a>
+<h4>BrowserModel.interpreterChanged</h4>
+<b>interpreterChanged</b>(<i>interpreter</i>)
+<p>
+        Public method to handle a change of the debug client's interpreter.
+</p><dl>
+<dt><i>interpreter</i></dt>
+<dd>
+interpreter of the debug client (string)
+</dd>
 </dl><a NAME="BrowserModel.item" ID="BrowserModel.item"></a>
 <h4>BrowserModel.item</h4>
 <b>item</b>(<i>index</i>)
--- a/UI/BrowserModel.py	Tue Mar 11 20:07:05 2014 +0100
+++ b/UI/BrowserModel.py	Wed Mar 12 18:44:34 2014 +0100
@@ -7,12 +7,12 @@
 Module implementing the browser model.
 """
 
-import sys
 import os
 import fnmatch
+import json
 
 from PyQt4.QtCore import QDir, QModelIndex, QAbstractItemModel, \
-    QFileSystemWatcher, Qt
+    QFileSystemWatcher, Qt, QProcess
 from PyQt4.QtGui import QImageReader, QApplication, QFont
 
 import UI.PixmapCache
@@ -558,18 +558,31 @@
         @param parentItem reference to the sys.path item to be populated
         @param repopulate flag indicating a repopulation (boolean)
         """
-        # TODO: make this dynamic depending on interpreter
-        if len(sys.path) > 0:
-            if repopulate:
-                self.beginInsertRows(
-                    self.createIndex(parentItem.row(), 0, parentItem),
-                    0, len(sys.path) - 1)
-            for p in sys.path:
-                if p:
-                    node = BrowserDirectoryItem(parentItem, p)
-                    self._addItem(node, parentItem)
-            if repopulate:
-                self.endInsertRows()
+        if self.__sysPathInterpreter:
+            script = "import sys, json; print(json.dumps(sys.path))"
+            proc = QProcess()
+            proc.start(self.__sysPathInterpreter, ["-c", script])
+            finished = proc.waitForFinished(3000)
+            if finished:
+                procOutput = str(proc.readAllStandardOutput(),
+                                 Preferences.getSystem("IOEncoding"),
+                                 'replace')
+                syspath = [p for p in json.loads(procOutput) if p]
+                if len(syspath) > 0:
+                    if repopulate:
+                        self.beginInsertRows(
+                            self.createIndex(parentItem.row(), 0, parentItem),
+                            0, len(syspath) - 1)
+                    for p in syspath:
+                        if os.path.isdir(p):
+                            node = BrowserDirectoryItem(parentItem, p)
+                        else:
+                            node = BrowserFileItem(parentItem, p)
+                        self._addItem(node, parentItem)
+                    if repopulate:
+                        self.endInsertRows()
+            else:
+                proc.kill()
 
     def populateFileItem(self, parentItem, repopulate=False):
         """

eric ide

mercurial