45 Constructor |
51 Constructor |
46 |
52 |
47 @param plugin reference to the plugin object |
53 @param plugin reference to the plugin object |
48 @param parent parent (QObject) |
54 @param parent parent (QObject) |
49 """ |
55 """ |
50 super().__init__(parent) |
56 super(Project, self).__init__(parent) |
51 |
57 |
52 self.__plugin = plugin |
58 self.__plugin = plugin |
53 self.__ui = parent |
59 self.__ui = parent |
54 self.__e5project = e5App().getObject("Project") |
60 self.__e5project = e5App().getObject("Project") |
55 self.__hooksInstalled = False |
61 self.__hooksInstalled = False |
898 virtEnv = self.__getVirtualEnvironment(variant) |
904 virtEnv = self.__getVirtualEnvironment(variant) |
899 if virtEnv: |
905 if virtEnv: |
900 if self.__getDjangoAdminCommand(variant): |
906 if self.__getDjangoAdminCommand(variant): |
901 variants.append(variant) |
907 variants.append(variant) |
902 else: |
908 else: |
903 cmd = self.__getDjangoAdminCommand() |
909 cmd = self.__getDjangoAdminCommand(variant) |
904 if isWindowsPlatform(): |
910 if isWindowsPlatform(): |
905 if variant.lower() in cmd.lower(): |
911 if variant.lower() in cmd.lower(): |
906 variants.append(variant) |
912 variants.append(variant) |
907 else: |
913 else: |
908 try: |
914 try: |
943 else: |
949 else: |
944 virtEnv = "" |
950 virtEnv = "" |
945 if virtEnv and not os.path.exists(virtEnv): |
951 if virtEnv and not os.path.exists(virtEnv): |
946 virtEnv = "" |
952 virtEnv = "" |
947 return virtEnv |
953 return virtEnv |
948 |
954 |
|
955 def __getDebugEnvironment(self, language=""): |
|
956 """ |
|
957 Private method to get the path of the debugger environment. |
|
958 |
|
959 @param language Python variant to get the debugger environment |
|
960 for (string, one of '', 'Python2' or 'Python3') |
|
961 @return path of the debugger environment (string) |
|
962 """ |
|
963 if not language: |
|
964 language = self.__e5project.getProjectLanguage() |
|
965 if language == "Python3": |
|
966 debugEnv = Preferences.getDebugger("Python3Interpreter") |
|
967 elif language == "Python2": |
|
968 debugEnv = Preferences.getDebugger("PythonInterpreter") |
|
969 else: |
|
970 debugEnv = sys.executable |
|
971 debugEnv = os.path.dirname(debugEnv) |
|
972 if debugEnv and not os.path.exists(debugEnv): |
|
973 debugEnv = sys.exec_prefix |
|
974 return debugEnv |
|
975 |
949 def __getDjangoAdminCommand(self, language=""): |
976 def __getDjangoAdminCommand(self, language=""): |
950 """ |
977 """ |
951 Private method to build a django-admin.py command. |
978 Private method to build a django-admin.py command. |
952 |
979 |
953 @param language Python variant to get the django-admin.py |
980 @param language Python variant to get the django-admin.py |
970 break |
997 break |
971 else: |
998 else: |
972 "" |
999 "" |
973 else: |
1000 else: |
974 if isWindowsPlatform(): |
1001 if isWindowsPlatform(): |
975 cmd = os.path.join(sys.exec_prefix, "Scripts", "django-admin.py") |
1002 debugEnv = self.__getDebugEnvironment(language) |
|
1003 cmd = os.path.join(debugEnv, "Scripts", "django-admin.py") |
976 else: |
1004 else: |
977 if Utilities.isinpath("django-admin.py"): |
1005 if Utilities.isinpath("django-admin.py"): |
978 cmd = "django-admin.py" |
1006 cmd = "django-admin.py" |
979 elif Utilities.isinpath("django-admin"): |
1007 elif Utilities.isinpath("django-admin"): |
980 cmd = "django-admin" |
1008 cmd = "django-admin" |
988 """ |
1016 """ |
989 Public method to build the Python command. |
1017 Public method to build the Python command. |
990 |
1018 |
991 @return python command (string) |
1019 @return python command (string) |
992 """ |
1020 """ |
993 python = "python" |
1021 language = self.__e5project.getProjectLanguage() |
|
1022 pythonExe = "python" |
994 if isWindowsPlatform(): |
1023 if isWindowsPlatform(): |
995 python += ".exe" |
1024 pythonExe += ".exe" |
996 else: |
1025 else: |
997 language = self.__e5project.getProjectLanguage() |
|
998 if language == "Python3": |
1026 if language == "Python3": |
999 python = "python3" |
1027 pythonExe = "python3" |
1000 elif language == "Python2": |
1028 elif language == "Python2": |
1001 python = "python2" |
1029 pythonExe = "python2" |
1002 virtualEnv = self.__getVirtualEnvironment() |
1030 virtualEnv = self.__getVirtualEnvironment() |
|
1031 if not virtualEnv: |
|
1032 virtualEnv = self.__getDebugEnvironment(language) |
1003 if virtualEnv: |
1033 if virtualEnv: |
1004 if isWindowsPlatform(): |
1034 if isWindowsPlatform(): |
1005 python = os.path.join(virtualEnv, "Scripts", python) |
1035 python = os.path.join(virtualEnv, "Scripts", pythonExe) |
1006 if not os.path.exists(python): |
1036 if not os.path.exists(python): |
1007 python = os.path.join(virtualEnv, python) |
1037 python = os.path.join(virtualEnv, pythonExe) |
1008 else: |
1038 else: |
1009 python = os.path.join(virtualEnv, "bin", python) |
1039 python = os.path.join(virtualEnv, "bin", pythonExe) |
1010 if not os.path.exists(python): |
1040 if not os.path.exists(python): |
1011 python = python[:-1] # omit the version character |
1041 python = python[:-1] # omit the version character |
1012 |
1042 |
1013 return python |
1043 return python |
1014 |
1044 |