40 @param parent reference to the parent widget |
41 @param parent reference to the parent widget |
41 @type QWidget |
42 @type QWidget |
42 """ |
43 """ |
43 super().__init__(parent) |
44 super().__init__(parent) |
44 self.setupUi(self) |
45 self.setupUi(self) |
45 |
46 |
46 self.settingsFileButton.setIcon(UI.PixmapCache.getIcon("open")) |
47 self.settingsFileButton.setIcon(UI.PixmapCache.getIcon("open")) |
47 |
48 |
48 self.__python = python |
49 self.__python = python |
49 self.__path = path |
50 self.__path = path |
50 |
51 |
51 self.appsComboBox.addItems([""] + apps) |
52 self.appsComboBox.addItems([""] + apps) |
52 |
53 |
53 self.deployCheckBox.setChecked(deployMode) |
54 self.deployCheckBox.setChecked(deployMode) |
54 self.on_deployCheckBox_toggled(deployMode) |
55 self.on_deployCheckBox_toggled(deployMode) |
55 |
56 |
56 @pyqtSlot(bool) |
57 @pyqtSlot(bool) |
57 def on_deployCheckBox_toggled(self, checked): |
58 def on_deployCheckBox_toggled(self, checked): |
58 """ |
59 """ |
59 Private slot handling a change of the deploy check box. |
60 Private slot handling a change of the deploy check box. |
60 |
61 |
61 @param checked state of the check box |
62 @param checked state of the check box |
62 @type bool |
63 @type bool |
63 """ |
64 """ |
64 self.settingsFileGroup.setEnabled(checked) |
65 self.settingsFileGroup.setEnabled(checked) |
65 self.__populateTagsList(checked) |
66 self.__populateTagsList(checked) |
66 |
67 |
67 @pyqtSlot() |
68 @pyqtSlot() |
68 def on_settingsFileButton_clicked(self): |
69 def on_settingsFileButton_clicked(self): |
69 """ |
70 """ |
70 Private slot to select a settings file via a file selection dialog. |
71 Private slot to select a settings file via a file selection dialog. |
71 """ |
72 """ |
72 path = self.__moduleToPath(self.settingsFileEdit.text()) |
73 path = self.__moduleToPath(self.settingsFileEdit.text()) |
73 if not path: |
74 if not path: |
74 path = self.__path |
75 path = self.__path |
75 settingsFile = EricFileDialog.getOpenFileName( |
76 settingsFile = EricFileDialog.getOpenFileName( |
76 self, |
77 self, self.tr("Select settings file"), path, self.tr("Python Files (*.py)") |
77 self.tr("Select settings file"), |
78 ) |
78 path, |
79 |
79 self.tr("Python Files (*.py)")) |
|
80 |
|
81 if settingsFile: |
80 if settingsFile: |
82 self.settingsFileEdit.setText(self.__pathToModule(settingsFile)) |
81 self.settingsFileEdit.setText(self.__pathToModule(settingsFile)) |
83 |
82 |
84 def __pathToModule(self, path): |
83 def __pathToModule(self, path): |
85 """ |
84 """ |
86 Private method to convert a file path including a .py extension to a |
85 Private method to convert a file path including a .py extension to a |
87 module name. |
86 module name. |
88 |
87 |
89 @param path file path to be converted |
88 @param path file path to be converted |
90 @type str |
89 @type str |
91 @return module name |
90 @return module name |
92 @rtype str |
91 @rtype str |
93 """ |
92 """ |
94 start = ( |
93 start = self.__path[:-1] if self.__path.endswith(("/", "\\")) else self.__path |
95 self.__path[:-1] |
|
96 if self.__path.endswith(("/", "\\")) else |
|
97 self.__path |
|
98 ) |
|
99 relPath = Utilities.relativeUniversalPath(path, start) |
94 relPath = Utilities.relativeUniversalPath(path, start) |
100 mod = os.path.splitext(relPath)[0].replace("/", ".") |
95 mod = os.path.splitext(relPath)[0].replace("/", ".") |
101 return mod |
96 return mod |
102 |
97 |
103 def __moduleToPath(self, moduleName): |
98 def __moduleToPath(self, moduleName): |
104 """ |
99 """ |
105 Private method to convert a module name to an file path. |
100 Private method to convert a module name to an file path. |
106 |
101 |
107 @param moduleName module name to be converted |
102 @param moduleName module name to be converted |
108 @type str |
103 @type str |
109 @return file path |
104 @return file path |
110 @rtype str |
105 @rtype str |
111 """ |
106 """ |
112 if moduleName: |
107 if moduleName: |
113 mod = "{0}.py".format(moduleName.replace(".", "/")) |
108 mod = "{0}.py".format(moduleName.replace(".", "/")) |
114 if not os.path.isabs(mod): |
109 if not os.path.isabs(mod): |
115 mod = os.path.join(self.__path, mod) |
110 mod = os.path.join(self.__path, mod) |
116 |
111 |
117 path = Utilities.toNativeSeparators(mod) |
112 path = Utilities.toNativeSeparators(mod) |
118 else: |
113 else: |
119 path = "" |
114 path = "" |
120 return path |
115 return path |
121 |
116 |
122 def __populateTagsList(self, deployMode): |
117 def __populateTagsList(self, deployMode): |
123 """ |
118 """ |
124 Private slot to populate the tags list. |
119 Private slot to populate the tags list. |
125 |
120 |
126 @param deployMode flag indicating the deployment mode |
121 @param deployMode flag indicating the deployment mode |
127 @type bool |
122 @type bool |
128 """ |
123 """ |
129 # step 1: save the selected tags |
124 # step 1: save the selected tags |
130 selectedTags = [] |
125 selectedTags = [] |
131 for itm in self.tagsList.selectedItems(): |
126 for itm in self.tagsList.selectedItems(): |
132 selectedTags.append(itm.text()) |
127 selectedTags.append(itm.text()) |
133 |
128 |
134 # step 2: clear the list |
129 # step 2: clear the list |
135 self.tagsList.clear() |
130 self.tagsList.clear() |
136 |
131 |
137 # step 3: get the available tags and populate the list |
132 # step 3: get the available tags and populate the list |
138 args = [] |
133 args = [] |
139 args.append("manage.py") |
134 args.append("manage.py") |
140 args.append("check") |
135 args.append("check") |
141 args.append("--list-tags") |
136 args.append("--list-tags") |
142 if deployMode: |
137 if deployMode: |
143 args.append("--deploy") |
138 args.append("--deploy") |
144 |
139 |
145 proc = QProcess() |
140 proc = QProcess() |
146 if self.__path: |
141 if self.__path: |
147 proc.setWorkingDirectory(self.__path) |
142 proc.setWorkingDirectory(self.__path) |
148 proc.start(self.__python, args) |
143 proc.start(self.__python, args) |
149 if proc.waitForStarted() and proc.waitForFinished(): |
144 if proc.waitForStarted() and proc.waitForFinished(): |
150 output = str(proc.readAllStandardOutput(), |
145 output = str( |
151 Preferences.getSystem("IOEncoding"), 'replace') |
146 proc.readAllStandardOutput(), |
|
147 Preferences.getSystem("IOEncoding"), |
|
148 "replace", |
|
149 ) |
152 for line in output.splitlines(): |
150 for line in output.splitlines(): |
153 self.tagsList.addItem(line.strip()) |
151 self.tagsList.addItem(line.strip()) |
154 |
152 |
155 # step 4: re-select tags |
153 # step 4: re-select tags |
156 for tag in selectedTags: |
154 for tag in selectedTags: |
157 items = self.tagsList.findItems( |
155 items = self.tagsList.findItems(tag, Qt.MatchFlag.MatchCaseSensitive) |
158 tag, Qt.MatchFlag.MatchCaseSensitive) |
|
159 if items: |
156 if items: |
160 items[0].setSelected(True) |
157 items[0].setSelected(True) |
161 |
158 |
162 def getData(self): |
159 def getData(self): |
163 """ |
160 """ |
164 Public method to get the options for the check operation. |
161 Public method to get the options for the check operation. |
165 |
162 |
166 @return tuple containing the deployment flag, list of selected tags, |
163 @return tuple containing the deployment flag, list of selected tags, |
167 applications string and the settings file |
164 applications string and the settings file |
168 @rtype tuple of bool, list of str, str and str |
165 @rtype tuple of bool, list of str, str and str |
169 """ |
166 """ |
170 selectedTags = [] |
167 selectedTags = [] |
171 for itm in self.tagsList.selectedItems(): |
168 for itm in self.tagsList.selectedItems(): |
172 selectedTags.append(itm.text()) |
169 selectedTags.append(itm.text()) |
173 |
170 |
174 return ( |
171 return ( |
175 self.deployCheckBox.isChecked(), |
172 self.deployCheckBox.isChecked(), |
176 selectedTags, |
173 selectedTags, |
177 self.appsComboBox.currentText(), |
174 self.appsComboBox.currentText(), |
178 self.settingsFileEdit.text(), |
175 self.settingsFileEdit.text(), |