Mon, 30 Sep 2013 22:13:01 +0200
Python 2 compatibility for Eric 5.
--- a/ChangeLog Sat Sep 28 13:28:03 2013 +0200 +++ b/ChangeLog Mon Sep 30 22:13:01 2013 +0200 @@ -1,5 +1,10 @@ ChangeLog --------- +Version 3.2.0: +- bug fixes +- Python 2 compatibility for Eric 5 +- Python executable for Django based on project configuration selected + Version 3.1.0: - bug fixes - added a menu entry to call a translations editor from the translations viewer
--- a/PluginDjango.e4p Sat Sep 28 13:28:03 2013 +0200 +++ b/PluginDjango.e4p Mon Sep 30 22:13:01 2013 +0200 @@ -1,13 +1,15 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE Project SYSTEM "Project-5.1.dtd"> <!-- eric5 project file for project PluginDjango --> +<!-- Saved: 2013-09-30, 22:06:03 --> +<!-- Copyright (C) 2013 Detlev Offenbach, detlev@die-offenbachs.de --> <Project version="5.1"> <Language>en</Language> <Hash>74ebac2e9316db59fdca32e146fa5ae695c66907</Hash> <ProgLanguage mixed="0">Python3</ProgLanguage> <ProjectType>E4Plugin</ProjectType> <Description>Plugin implementing support for Django projects.</Description> - <Version>3.1.x</Version> + <Version>3.2.0</Version> <Author>Detlev Offenbach</Author> <Email>detlev@die-offenbachs.de</Email> <TranslationPattern>ProjectDjango/i18n/django_%language%.ts</TranslationPattern>
--- a/PluginProjectDjango.py Sat Sep 28 13:28:03 2013 +0200 +++ b/PluginProjectDjango.py Mon Sep 30 22:13:01 2013 +0200 @@ -7,6 +7,8 @@ Module implementing the Django project plugin. """ +from __future__ import unicode_literals # __IGNORE_WARNING__ + import os import glob import fnmatch @@ -26,7 +28,7 @@ author = "Detlev Offenbach <detlev@die-offenbachs.de>" autoactivate = True deactivateable = True -version = "3.1.0" +version = "3.2.0" className = "ProjectDjangoPlugin" packageName = "ProjectDjango" shortDescription = "Project support for Django projects."
--- a/ProjectDjango/ConfigurationPage/DjangoPage.py Sat Sep 28 13:28:03 2013 +0200 +++ b/ProjectDjango/ConfigurationPage/DjangoPage.py Mon Sep 30 22:13:01 2013 +0200 @@ -7,6 +7,8 @@ Module implementing the Django configuration page. """ +from __future__ import unicode_literals # __IGNORE_WARNING__ + from PyQt4.QtCore import pyqtSlot from E5Gui import E5FileDialog @@ -29,7 +31,7 @@ @param plugin reference to the plugin object """ - super().__init__() + super(DjangoPage, self).__init__() self.setupUi(self) self.setObjectName("DjangoPage")
--- a/ProjectDjango/DjangoDialog.py Sat Sep 28 13:28:03 2013 +0200 +++ b/ProjectDjango/DjangoDialog.py Mon Sep 30 22:13:01 2013 +0200 @@ -7,6 +7,12 @@ Module implementing a dialog starting a process and showing its output. """ +from __future__ import unicode_literals # __IGNORE_WARNING__ +try: + str = unicode # __IGNORE_WARNING__ +except (NameError): + pass + from PyQt4.QtCore import pyqtSlot, QProcess, QTimer, QFileInfo from PyQt4.QtGui import QDialog, QDialogButtonBox, QAbstractButton, QTextEdit @@ -44,7 +50,7 @@ @keyparam saveFilters filename filter string (string) @keyparam parent parent widget (QWidget) """ - super().__init__(parent) + super(DjangoDialog, self).__init__(parent) self.setupUi(self) self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
--- a/ProjectDjango/DjangoDumpdataDataDialog.py Sat Sep 28 13:28:03 2013 +0200 +++ b/ProjectDjango/DjangoDumpdataDataDialog.py Mon Sep 30 22:13:01 2013 +0200 @@ -7,6 +7,8 @@ Module implementing a dialog to enter the data for the 'dumpdata' command. """ +from __future__ import unicode_literals # __IGNORE_WARNING__ + from PyQt4.QtGui import QDialog from .Ui_DjangoDumpdataDataDialog import Ui_DjangoDumpdataDataDialog @@ -23,7 +25,7 @@ @param project reference to the Django project object @param parent reference to the parent widget (QWidget) """ - super().__init__(parent) + super(DjangoDumpdataDataDialog, self).__init__(parent) self.setupUi(self) self.__project = project
--- a/ProjectDjango/DjangoLoaddataDataDialog.py Sat Sep 28 13:28:03 2013 +0200 +++ b/ProjectDjango/DjangoLoaddataDataDialog.py Mon Sep 30 22:13:01 2013 +0200 @@ -7,6 +7,8 @@ Module implementing a dialog to enter the data for the 'loaddata' command. """ +from __future__ import unicode_literals # __IGNORE_WARNING__ + from PyQt4.QtCore import pyqtSlot from PyQt4.QtGui import QDialog, QDialogButtonBox @@ -28,7 +30,7 @@ @param project reference to the Django project object @param parent reference to the parent widget (QWidget) """ - super().__init__(parent) + super(DjangoLoaddataDataDialog, self).__init__(parent) self.setupUi(self) self.__project = project
--- a/ProjectDjango/Documentation/source/Plugin_Project_Django.ProjectDjango.Project.html Sat Sep 28 13:28:03 2013 +0200 +++ b/ProjectDjango/Documentation/source/Plugin_Project_Django.ProjectDjango.Project.html Mon Sep 30 22:13:01 2013 +0200 @@ -155,6 +155,9 @@ <td><a href="#Project.__getApplications">__getApplications</a></td> <td>Private method to ask the user for a list of application names.</td> </tr><tr> +<td><a href="#Project.__getDebugEnvironment">__getDebugEnvironment</a></td> +<td>Private method to get the path of the debugger environment.</td> +</tr><tr> <td><a href="#Project.__getDjangoAdminCommand">__getDjangoAdminCommand</a></td> <td>Private method to build a django-admin.py command.</td> </tr><tr> @@ -518,6 +521,22 @@ <dd> list of application names (list of strings) </dd> +</dl><a NAME="Project.__getDebugEnvironment" ID="Project.__getDebugEnvironment"></a> +<h4>Project.__getDebugEnvironment</h4> +<b>__getDebugEnvironment</b>(<i>language=""</i>) +<p> + Private method to get the path of the debugger environment. +</p><dl> +<dt><i>language</i></dt> +<dd> +Python variant to get the debugger environment + for (string, one of '', 'Python2' or 'Python3') +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +path of the debugger environment (string) +</dd> </dl><a NAME="Project.__getDjangoAdminCommand" ID="Project.__getDjangoAdminCommand"></a> <h4>Project.__getDjangoAdminCommand</h4> <b>__getDjangoAdminCommand</b>(<i>language=""</i>)
--- a/ProjectDjango/Project.py Sat Sep 28 13:28:03 2013 +0200 +++ b/ProjectDjango/Project.py Mon Sep 30 22:13:01 2013 +0200 @@ -7,6 +7,12 @@ Module implementing the Django project support. """ +from __future__ import unicode_literals # __IGNORE_WARNING__ +try: + str = unicode # __IGNORE_WARNING__ +except (NameError): + pass + import sys import os import re @@ -47,7 +53,7 @@ @param plugin reference to the plugin object @param parent parent (QObject) """ - super().__init__(parent) + super(Project, self).__init__(parent) self.__plugin = plugin self.__ui = parent @@ -900,7 +906,7 @@ if self.__getDjangoAdminCommand(variant): variants.append(variant) else: - cmd = self.__getDjangoAdminCommand() + cmd = self.__getDjangoAdminCommand(variant) if isWindowsPlatform(): if variant.lower() in cmd.lower(): variants.append(variant) @@ -945,7 +951,28 @@ if virtEnv and not os.path.exists(virtEnv): virtEnv = "" return virtEnv - + + def __getDebugEnvironment(self, language=""): + """ + Private method to get the path of the debugger environment. + + @param language Python variant to get the debugger environment + for (string, one of '', 'Python2' or 'Python3') + @return path of the debugger environment (string) + """ + if not language: + language = self.__e5project.getProjectLanguage() + if language == "Python3": + debugEnv = Preferences.getDebugger("Python3Interpreter") + elif language == "Python2": + debugEnv = Preferences.getDebugger("PythonInterpreter") + else: + debugEnv = sys.executable + debugEnv = os.path.dirname(debugEnv) + if debugEnv and not os.path.exists(debugEnv): + debugEnv = sys.exec_prefix + return debugEnv + def __getDjangoAdminCommand(self, language=""): """ Private method to build a django-admin.py command. @@ -972,7 +999,8 @@ "" else: if isWindowsPlatform(): - cmd = os.path.join(sys.exec_prefix, "Scripts", "django-admin.py") + debugEnv = self.__getDebugEnvironment(language) + cmd = os.path.join(debugEnv, "Scripts", "django-admin.py") else: if Utilities.isinpath("django-admin.py"): cmd = "django-admin.py" @@ -990,23 +1018,25 @@ @return python command (string) """ - python = "python" + language = self.__e5project.getProjectLanguage() + pythonExe = "python" if isWindowsPlatform(): - python += ".exe" + pythonExe += ".exe" else: - language = self.__e5project.getProjectLanguage() if language == "Python3": - python = "python3" + pythonExe = "python3" elif language == "Python2": - python = "python2" + pythonExe = "python2" virtualEnv = self.__getVirtualEnvironment() + if not virtualEnv: + virtualEnv = self.__getDebugEnvironment(language) if virtualEnv: if isWindowsPlatform(): - python = os.path.join(virtualEnv, "Scripts", python) + python = os.path.join(virtualEnv, "Scripts", pythonExe) if not os.path.exists(python): - python = os.path.join(virtualEnv, python) + python = os.path.join(virtualEnv, pythonExe) else: - python = os.path.join(virtualEnv, "bin", python) + python = os.path.join(virtualEnv, "bin", pythonExe) if not os.path.exists(python): python = python[:-1] # omit the version character