26 """ |
28 """ |
27 def __init__(self, caption, lastUsedVenvName, argvList, wdList, envList, |
29 def __init__(self, caption, lastUsedVenvName, argvList, wdList, envList, |
28 exceptions, |
30 exceptions, |
29 parent=None, dialogType=0, modfuncList=None, |
31 parent=None, dialogType=0, modfuncList=None, |
30 tracePython=False, autoClearShell=True, autoContinue=True, |
32 tracePython=False, autoClearShell=True, autoContinue=True, |
31 autoFork=False, forkChild=False): |
33 enableMultiprocess=False, multiprocessNoDebugHistory=None): |
32 """ |
34 """ |
33 Constructor |
35 Constructor |
34 |
36 |
35 @param caption the caption to be displayed |
37 @param caption the caption to be displayed |
36 @type str |
38 @type str |
53 <li>1 = start run dialog</li> |
55 <li>1 = start run dialog</li> |
54 <li>2 = start coverage dialog</li> |
56 <li>2 = start coverage dialog</li> |
55 <li>3 = start profile dialog</li> |
57 <li>3 = start profile dialog</li> |
56 </ul> |
58 </ul> |
57 @type int (0 to 3) |
59 @type int (0 to 3) |
58 @keyparam modfuncList history list of module functions |
60 @param modfuncList history list of module functions |
59 @type list of str |
61 @type list of str |
60 @keyparam tracePython flag indicating if the Python library should |
62 @param tracePython flag indicating if the Python library should |
61 be traced as well |
63 be traced as well |
62 @type bool |
64 @type bool |
63 @keyparam autoClearShell flag indicating, that the interpreter window |
65 @param autoClearShell flag indicating, that the interpreter window |
64 should be cleared automatically |
66 should be cleared automatically |
65 @type bool |
67 @type bool |
66 @keyparam autoContinue flag indicating, that the debugger should not |
68 @param autoContinue flag indicating, that the debugger should not |
67 stop at the first executable line |
69 stop at the first executable line |
68 @type bool |
70 @type bool |
69 @keyparam autoFork flag indicating the automatic fork mode |
71 @param enableMultiprocess flag indicating the support for multi process |
70 @type bool |
72 debugging |
71 @keyparam forkChild flag indicating to debug the child after forking |
73 @type bool |
72 @type bool |
74 @param multiprocessNoDebugHistory list of lists with programs not to be |
|
75 debugged |
|
76 @type list of str |
73 """ |
77 """ |
74 super(StartDialog, self).__init__(parent) |
78 super(StartDialog, self).__init__(parent) |
75 self.setModal(True) |
79 self.setModal(True) |
76 |
80 |
77 self.dialogType = dialogType |
81 self.dialogType = dialogType |
124 self.ui.consoleCheckBox.setChecked(False) |
128 self.ui.consoleCheckBox.setChecked(False) |
125 venvIndex = max(0, self.ui.venvComboBox.findText(lastUsedVenvName)) |
129 venvIndex = max(0, self.ui.venvComboBox.findText(lastUsedVenvName)) |
126 self.ui.venvComboBox.setCurrentIndex(venvIndex) |
130 self.ui.venvComboBox.setCurrentIndex(venvIndex) |
127 |
131 |
128 if dialogType == 0: # start debug dialog |
132 if dialogType == 0: # start debug dialog |
|
133 enableMultiprocessGlobal = Preferences.getDebugger( |
|
134 "MultiProcessEnabled") |
129 self.ui.tracePythonCheckBox.setChecked(tracePython) |
135 self.ui.tracePythonCheckBox.setChecked(tracePython) |
130 self.ui.tracePythonCheckBox.show() |
136 self.ui.tracePythonCheckBox.show() |
131 self.ui.autoContinueCheckBox.setChecked(autoContinue) |
137 self.ui.autoContinueCheckBox.setChecked(autoContinue) |
132 self.ui.forkModeCheckBox.setChecked(autoFork) |
138 self.ui.multiprocessGroup.setEnabled(enableMultiprocessGlobal) |
133 self.ui.forkChildCheckBox.setChecked(forkChild) |
139 self.ui.multiprocessGroup.setChecked( |
134 |
140 enableMultiprocess & enableMultiprocessGlobal) |
135 if dialogType == 1: # start run dialog |
141 self.ui.multiprocessNoDebugCombo.clear() |
136 self.ui.forkModeCheckBox.setChecked(autoFork) |
142 self.ui.multiprocessNoDebugCombo.setToolTip(self.tr( |
137 self.ui.forkChildCheckBox.setChecked(forkChild) |
143 "Enter the list of programs or program patterns not to be" |
|
144 " debugged separated by '{0}'.").format(os.pathsep) |
|
145 ) |
|
146 if multiprocessNoDebugHistory: |
|
147 self.ui.multiprocessNoDebugCombo.addItems( |
|
148 multiprocessNoDebugHistory) |
|
149 self.ui.multiprocessNoDebugCombo.setCurrentIndex(0) |
138 |
150 |
139 if dialogType == 3: # start coverage or profile dialog |
151 if dialogType == 3: # start coverage or profile dialog |
140 self.ui.eraseCheckBox.setChecked(True) |
152 self.ui.eraseCheckBox.setChecked(True) |
141 |
153 |
142 self.__clearHistoryLists = False |
154 self.__clearHistoryLists = False |
154 |
166 |
155 def getData(self): |
167 def getData(self): |
156 """ |
168 """ |
157 Public method to retrieve the data entered into this dialog. |
169 Public method to retrieve the data entered into this dialog. |
158 |
170 |
159 @return a tuple of interpreter (string), argv (string), workdir |
171 @return a tuple of interpreter, argv, workdir, environment, |
160 (string), environment (string), exceptions flag (boolean), |
172 exceptions flag, clear interpreter flag and run in console flag |
161 clear interpreter flag (boolean) and run in console flag (boolean) |
173 @rtype tuple of (str, str, str, str, bool, bool, bool) |
162 """ |
174 """ |
163 cmdLine = self.ui.cmdlineCombo.currentText() |
175 cmdLine = self.ui.cmdlineCombo.currentText() |
164 workdir = self.ui.workdirPicker.currentText(toNative=False) |
176 workdir = self.ui.workdirPicker.currentText(toNative=False) |
165 environment = self.ui.environmentCombo.currentText() |
177 environment = self.ui.environmentCombo.currentText() |
166 venvName = self.ui.venvComboBox.currentText() |
178 venvName = self.ui.venvComboBox.currentText() |
179 Public method to retrieve the debug related data entered into this |
191 Public method to retrieve the debug related data entered into this |
180 dialog. |
192 dialog. |
181 |
193 |
182 @return a tuple of a flag indicating, if the Python library should be |
194 @return a tuple of a flag indicating, if the Python library should be |
183 traced as well, a flag indicating, that the debugger should not |
195 traced as well, a flag indicating, that the debugger should not |
184 stop at the first executable line (boolean), a flag indicating, |
196 stop at the first executable line, a flag indicating to support |
185 that the debugger should fork automatically (boolean) and a flag |
197 multi process debugging and a space separated list of programs not |
186 indicating, that the debugger should debug the child process after |
198 to be debugged |
187 forking automatically (boolean) |
199 @rtype tuple of (bool, bool, bool, str) |
188 """ |
200 """ |
189 if self.dialogType == 0: |
201 if self.dialogType == 0: |
190 return (self.ui.tracePythonCheckBox.isChecked(), |
202 return (self.ui.tracePythonCheckBox.isChecked(), |
191 self.ui.autoContinueCheckBox.isChecked(), |
203 self.ui.autoContinueCheckBox.isChecked(), |
192 self.ui.forkModeCheckBox.isChecked(), |
204 self.ui.multiprocessGroup.isChecked(), |
193 self.ui.forkChildCheckBox.isChecked()) |
205 self.ui.multiprocessNoDebugCombo.currentText()) |
194 else: |
206 else: |
195 return (False, False, False, False) |
207 return (False, False, False, "") |
196 |
208 |
197 def getRunData(self): |
|
198 """ |
|
199 Public method to retrieve the debug related data entered into this |
|
200 dialog. |
|
201 |
|
202 @return a tuple of a flag indicating, that the debugger should fork |
|
203 automatically (boolean) and a flag indicating, that the debugger |
|
204 should debug the child process after forking automatically |
|
205 (boolean) |
|
206 """ |
|
207 if self.dialogType == 1: |
|
208 return (self.ui.forkModeCheckBox.isChecked(), |
|
209 self.ui.forkChildCheckBox.isChecked()) |
|
210 else: |
|
211 return (False, False) |
|
212 |
|
213 def getCoverageData(self): |
209 def getCoverageData(self): |
214 """ |
210 """ |
215 Public method to retrieve the coverage related data entered into this |
211 Public method to retrieve the coverage related data entered into this |
216 dialog. |
212 dialog. |
217 |
213 |
218 @return flag indicating erasure of coverage info (boolean) |
214 @return flag indicating erasure of coverage info |
|
215 @rtype bool |
219 """ |
216 """ |
220 if self.dialogType == 2: |
217 if self.dialogType == 2: |
221 return self.ui.eraseCheckBox.isChecked() |
218 return self.ui.eraseCheckBox.isChecked() |
222 else: |
219 else: |
223 return False |
220 return False |
251 self.ui.environmentCombo.clear() |
249 self.ui.environmentCombo.clear() |
252 |
250 |
253 self.ui.cmdlineCombo.addItem(cmdLine) |
251 self.ui.cmdlineCombo.addItem(cmdLine) |
254 self.ui.workdirPicker.addItem(workdir) |
252 self.ui.workdirPicker.addItem(workdir) |
255 self.ui.environmentCombo.addItem(environment) |
253 self.ui.environmentCombo.addItem(environment) |
|
254 |
|
255 if self.dialogType == 0: |
|
256 noDebugList = self.ui.multiprocessNoDebugCombo.currentText() |
|
257 self.ui.multiprocessNoDebugCombo.clear() |
|
258 self.ui.multiprocessNoDebugCombo.addItem(noDebugList) |
256 |
259 |
257 def __editHistory(self): |
260 def __editHistory(self): |
258 """ |
261 """ |
259 Private slot to edit a history list. |
262 Private slot to edit a history list. |
260 """ |
263 """ |
262 "", |
265 "", |
263 self.tr("Command Line"), |
266 self.tr("Command Line"), |
264 self.tr("Working Directory"), |
267 self.tr("Working Directory"), |
265 self.tr("Environment"), |
268 self.tr("Environment"), |
266 ] |
269 ] |
|
270 combos = [ |
|
271 None, |
|
272 self.ui.cmdlineCombo, |
|
273 self.ui.workdirPicker, |
|
274 self.ui.environmentCombo, |
|
275 ] |
|
276 if self.dialogType == 0: |
|
277 histories.append(self.tr("No Debug Programs")) |
|
278 combos.append(self.ui.multiprocessNoDebugCombo) |
267 historyKind, ok = QInputDialog.getItem( |
279 historyKind, ok = QInputDialog.getItem( |
268 self, |
280 self, |
269 self.tr("Edit History"), |
281 self.tr("Edit History"), |
270 self.tr("Select the history list to be edited:"), |
282 self.tr("Select the history list to be edited:"), |
271 histories, |
283 histories, |
272 0, False) |
284 0, False) |
273 if ok and historyKind: |
285 if ok and historyKind: |
|
286 history = [] |
274 historiesIndex = histories.index(historyKind) |
287 historiesIndex = histories.index(historyKind) |
275 if historiesIndex == 2: |
288 if historiesIndex == 2: |
276 history = self.ui.workdirPicker.getPathItems() |
289 history = self.ui.workdirPicker.getPathItems() |
277 else: |
290 else: |
278 history = [] |
291 combo = combos[historiesIndex] |
279 if historiesIndex == 1: |
292 if combo: |
280 combo = self.ui.cmdlineCombo |
293 for index in range(combo.count()): |
281 else: |
294 history.append(combo.itemText(index)) |
282 combo = self.ui.environmentCombo |
|
283 for index in range(combo.count()): |
|
284 history.append(combo.itemText(index)) |
|
285 |
295 |
286 from .StartHistoryEditDialog import StartHistoryEditDialog |
296 if history: |
287 dlg = StartHistoryEditDialog(history, self) |
297 from .StartHistoryEditDialog import StartHistoryEditDialog |
|
298 dlg = StartHistoryEditDialog(history, self) |
288 if dlg.exec() == QDialog.Accepted: |
299 if dlg.exec() == QDialog.Accepted: |
289 history = dlg.getHistory() |
300 history = dlg.getHistory() |
290 if historiesIndex == 1: |
301 combo = combos[historiesIndex] |
291 combo = self.ui.cmdlineCombo |
302 if combo: |
292 elif historiesIndex == 2: |
303 combo.clear() |
293 combo = self.ui.workdirPicker |
304 combo.addItems(history) |
294 else: |
305 |
295 combo = self.ui.environmentCombo |
306 self.__historiesModified = True |
296 combo.clear() |
|
297 combo.addItems(history) |
|
298 |
|
299 self.__historiesModified = True |
|
300 |
307 |
301 def historiesModified(self): |
308 def historiesModified(self): |
302 """ |
309 """ |
303 Public method to test for modified histories. |
310 Public method to test for modified histories. |
304 |
311 |
319 def getHistories(self): |
326 def getHistories(self): |
320 """ |
327 """ |
321 Public method to get the lists of histories. |
328 Public method to get the lists of histories. |
322 |
329 |
323 @return tuple containing the histories of command line arguments, |
330 @return tuple containing the histories of command line arguments, |
324 working directories, environment settings and interpreters |
331 working directories, environment settings and no debug programs |
|
332 lists |
325 @rtype tuple of four list of str |
333 @rtype tuple of four list of str |
326 """ |
334 """ |
|
335 if self.dialogType == 0: |
|
336 noDebugHistory = [ |
|
337 self.ui.multiprocessNoDebugCombo.itemText(index) |
|
338 for index in range(self.ui.multiprocessNoDebugCombo.count()) |
|
339 ] |
|
340 else: |
|
341 noDebugHistory = None |
327 return ( |
342 return ( |
328 [self.ui.cmdlineCombo.itemText(index) for index in range( |
343 [self.ui.cmdlineCombo.itemText(index) for index in range( |
329 self.ui.cmdlineCombo.count())], |
344 self.ui.cmdlineCombo.count())], |
330 self.ui.workdirPicker.getPathItems(), |
345 self.ui.workdirPicker.getPathItems(), |
331 [self.ui.environmentCombo.itemText(index) for index in range( |
346 [self.ui.environmentCombo.itemText(index) for index in range( |
332 self.ui.environmentCombo.count())], |
347 self.ui.environmentCombo.count())], |
|
348 noDebugHistory, |
333 ) |
349 ) |
334 |
350 |
335 def on_buttonBox_clicked(self, button): |
351 def on_buttonBox_clicked(self, button): |
336 """ |
352 """ |
337 Private slot called by a button of the button box clicked. |
353 Private slot called by a button of the button box clicked. |
338 |
354 |
339 @param button button that was clicked (QAbstractButton) |
355 @param button button that was clicked |
|
356 @type QAbstractButton |
340 """ |
357 """ |
341 if button == self.clearButton: |
358 if button == self.clearButton: |
342 self.__clearHistories() |
359 self.__clearHistories() |
343 elif button == self.editButton: |
360 elif button == self.editButton: |
344 self.__editHistory() |
361 self.__editHistory() |