eric6/VirtualEnv/VirtualenvAddEditDialog.py

Sun, 01 Sep 2019 19:40:53 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 01 Sep 2019 19:40:53 +0200
branch
without_py2_and_pyqt4
changeset 7198
684261ef2165
parent 6942
2602857055c5
child 7229
53054eb5b15a
permissions
-rw-r--r--

Removed the Qt4 runtime stuff.

6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6576
diff changeset
3 # Copyright (c) 2018 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 Module implementing a dialog to enter the data of a virtual environment.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 from __future__ import unicode_literals
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
11
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
12 import os
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 import sys
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 from PyQt5.QtCore import pyqtSlot
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
16 from PyQt5.QtWidgets import QDialog, QDialogButtonBox
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18 from E5Gui.E5PathPicker import E5PathPickerModes
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
19
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20 from .Ui_VirtualenvAddEditDialog import Ui_VirtualenvAddEditDialog
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 import Utilities
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25 class VirtualenvAddEditDialog(QDialog, Ui_VirtualenvAddEditDialog):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27 Class implementing a dialog to enter the data of a virtual environment.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
28 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
29 def __init__(self, manager, venvName="", venvDirectory="",
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
30 venvInterpreter="", venvVariant=3, isGlobal=False,
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
31 isConda=False, isRemote=False, execPath="", parent=None):
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
32 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
33 Constructor
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
34
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
35 @param manager reference to the virtual environment manager
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
36 @type VirtualenvManager
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37 @param venvName logical name of a virtual environment for editing
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 @type str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 @param venvDirectory directory of the virtual environment
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 @type str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 @param venvInterpreter Python interpreter of the virtual environment
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42 @type str
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
43 @param venvVariant Python variant of the virtual environment
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
44 @type int
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
45 @param isGlobal flag indicating a global environment
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
46 @type bool
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
47 @param isConda flag indicating an Anaconda virtual environment
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
48 @type bool
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
49 @param isRemote flag indicating a remotely accessed environment
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
50 @type bool
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
51 @param execPath search path string to be prepended to the PATH
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
52 environment variable
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
53 @type str
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 @param parent reference to the parent widget
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
55 @type QWidget
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
56 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
57 super(VirtualenvAddEditDialog, self).__init__(parent)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
58 self.setupUi(self)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
59
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
60 self.__venvName = venvName
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
61 self.__manager = manager
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
62 self.__editMode = bool(venvName)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
63
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
64 self.targetDirectoryPicker.setMode(E5PathPickerModes.DirectoryMode)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
65 self.targetDirectoryPicker.setWindowTitle(
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 self.tr("Virtualenv Target Directory"))
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 self.targetDirectoryPicker.setDefaultDirectory(Utilities.getHomeDir())
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 self.pythonExecPicker.setMode(E5PathPickerModes.OpenFileMode)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 self.pythonExecPicker.setWindowTitle(
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 self.tr("Python Interpreter"))
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 self.pythonExecPicker.setDefaultDirectory(
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 sys.executable.replace("w.exe", ".exe"))
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
75 self.execPathEdit.setToolTip(self.tr(
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
76 "Enter the executable search path to be prepended to the PATH"
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
77 " environment variable. Use '{0}' as the separator.").format(
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
78 os.pathsep)
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
79 )
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
80
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 self.nameEdit.setText(venvName)
6719
705080ffd4a9 VirtualenvAddEditDialog: fixed an issue causing file path conversion for remote environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6716
diff changeset
82 self.targetDirectoryPicker.setText(venvDirectory,
705080ffd4a9 VirtualenvAddEditDialog: fixed an issue causing file path conversion for remote environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6716
diff changeset
83 toNative=not isRemote)
705080ffd4a9 VirtualenvAddEditDialog: fixed an issue causing file path conversion for remote environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6716
diff changeset
84 self.pythonExecPicker.setText(venvInterpreter,
705080ffd4a9 VirtualenvAddEditDialog: fixed an issue causing file path conversion for remote environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6716
diff changeset
85 toNative=not isRemote)
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
86 self.variantComboBox.setCurrentIndex(3 - venvVariant)
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
87 self.globalCheckBox.setChecked(isGlobal)
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
88 self.anacondaCheckBox.setChecked(isConda)
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
89 self.remoteCheckBox.setChecked(isRemote)
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
90 self.execPathEdit.setText(execPath)
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92 self.__updateOk()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 def __updateOk(self):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96 Private slot to update the state of the OK button.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 if self.__editMode:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 enable = (
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
100 bool(self.nameEdit.text()) and
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
101 (self.nameEdit.text() == self.__venvName or
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 self.__manager.isUnique(self.nameEdit.text()))
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
103 )
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 else:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 enable = (
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 bool(self.nameEdit.text()) and
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107 self.__manager.isUnique(self.nameEdit.text())
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 )
6341
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
109
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
110 if not self.globalCheckBox.isChecked():
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
111 enable = (
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
112 enable and (
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
113 self.remoteCheckBox.isChecked() or (
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
114 bool(self.targetDirectoryPicker.text()) and
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
115 os.path.exists(self.targetDirectoryPicker.text())
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
116 )
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
117 )
6341
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
118 )
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
119
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 enable = (
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 enable and
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
122 bool(self.pythonExecPicker.text()) and (
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
123 self.remoteCheckBox.isChecked() or
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
124 os.access(self.pythonExecPicker.text(), os.X_OK)
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
125 )
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 )
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 self.buttonBox.button(QDialogButtonBox.Ok).setEnabled(enable)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 @pyqtSlot(str)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131 def on_nameEdit_textChanged(self, txt):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
132 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 Private slot to handle changes of the logical name.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 @param txt current logical name
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 @type str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 self.__updateOk()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 @pyqtSlot(str)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 def on_targetDirectoryPicker_textChanged(self, txt):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143 Private slot to handle changes of the virtual environment directory.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 @param txt virtual environment directory
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
146 @type str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
147 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148 self.__updateOk()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
149
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 if txt:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 self.pythonExecPicker.setDefaultDirectory(txt)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152 else:
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 self.pythonExecPicker.setDefaultDirectory(
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 sys.executable.replace("w.exe", ".exe"))
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 @pyqtSlot(str)
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 def on_pythonExecPicker_textChanged(self, txt):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
159 Private slot to handle changes of the virtual environment interpreter.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 @param txt virtual environment interpreter
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 @type str
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
164 self.__updateOk()
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
165
6341
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
166 @pyqtSlot(bool)
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
167 def on_globalCheckBox_toggled(self, checked):
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
168 """
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
169 Private slot handling a change of the global check box state.
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
170
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
171 @param checked state of the check box
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
172 @type bool
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
173 """
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
174 self.__updateOk()
a00e63f6d766 VirtualenvManager: changed code to allow environments without environment directory denoting a global environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6338
diff changeset
175
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
176 @pyqtSlot(bool)
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
177 def on_remoteCheckBox_toggled(self, checked):
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
178 """
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
179 Private slot handling a change of the remote check box state.
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
180
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
181 @param checked state of the check box
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
182 @type bool
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
183 """
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
184 self.__updateOk()
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
185
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
186 @pyqtSlot(bool)
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
187 def on_anacondaCheckBox_clicked(self, checked):
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
188 """
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
189 Private slot handling a user click on this check box.
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
190
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
191 @param checked state of the check box
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
192 @type bool
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
193 """
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
194 if checked and not bool(self.execPathEdit.text()):
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
195 # prepopulate the execPathEdit widget
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
196 if Utilities.isWindowsPlatform():
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
197 self.execPathEdit.setText(os.pathsep.join([
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
198 self.targetDirectoryPicker.text(),
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
199 os.path.join(self.targetDirectoryPicker.text(),
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
200 "Scripts"),
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
201 os.path.join(self.targetDirectoryPicker.text(),
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
202 "Library", "bin"),
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
203 ]))
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
204 else:
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
205 self.execPathEdit.setText(
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
206 os.path.join(self.targetDirectoryPicker.text(),
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
207 "bin"),
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
208 )
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
209
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 def getData(self):
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 """
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 Public method to retrieve the entered data.
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213
6349
17b3c75913de VirtualEnv: improved the virtual env handling.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6341
diff changeset
214 @return tuple containing the logical name, the directory, the
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
215 interpreter of the virtual environment, the Python variant,
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
216 a flag indicating a global environment, a flag indicating an
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
217 Anaconda environment, aflag indicating a remotely accessed
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
218 environment and a string to be prepended to the PATH environment
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
219 variable
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
220 @rtype tuple of (str, str, str, int, bool, bool, bool, str)
6338
104ee21d765d VirtualEnv: finished implementing a virtualenv manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 """
6719
705080ffd4a9 VirtualenvAddEditDialog: fixed an issue causing file path conversion for remote environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6716
diff changeset
222 nativePaths = not self.remoteCheckBox.isChecked()
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
223 return (
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
224 self.nameEdit.text(),
6719
705080ffd4a9 VirtualenvAddEditDialog: fixed an issue causing file path conversion for remote environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6716
diff changeset
225 self.targetDirectoryPicker.text(toNative=nativePaths),
705080ffd4a9 VirtualenvAddEditDialog: fixed an issue causing file path conversion for remote environments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6716
diff changeset
226 self.pythonExecPicker.text(toNative=nativePaths),
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
227 3 - self.variantComboBox.currentIndex(),
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
228 self.globalCheckBox.isChecked(),
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
229 self.anacondaCheckBox.isChecked(),
6716
1c9d3b369ea8 VirtualEnv Manager: extended the environment definition by a flag indicating a remotely accessed environment.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6645
diff changeset
230 self.remoteCheckBox.isChecked(),
6576
ea60ea85067a VitualEnv Manager:
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6362
diff changeset
231 self.execPathEdit.text(),
6362
ec32d1d7f525 Virtual Environments: improved the virtual environment handling
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6349
diff changeset
232 )

eric ide

mercurial