Wed, 10 Apr 2013 22:33:47 +0200
Search for interpreter on startup, avoid 'not found' message and switch to opposite interpreter.
--- a/APIs/Python3/eric5.api Wed Apr 10 22:21:27 2013 +0200 +++ b/APIs/Python3/eric5.api Wed Apr 10 22:33:47 2013 +0200 @@ -1747,7 +1747,7 @@ eric5.Globals.AppInfo.makeAppInfo?4(argv, name, arg, description, options=[]) eric5.Globals.checkBlacklistedVersions?4() eric5.Globals.configDir?7 -eric5.Globals.findPython2Interpreters?4() +eric5.Globals.findPythonInterpreters?4(pyVersion) eric5.Globals.getConfigDir?4() eric5.Globals.isLinuxPlatform?4() eric5.Globals.isMacPlatform?4()
--- a/Debugger/DebugServer.py Wed Apr 10 22:21:27 2013 +0200 +++ b/Debugger/DebugServer.py Wed Apr 10 22:33:47 2013 +0200 @@ -187,6 +187,11 @@ self.clientType = 'Python2' else: self.clientType = 'Python3' + # Change clientType if dependent interpreter not exist anymore (maybe deinstalled,...) + elif self.clientType == 'Python2' and Preferences.getDebugger("PythonInterpreter") == '': + self.clientType = 'Python3' + elif self.clientType == 'Python3' and Preferences.getDebugger("Python3Interpreter") == '': + self.clientType = 'Python2' self.lastClientType = '' self.__autoClearShell = False
--- a/Debugger/DebuggerInterfacePython3.py Wed Apr 10 22:21:27 2013 +0200 +++ b/Debugger/DebuggerInterfacePython3.py Wed Apr 10 22:33:47 2013 +0200 @@ -150,12 +150,13 @@ @return client process object (QProcess) and a flag to indicate a network connection (boolean) """ - if Preferences.getDebugger("CustomPython3Interpreter"): - interpreter = Preferences.getDebugger("Python3Interpreter") - if interpreter == "": - interpreter = sys.executable - else: - interpreter = sys.executable + interpreter = Preferences.getDebugger("Python3Interpreter") + if interpreter == "": + E5MessageBox.critical(None, + self.trUtf8("Start Debugger"), + self.trUtf8( + """<p>No Python3 interpreter configured.</p>""")) + return None, False debugClientType = Preferences.getDebugger("DebugClientType3") if debugClientType == "standard":
--- a/Documentation/Help/source.qhp Wed Apr 10 22:21:27 2013 +0200 +++ b/Documentation/Help/source.qhp Wed Apr 10 22:33:47 2013 +0200 @@ -12434,7 +12434,7 @@ <keyword name="filename_match" id="filename_match" ref="eric5.UtilitiesPython2.pep8.html#filename_match" /> <keyword name="fileno" id="fileno" ref="eric5.DebugClients.Ruby.AsyncFile.html#fileno" /> <keyword name="filterCharsFromFilename" id="filterCharsFromFilename" ref="eric5.Helpviewer.HelpUtilities.html#filterCharsFromFilename" /> - <keyword name="findPython2Interpreters" id="findPython2Interpreters" ref="eric5.Globals.__init__.html#findPython2Interpreters" /> + <keyword name="findPythonInterpreters" id="findPythonInterpreters" ref="eric5.Globals.__init__.html#findPythonInterpreters" /> <keyword name="find_checks" id="find_checks" ref="eric5.Plugins.CheckerPlugins.Pep8.pep8.html#find_checks" /> <keyword name="find_checks" id="find_checks" ref="eric5.UtilitiesPython2.pep8.html#find_checks" /> <keyword name="find_module" id="find_module" ref="eric5.Utilities.ClassBrowsers.__init__.html#find_module" />
--- a/Documentation/Source/eric5.Globals.__init__.html Wed Apr 10 22:21:27 2013 +0200 +++ b/Documentation/Source/eric5.Globals.__init__.html Wed Apr 10 22:33:47 2013 +0200 @@ -37,8 +37,8 @@ <td><a href="#checkBlacklistedVersions">checkBlacklistedVersions</a></td> <td>Module functions to check for blacklisted versions of the prerequisites.</td> </tr><tr> -<td><a href="#findPython2Interpreters">findPython2Interpreters</a></td> -<td>Module function for searching a Python2 interpreter.</td> +<td><a href="#findPythonInterpreters">findPythonInterpreters</a></td> +<td>Module function for searching a Python interpreter.</td> </tr><tr> <td><a href="#getConfigDir">getConfigDir</a></td> <td>Module function to get the name of the directory storing the config data.</td> @@ -70,12 +70,17 @@ </dl> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> -<a NAME="findPython2Interpreters" ID="findPython2Interpreters"></a> -<h2>findPython2Interpreters</h2> -<b>findPython2Interpreters</b>(<i></i>) +<a NAME="findPythonInterpreters" ID="findPythonInterpreters"></a> +<h2>findPythonInterpreters</h2> +<b>findPythonInterpreters</b>(<i>pyVersion</i>) <p> - Module function for searching a Python2 interpreter. + Module function for searching a Python interpreter. </p><dl> +<dt><i>pyVersion</i></dt> +<dd> +major Python version +</dd> +</dl><dl> <dt>Returns:</dt> <dd> list of interpreters found (list of strings)
--- a/Globals/__init__.py Wed Apr 10 22:21:27 2013 +0200 +++ b/Globals/__init__.py Wed Apr 10 22:33:47 2013 +0200 @@ -148,19 +148,24 @@ ################################################################################ -## functions for searching a Python2 interpreter +## functions for searching a Python2/3 interpreter ################################################################################ -def findPython2Interpreters(): +def findPythonInterpreters(pyVersion): """ - Module function for searching a Python2 interpreter. + Module function for searching a Python interpreter. + @param pyVersion major Python version @return list of interpreters found (list of strings) """ - winPathList = ["C:\\Python25", "C:\\Python26", "C:\\Python27", "C:\\Python28"] + if pyVersion == 2: + winPathList = ["C:\\Python25", "C:\\Python26", "C:\\Python27", "C:\\Python28"] + posixVersionsList = ["2.5", "2.6", "2.7", "2.8"] + else: + winPathList = ["C:\\Python3{0}".format(x) for x in range(5)] + posixVersionsList = ["3.{0}".format(x) for x in range(5)] posixPathList = ["/usr/bin", "/usr/local/bin"] - posixVersionsList = ["2.5", "2.6", "2.7", "2.8"] interpreters = [] if isWindowsPlatform():
--- a/Preferences/__init__.py Wed Apr 10 22:21:27 2013 +0200 +++ b/Preferences/__init__.py Wed Apr 10 22:33:47 2013 +0200 @@ -36,7 +36,7 @@ from E5Network.E5Ftp import E5FtpProxyType from Globals import settingsNameOrganization, settingsNameGlobal, settingsNameRecent, \ - isWindowsPlatform, findPython2Interpreters + isWindowsPlatform, findPythonInterpreters from Project.ProjectBrowserFlags import SourcesBrowserFlag, FormsBrowserFlag, \ ResourcesBrowserFlag, TranslationsBrowserFlag, InterfacesBrowserFlag, \ @@ -1247,11 +1247,15 @@ elif key in ["AllowedHosts"]: return toList( prefClass.settings.value("Debugger/" + key, prefClass.debuggerDefaults[key])) - elif key == "PythonInterpreter": + elif key in ["PythonInterpreter", "Python3Interpreter"]: interpreter = \ prefClass.settings.value("Debugger/" + key, prefClass.debuggerDefaults[key]) if not interpreter: - interpreters = findPython2Interpreters() + pyVersion = 2 if key == "PythonInterpreter" else 3 + if sys.version_info[0] == pyVersion: + return sys.executable + + interpreters = findPythonInterpreters(pyVersion) if interpreters: if len(interpreters) == 1: interpreter = interpreters[0] @@ -1259,15 +1263,15 @@ selection, ok = QInputDialog.getItem( None, QCoreApplication.translate("Preferences", - "Select Python2 Interpreter"), + "Select Python{0} Interpreter").format(pyVersion), QCoreApplication.translate("Preferences", - "Select the Python2 interpreter to be used:"), + "Select the Python{0} interpreter to be used:").format(pyVersion), interpreters, 0, False) if ok and selection != "": interpreter = selection if interpreter: - setDebugger("PythonInterpreter", interpreter) + setDebugger(key, interpreter) return interpreter else: return \