10 import os |
10 import os |
11 import re |
11 import re |
12 import shutil |
12 import shutil |
13 import contextlib |
13 import contextlib |
14 |
14 |
15 from PyQt5.QtCore import QObject, QTimer, QUrl, QFileInfo |
15 from PyQt6.QtCore import QObject, QTimer, QUrl, QFileInfo, QIODeviceBase |
16 from PyQt5.QtGui import QDesktopServices |
16 from PyQt6.QtGui import QDesktopServices |
17 from PyQt5.QtWidgets import QMenu, QInputDialog, QLineEdit, QDialog |
17 from PyQt6.QtWidgets import QMenu, QInputDialog, QLineEdit, QDialog |
18 from PyQt5.QtCore import QProcess as QProcessPyQt |
18 from PyQt6.QtCore import QProcess as QProcessPyQt |
19 |
19 |
20 from E5Gui.E5Application import e5App |
20 from EricWidgets.EricApplication import ericApp |
21 from E5Gui import E5MessageBox, E5FileDialog |
21 from EricWidgets import EricMessageBox, EricFileDialog |
22 from E5Gui.E5Action import E5Action |
22 from EricGui.EricAction import EricAction |
23 |
23 |
24 from Globals import isWindowsPlatform |
24 from Globals import isWindowsPlatform |
25 |
25 |
26 from .DjangoDialog import DjangoDialog |
26 from .DjangoDialog import DjangoDialog |
27 |
27 |
39 |
39 |
40 class QProcess(QProcessPyQt): |
40 class QProcess(QProcessPyQt): |
41 """ |
41 """ |
42 Class transforming the call arguments in case of gnome-terminal. |
42 Class transforming the call arguments in case of gnome-terminal. |
43 """ |
43 """ |
44 def start(self, cmd, args=None, mode=QProcessPyQt.ReadWrite): |
44 def start(self, cmd, args=None, mode=QIODeviceBase.OpenModeFlag.ReadWrite): |
45 """ |
45 """ |
46 Public method to start the given program (cmd) in a new process, if |
46 Public method to start the given program (cmd) in a new process, if |
47 none is already running, passing the command line arguments in args. |
47 none is already running, passing the command line arguments in args. |
48 |
48 |
49 @param cmd start the given program cmd (string) |
49 @param cmd start the given program cmd |
50 @keyparam args list of parameters (list of strings) |
50 @type str |
51 @keyparam mode access mode (QIODevice.OpenMode) |
51 @param args list of parameters |
|
52 @type list of str |
|
53 @param mode access mode |
|
54 @type QIODeviceBase.OpenMode |
52 """ |
55 """ |
53 if args is None: |
56 if args is None: |
54 args = [] |
57 args = [] |
55 |
58 |
56 if ( |
59 if ( |
68 def startDetached(cmd, args=None, path=''): |
71 def startDetached(cmd, args=None, path=''): |
69 """ |
72 """ |
70 Public static method to start the given program (cmd) in a new process, |
73 Public static method to start the given program (cmd) in a new process, |
71 if none is already running, passing the command line arguments in args. |
74 if none is already running, passing the command line arguments in args. |
72 |
75 |
73 @param cmd start the given program cmd (string) |
76 @param cmd start the given program cmd |
74 @keyparam args list of parameters (list of strings) |
77 @type str |
75 @keyparam path new working directory (string) |
78 @param args list of parameters |
76 @return tuple of successful start and process id (boolean, integer) |
79 @type list of str |
|
80 @param path new working directory |
|
81 @type str |
|
82 @return tuple of successful start and process id |
|
83 @rtype tuple of (bool, int) |
77 """ |
84 """ |
78 if args is None: |
85 if args is None: |
79 args = [] |
86 args = [] |
80 |
87 |
81 if ( |
88 if ( |
112 |
119 |
113 self.__plugin = plugin |
120 self.__plugin = plugin |
114 self.__iconSuffix = iconSuffix |
121 self.__iconSuffix = iconSuffix |
115 self.__ui = parent |
122 self.__ui = parent |
116 |
123 |
117 self.__e5project = e5App().getObject("Project") |
124 self.__ericProject = ericApp().getObject("Project") |
118 self.__virtualEnvManager = e5App().getObject("VirtualEnvManager") |
125 self.__virtualEnvManager = ericApp().getObject("VirtualEnvManager") |
119 self.__hooksInstalled = False |
126 self.__hooksInstalled = False |
120 |
127 |
121 self.__menus = {} # dictionary with references to menus |
128 self.__menus = {} # dictionary with references to menus |
122 |
129 |
123 self.__serverProc = None |
130 self.__serverProc = None |
160 |
167 |
161 ############################## |
168 ############################## |
162 ## start actions below ## |
169 ## start actions below ## |
163 ############################## |
170 ############################## |
164 |
171 |
165 self.startProjectAct = E5Action( |
172 self.startProjectAct = EricAction( |
166 self.tr('Start Project'), |
173 self.tr('Start Project'), |
167 self.tr('Start &Project'), |
174 self.tr('Start &Project'), |
168 0, 0, |
175 0, 0, |
169 self, 'django_start_project') |
176 self, 'django_start_project') |
170 self.startProjectAct.setStatusTip(self.tr( |
177 self.startProjectAct.setStatusTip(self.tr( |
175 """ startproject".</p>""" |
182 """ startproject".</p>""" |
176 )) |
183 )) |
177 self.startProjectAct.triggered.connect(self.__startProject) |
184 self.startProjectAct.triggered.connect(self.__startProject) |
178 self.actions.append(self.startProjectAct) |
185 self.actions.append(self.startProjectAct) |
179 |
186 |
180 self.startGlobalApplicationAct = E5Action( |
187 self.startGlobalApplicationAct = EricAction( |
181 self.tr('Start Application (global)'), |
188 self.tr('Start Application (global)'), |
182 self.tr('Start Application (&global)'), |
189 self.tr('Start Application (&global)'), |
183 0, 0, |
190 0, 0, |
184 self, 'django_start_global_application') |
191 self, 'django_start_global_application') |
185 self.startGlobalApplicationAct.setStatusTip(self.tr( |
192 self.startGlobalApplicationAct.setStatusTip(self.tr( |
191 )) |
198 )) |
192 self.startGlobalApplicationAct.triggered.connect( |
199 self.startGlobalApplicationAct.triggered.connect( |
193 self.__startGlobalApplication) |
200 self.__startGlobalApplication) |
194 self.actions.append(self.startGlobalApplicationAct) |
201 self.actions.append(self.startGlobalApplicationAct) |
195 |
202 |
196 self.startLocalApplicationAct = E5Action( |
203 self.startLocalApplicationAct = EricAction( |
197 self.tr('Start Application (local)'), |
204 self.tr('Start Application (local)'), |
198 self.tr('Start Application (&local)'), |
205 self.tr('Start Application (&local)'), |
199 0, 0, |
206 0, 0, |
200 self, 'django_start_local_application') |
207 self, 'django_start_local_application') |
201 self.startLocalApplicationAct.setStatusTip(self.tr( |
208 self.startLocalApplicationAct.setStatusTip(self.tr( |
211 |
218 |
212 ############################## |
219 ############################## |
213 ## run actions below ## |
220 ## run actions below ## |
214 ############################## |
221 ############################## |
215 |
222 |
216 self.runServerAct = E5Action( |
223 self.runServerAct = EricAction( |
217 self.tr('Run Server'), |
224 self.tr('Run Server'), |
218 self.tr('Run &Server'), |
225 self.tr('Run &Server'), |
219 0, 0, |
226 0, 0, |
220 self, 'django_run_server') |
227 self, 'django_run_server') |
221 self.runServerAct.setStatusTip(self.tr( |
228 self.runServerAct.setStatusTip(self.tr( |
226 """ runserver".</p>""" |
233 """ runserver".</p>""" |
227 )) |
234 )) |
228 self.runServerAct.triggered.connect(self.__runServer) |
235 self.runServerAct.triggered.connect(self.__runServer) |
229 self.actions.append(self.runServerAct) |
236 self.actions.append(self.runServerAct) |
230 |
237 |
231 self.runBrowserAct = E5Action( |
238 self.runBrowserAct = EricAction( |
232 self.tr('Run Web-Browser'), |
239 self.tr('Run Web-Browser'), |
233 self.tr('Run &Web-Browser'), |
240 self.tr('Run &Web-Browser'), |
234 0, 0, |
241 0, 0, |
235 self, 'django_run_browser') |
242 self, 'django_run_browser') |
236 self.runBrowserAct.setStatusTip(self.tr( |
243 self.runBrowserAct.setStatusTip(self.tr( |
246 |
253 |
247 ############################## |
254 ############################## |
248 ## caching actions below ## |
255 ## caching actions below ## |
249 ############################## |
256 ############################## |
250 |
257 |
251 self.createCacheTableAct = E5Action( |
258 self.createCacheTableAct = EricAction( |
252 self.tr('Create Cache Tables'), |
259 self.tr('Create Cache Tables'), |
253 self.tr('C&reate Cache Tables'), |
260 self.tr('C&reate Cache Tables'), |
254 0, 0, |
261 0, 0, |
255 self, 'django_create_cache_tables') |
262 self, 'django_create_cache_tables') |
256 self.createCacheTableAct.setStatusTip(self.tr( |
263 self.createCacheTableAct.setStatusTip(self.tr( |
284 |
291 |
285 ############################## |
292 ############################## |
286 ## about action below ## |
293 ## about action below ## |
287 ############################## |
294 ############################## |
288 |
295 |
289 self.aboutDjangoAct = E5Action( |
296 self.aboutDjangoAct = EricAction( |
290 self.tr('About Django'), |
297 self.tr('About Django'), |
291 self.tr('About D&jango'), |
298 self.tr('About D&jango'), |
292 0, 0, |
299 0, 0, |
293 self, 'django_about') |
300 self, 'django_about') |
294 self.aboutDjangoAct.setStatusTip(self.tr( |
301 self.aboutDjangoAct.setStatusTip(self.tr( |
302 |
309 |
303 ############################## |
310 ############################## |
304 ## check action below ## |
311 ## check action below ## |
305 ############################## |
312 ############################## |
306 |
313 |
307 self.checkAct = E5Action( |
314 self.checkAct = EricAction( |
308 self.tr('Check Project'), |
315 self.tr('Check Project'), |
309 self.tr('Check Project'), |
316 self.tr('Check Project'), |
310 0, 0, |
317 0, 0, |
311 self, 'django_check_project') |
318 self, 'django_check_project') |
312 self.checkAct.setStatusTip(self.tr( |
319 self.checkAct.setStatusTip(self.tr( |
345 )) |
352 )) |
346 self.selectDatabaseNameAct.triggered.connect(self.__selectDatabaseName) |
353 self.selectDatabaseNameAct.triggered.connect(self.__selectDatabaseName) |
347 self.actions.append(self.selectDatabaseNameAct) |
354 self.actions.append(self.selectDatabaseNameAct) |
348 self.__setCurrentDatabase(None) |
355 self.__setCurrentDatabase(None) |
349 |
356 |
350 self.inspectDatabaseAct = E5Action( |
357 self.inspectDatabaseAct = EricAction( |
351 self.tr('Introspect'), |
358 self.tr('Introspect'), |
352 self.tr('&Introspect'), |
359 self.tr('&Introspect'), |
353 0, 0, |
360 0, 0, |
354 self, 'django_database_inspect') |
361 self, 'django_database_inspect') |
355 self.inspectDatabaseAct.setStatusTip(self.tr( |
362 self.inspectDatabaseAct.setStatusTip(self.tr( |
377 """just after their installation.</p>""" |
384 """just after their installation.</p>""" |
378 )) |
385 )) |
379 self.flushDatabaseAct.triggered.connect(self.__databaseFlush) |
386 self.flushDatabaseAct.triggered.connect(self.__databaseFlush) |
380 self.actions.append(self.flushDatabaseAct) |
387 self.actions.append(self.flushDatabaseAct) |
381 |
388 |
382 self.databaseClientAct = E5Action( |
389 self.databaseClientAct = EricAction( |
383 self.tr('Start Client Console'), |
390 self.tr('Start Client Console'), |
384 self.tr('Start &Client Console'), |
391 self.tr('Start &Client Console'), |
385 0, 0, |
392 0, 0, |
386 self, 'django_database_client') |
393 self, 'django_database_client') |
387 self.databaseClientAct.setStatusTip(self.tr( |
394 self.databaseClientAct.setStatusTip(self.tr( |
395 |
402 |
396 def __initDatabaseSqlActions(self): |
403 def __initDatabaseSqlActions(self): |
397 """ |
404 """ |
398 Private method to define the database SQL related actions. |
405 Private method to define the database SQL related actions. |
399 """ |
406 """ |
400 self.databaseSqlFlushAct = E5Action( |
407 self.databaseSqlFlushAct = EricAction( |
401 self.tr('Flush Database'), |
408 self.tr('Flush Database'), |
402 self.tr('&Flush Database'), |
409 self.tr('&Flush Database'), |
403 0, 0, |
410 0, 0, |
404 self, 'django_database_sql_flush_database') |
411 self, 'django_database_sql_flush_database') |
405 self.databaseSqlFlushAct.setStatusTip(self.tr( |
412 self.databaseSqlFlushAct.setStatusTip(self.tr( |
412 )) |
419 )) |
413 self.databaseSqlFlushAct.triggered.connect( |
420 self.databaseSqlFlushAct.triggered.connect( |
414 self.__databaseSqlFlushDatabase) |
421 self.__databaseSqlFlushDatabase) |
415 self.actions.append(self.databaseSqlFlushAct) |
422 self.actions.append(self.databaseSqlFlushAct) |
416 |
423 |
417 self.databaseSqlResetSeqAct = E5Action( |
424 self.databaseSqlResetSeqAct = EricAction( |
418 self.tr('Reset Sequences'), |
425 self.tr('Reset Sequences'), |
419 self.tr('Reset &Sequences'), |
426 self.tr('Reset &Sequences'), |
420 0, 0, |
427 0, 0, |
421 self, 'django_database_sql_reset_sequences') |
428 self, 'django_database_sql_reset_sequences') |
422 self.databaseSqlResetSeqAct.setStatusTip(self.tr( |
429 self.databaseSqlResetSeqAct.setStatusTip(self.tr( |
429 )) |
436 )) |
430 self.databaseSqlResetSeqAct.triggered.connect( |
437 self.databaseSqlResetSeqAct.triggered.connect( |
431 self.__databaseSqlResetSequences) |
438 self.__databaseSqlResetSequences) |
432 self.actions.append(self.databaseSqlResetSeqAct) |
439 self.actions.append(self.databaseSqlResetSeqAct) |
433 |
440 |
434 self.databaseSqlMigrateAct = E5Action( |
441 self.databaseSqlMigrateAct = EricAction( |
435 self.tr('Apply Migration'), |
442 self.tr('Apply Migration'), |
436 self.tr('&Apply Migration'), |
443 self.tr('&Apply Migration'), |
437 0, 0, |
444 0, 0, |
438 self, 'django_database_sql_apply_migration') |
445 self, 'django_database_sql_apply_migration') |
439 self.databaseSqlMigrateAct.setStatusTip(self.tr( |
446 self.databaseSqlMigrateAct.setStatusTip(self.tr( |
446 )) |
453 )) |
447 self.databaseSqlMigrateAct.triggered.connect( |
454 self.databaseSqlMigrateAct.triggered.connect( |
448 self.__databaseSqlMigrate) |
455 self.__databaseSqlMigrate) |
449 self.actions.append(self.databaseSqlMigrateAct) |
456 self.actions.append(self.databaseSqlMigrateAct) |
450 |
457 |
451 self.databaseSqlMigrateBackwardsAct = E5Action( |
458 self.databaseSqlMigrateBackwardsAct = EricAction( |
452 self.tr('Unapply Migration'), |
459 self.tr('Unapply Migration'), |
453 self.tr('&Unapply Migration'), |
460 self.tr('&Unapply Migration'), |
454 0, 0, |
461 0, 0, |
455 self, 'django_database_sql_unapply_migration') |
462 self, 'django_database_sql_unapply_migration') |
456 self.databaseSqlMigrateBackwardsAct.setStatusTip(self.tr( |
463 self.databaseSqlMigrateBackwardsAct.setStatusTip(self.tr( |
467 |
474 |
468 def __initToolsActions(self): |
475 def __initToolsActions(self): |
469 """ |
476 """ |
470 Private method to define the tool actions. |
477 Private method to define the tool actions. |
471 """ |
478 """ |
472 self.diffSettingsAct = E5Action( |
479 self.diffSettingsAct = EricAction( |
473 self.tr('Diff Settings'), |
480 self.tr('Diff Settings'), |
474 self.tr('&Diff Settings'), |
481 self.tr('&Diff Settings'), |
475 0, 0, |
482 0, 0, |
476 self, 'django_tools_diffsettings') |
483 self, 'django_tools_diffsettings') |
477 self.diffSettingsAct.setStatusTip(self.tr( |
484 self.diffSettingsAct.setStatusTip(self.tr( |
481 """<p>Shows the modification made to the settings.</p>""" |
488 """<p>Shows the modification made to the settings.</p>""" |
482 )) |
489 )) |
483 self.diffSettingsAct.triggered.connect(self.__diffSettings) |
490 self.diffSettingsAct.triggered.connect(self.__diffSettings) |
484 self.actions.append(self.diffSettingsAct) |
491 self.actions.append(self.diffSettingsAct) |
485 |
492 |
486 self.runPythonShellAct = E5Action( |
493 self.runPythonShellAct = EricAction( |
487 self.tr('Start Python Console'), |
494 self.tr('Start Python Console'), |
488 self.tr('Start &Python Console'), |
495 self.tr('Start &Python Console'), |
489 0, 0, |
496 0, 0, |
490 self, 'django_tools_pythonconsole') |
497 self, 'django_tools_pythonconsole') |
491 self.runPythonShellAct.setStatusTip(self.tr( |
498 self.runPythonShellAct.setStatusTip(self.tr( |
495 """<p>Starts a Python interactive interpreter.</p>""" |
502 """<p>Starts a Python interactive interpreter.</p>""" |
496 )) |
503 )) |
497 self.runPythonShellAct.triggered.connect(self.__runPythonShell) |
504 self.runPythonShellAct.triggered.connect(self.__runPythonShell) |
498 self.actions.append(self.runPythonShellAct) |
505 self.actions.append(self.runPythonShellAct) |
499 |
506 |
500 self.testEmailAct = E5Action( |
507 self.testEmailAct = EricAction( |
501 self.tr('Send Test Email'), |
508 self.tr('Send Test Email'), |
502 self.tr('Send Test &Email'), |
509 self.tr('Send Test &Email'), |
503 0, 0, |
510 0, 0, |
504 self, 'django_tools_sendtestemail') |
511 self, 'django_tools_sendtestemail') |
505 self.testEmailAct.setStatusTip(self.tr( |
512 self.testEmailAct.setStatusTip(self.tr( |
514 |
521 |
515 def __initTestingActions(self): |
522 def __initTestingActions(self): |
516 """ |
523 """ |
517 Private method to define the testing actions. |
524 Private method to define the testing actions. |
518 """ |
525 """ |
519 self.dumpDataAct = E5Action( |
526 self.dumpDataAct = EricAction( |
520 self.tr('Dump Data'), |
527 self.tr('Dump Data'), |
521 self.tr('&Dump Data'), |
528 self.tr('&Dump Data'), |
522 0, 0, |
529 0, 0, |
523 self, 'django_tools_dumpdata') |
530 self, 'django_tools_dumpdata') |
524 self.dumpDataAct.setStatusTip(self.tr( |
531 self.dumpDataAct.setStatusTip(self.tr( |
528 """<p>Dump the database data to a fixture.</p>""" |
535 """<p>Dump the database data to a fixture.</p>""" |
529 )) |
536 )) |
530 self.dumpDataAct.triggered.connect(self.__dumpData) |
537 self.dumpDataAct.triggered.connect(self.__dumpData) |
531 self.actions.append(self.dumpDataAct) |
538 self.actions.append(self.dumpDataAct) |
532 |
539 |
533 self.loadDataAct = E5Action( |
540 self.loadDataAct = EricAction( |
534 self.tr('Load Data'), |
541 self.tr('Load Data'), |
535 self.tr('&Load Data'), |
542 self.tr('&Load Data'), |
536 0, 0, |
543 0, 0, |
537 self, 'django_tools_loaddata') |
544 self, 'django_tools_loaddata') |
538 self.loadDataAct.setStatusTip(self.tr( |
545 self.loadDataAct.setStatusTip(self.tr( |
542 """<p>Load data from fixture files.</p>""" |
549 """<p>Load data from fixture files.</p>""" |
543 )) |
550 )) |
544 self.loadDataAct.triggered.connect(self.__loadData) |
551 self.loadDataAct.triggered.connect(self.__loadData) |
545 self.actions.append(self.loadDataAct) |
552 self.actions.append(self.loadDataAct) |
546 |
553 |
547 self.runTestAct = E5Action( |
554 self.runTestAct = EricAction( |
548 self.tr('Run Testsuite'), |
555 self.tr('Run Testsuite'), |
549 self.tr('Run &Testsuite'), |
556 self.tr('Run &Testsuite'), |
550 0, 0, |
557 0, 0, |
551 self, 'django_tools_run_test') |
558 self, 'django_tools_run_test') |
552 self.runTestAct.setStatusTip(self.tr( |
559 self.runTestAct.setStatusTip(self.tr( |
556 """<p>Run the test suite for applications or the whole site.</p>""" |
563 """<p>Run the test suite for applications or the whole site.</p>""" |
557 )) |
564 )) |
558 self.runTestAct.triggered.connect(self.__runTestSuite) |
565 self.runTestAct.triggered.connect(self.__runTestSuite) |
559 self.actions.append(self.runTestAct) |
566 self.actions.append(self.runTestAct) |
560 |
567 |
561 self.runDeprecationTestAct = E5Action( |
568 self.runDeprecationTestAct = EricAction( |
562 self.tr('Run Testsuite (-Wall)'), |
569 self.tr('Run Testsuite (-Wall)'), |
563 self.tr('Run Testsuite (-Wall)'), |
570 self.tr('Run Testsuite (-Wall)'), |
564 0, 0, |
571 0, 0, |
565 self, 'django_tools_run_deprecation_test') |
572 self, 'django_tools_run_deprecation_test') |
566 self.runDeprecationTestAct.setStatusTip(self.tr( |
573 self.runDeprecationTestAct.setStatusTip(self.tr( |
573 )) |
580 )) |
574 self.runDeprecationTestAct.triggered.connect( |
581 self.runDeprecationTestAct.triggered.connect( |
575 lambda: self.__runTestSuite(deprecation=True)) |
582 lambda: self.__runTestSuite(deprecation=True)) |
576 self.actions.append(self.runDeprecationTestAct) |
583 self.actions.append(self.runDeprecationTestAct) |
577 |
584 |
578 self.runTestServerAct = E5Action( |
585 self.runTestServerAct = EricAction( |
579 self.tr('Run Testserver'), |
586 self.tr('Run Testserver'), |
580 self.tr('Run Test&server'), |
587 self.tr('Run Test&server'), |
581 0, 0, |
588 0, 0, |
582 self, 'django_tools_run_test_server') |
589 self, 'django_tools_run_test_server') |
583 self.runTestServerAct.setStatusTip(self.tr( |
590 self.runTestServerAct.setStatusTip(self.tr( |
592 |
599 |
593 def __initAuthorizationActions(self): |
600 def __initAuthorizationActions(self): |
594 """ |
601 """ |
595 Private method to define the authorization actions. |
602 Private method to define the authorization actions. |
596 """ |
603 """ |
597 self.changePasswordAct = E5Action( |
604 self.changePasswordAct = EricAction( |
598 self.tr('Change Password'), |
605 self.tr('Change Password'), |
599 self.tr('Change &Password'), |
606 self.tr('Change &Password'), |
600 0, 0, |
607 0, 0, |
601 self, 'django_auth_changepassword') |
608 self, 'django_auth_changepassword') |
602 self.changePasswordAct.setStatusTip(self.tr( |
609 self.changePasswordAct.setStatusTip(self.tr( |
606 """<p>Change the password of a user of the Django project.</p>""" |
613 """<p>Change the password of a user of the Django project.</p>""" |
607 )) |
614 )) |
608 self.changePasswordAct.triggered.connect(self.__changePassword) |
615 self.changePasswordAct.triggered.connect(self.__changePassword) |
609 self.actions.append(self.changePasswordAct) |
616 self.actions.append(self.changePasswordAct) |
610 |
617 |
611 self.createSuperUserAct = E5Action( |
618 self.createSuperUserAct = EricAction( |
612 self.tr('Create Superuser'), |
619 self.tr('Create Superuser'), |
613 self.tr('Create &Superuser'), |
620 self.tr('Create &Superuser'), |
614 0, 0, |
621 0, 0, |
615 self, 'django_auth_createsuperuser') |
622 self, 'django_auth_createsuperuser') |
616 self.createSuperUserAct.setStatusTip(self.tr( |
623 self.createSuperUserAct.setStatusTip(self.tr( |
624 |
631 |
625 def __initSessionActions(self): |
632 def __initSessionActions(self): |
626 """ |
633 """ |
627 Private method to define the session actions. |
634 Private method to define the session actions. |
628 """ |
635 """ |
629 self.clearSessionsAct = E5Action( |
636 self.clearSessionsAct = EricAction( |
630 self.tr('Clear Sessions'), |
637 self.tr('Clear Sessions'), |
631 self.tr('Clear &Sessions'), |
638 self.tr('Clear &Sessions'), |
632 0, 0, |
639 0, 0, |
633 self, 'django_session_clearsessions') |
640 self, 'django_session_clearsessions') |
634 self.clearSessionsAct.setStatusTip(self.tr( |
641 self.clearSessionsAct.setStatusTip(self.tr( |
642 |
649 |
643 def __initMigrationActions(self): |
650 def __initMigrationActions(self): |
644 """ |
651 """ |
645 Private method to define the migration actions. |
652 Private method to define the migration actions. |
646 """ |
653 """ |
647 self.showMigrationsAct = E5Action( |
654 self.showMigrationsAct = EricAction( |
648 self.tr('Show Migrations'), |
655 self.tr('Show Migrations'), |
649 self.tr('&Show Migrations'), |
656 self.tr('&Show Migrations'), |
650 0, 0, |
657 0, 0, |
651 self, 'django_migration_show') |
658 self, 'django_migration_show') |
652 self.showMigrationsAct.setStatusTip(self.tr( |
659 self.showMigrationsAct.setStatusTip(self.tr( |
657 """ project and their status.</p>""" |
664 """ project and their status.</p>""" |
658 )) |
665 )) |
659 self.showMigrationsAct.triggered.connect(self.__showMigrationsList) |
666 self.showMigrationsAct.triggered.connect(self.__showMigrationsList) |
660 self.actions.append(self.showMigrationsAct) |
667 self.actions.append(self.showMigrationsAct) |
661 |
668 |
662 self.showMigrationsPlanAct = E5Action( |
669 self.showMigrationsPlanAct = EricAction( |
663 self.tr('Show Migrations Plan'), |
670 self.tr('Show Migrations Plan'), |
664 self.tr('Show Migrations &Plan'), |
671 self.tr('Show Migrations &Plan'), |
665 0, 0, |
672 0, 0, |
666 self, 'django_migration_show_plan') |
673 self, 'django_migration_show_plan') |
667 self.showMigrationsPlanAct.setStatusTip(self.tr( |
674 self.showMigrationsPlanAct.setStatusTip(self.tr( |
672 """ project.</p>""" |
679 """ project.</p>""" |
673 )) |
680 )) |
674 self.showMigrationsPlanAct.triggered.connect(self.__showMigrationsPlan) |
681 self.showMigrationsPlanAct.triggered.connect(self.__showMigrationsPlan) |
675 self.actions.append(self.showMigrationsPlanAct) |
682 self.actions.append(self.showMigrationsPlanAct) |
676 |
683 |
677 self.migrateAllAct = E5Action( |
684 self.migrateAllAct = EricAction( |
678 self.tr('Apply All Migrations'), |
685 self.tr('Apply All Migrations'), |
679 self.tr('&Apply All Migrations'), |
686 self.tr('&Apply All Migrations'), |
680 0, 0, |
687 0, 0, |
681 self, 'django_migration_apply_all') |
688 self, 'django_migration_apply_all') |
682 self.migrateAllAct.setStatusTip(self.tr( |
689 self.migrateAllAct.setStatusTip(self.tr( |
686 """<p>This applies all migrations of the Django project.</p>""" |
693 """<p>This applies all migrations of the Django project.</p>""" |
687 )) |
694 )) |
688 self.migrateAllAct.triggered.connect(self.__applyAllMigrations) |
695 self.migrateAllAct.triggered.connect(self.__applyAllMigrations) |
689 self.actions.append(self.migrateAllAct) |
696 self.actions.append(self.migrateAllAct) |
690 |
697 |
691 self.migrateSelectedAct = E5Action( |
698 self.migrateSelectedAct = EricAction( |
692 self.tr('Apply Selected Migrations'), |
699 self.tr('Apply Selected Migrations'), |
693 self.tr('Apply Selected Migrations'), |
700 self.tr('Apply Selected Migrations'), |
694 0, 0, |
701 0, 0, |
695 self, 'django_migration_apply_selected') |
702 self, 'django_migration_apply_selected') |
696 self.migrateSelectedAct.setStatusTip(self.tr( |
703 self.migrateSelectedAct.setStatusTip(self.tr( |
702 )) |
709 )) |
703 self.migrateSelectedAct.triggered.connect( |
710 self.migrateSelectedAct.triggered.connect( |
704 self.__applySelectedMigrations) |
711 self.__applySelectedMigrations) |
705 self.actions.append(self.migrateSelectedAct) |
712 self.actions.append(self.migrateSelectedAct) |
706 |
713 |
707 self.unmigrateAct = E5Action( |
714 self.unmigrateAct = EricAction( |
708 self.tr('Unapply Migrations'), |
715 self.tr('Unapply Migrations'), |
709 self.tr('&Unapply Migrations'), |
716 self.tr('&Unapply Migrations'), |
710 0, 0, |
717 0, 0, |
711 self, 'django_migration_unapply') |
718 self, 'django_migration_unapply') |
712 self.unmigrateAct.setStatusTip(self.tr( |
719 self.unmigrateAct.setStatusTip(self.tr( |
717 """ project.</p>""" |
724 """ project.</p>""" |
718 )) |
725 )) |
719 self.unmigrateAct.triggered.connect(self.__unapplyMigrations) |
726 self.unmigrateAct.triggered.connect(self.__unapplyMigrations) |
720 self.actions.append(self.unmigrateAct) |
727 self.actions.append(self.unmigrateAct) |
721 |
728 |
722 self.makeMigrationsAct = E5Action( |
729 self.makeMigrationsAct = EricAction( |
723 self.tr('Make Migrations'), |
730 self.tr('Make Migrations'), |
724 self.tr('&Make Migrations'), |
731 self.tr('&Make Migrations'), |
725 0, 0, |
732 0, 0, |
726 self, 'django_migration_make') |
733 self, 'django_migration_make') |
727 self.makeMigrationsAct.setStatusTip(self.tr( |
734 self.makeMigrationsAct.setStatusTip(self.tr( |
731 """<p>This generates migrations for the Django project.</p>""" |
738 """<p>This generates migrations for the Django project.</p>""" |
732 )) |
739 )) |
733 self.makeMigrationsAct.triggered.connect(self.__makeMigrations) |
740 self.makeMigrationsAct.triggered.connect(self.__makeMigrations) |
734 self.actions.append(self.makeMigrationsAct) |
741 self.actions.append(self.makeMigrationsAct) |
735 |
742 |
736 self.squashMigrationsAct = E5Action( |
743 self.squashMigrationsAct = EricAction( |
737 self.tr('Squash Migrations'), |
744 self.tr('Squash Migrations'), |
738 self.tr('S&quash Migrations'), |
745 self.tr('S&quash Migrations'), |
739 0, 0, |
746 0, 0, |
740 self, 'django_migration_squash') |
747 self, 'django_migration_squash') |
741 self.squashMigrationsAct.setStatusTip(self.tr( |
748 self.squashMigrationsAct.setStatusTip(self.tr( |
937 |
944 |
938 def getMenu(self, name): |
945 def getMenu(self, name): |
939 """ |
946 """ |
940 Public method to get a reference to the requested menu. |
947 Public method to get a reference to the requested menu. |
941 |
948 |
942 @param name name of the menu (string) |
949 @param name name of the menu |
943 @return reference to the menu (QMenu) or None, if no |
950 @type str |
944 menu with the given name exists |
951 @return reference to the menu or None, if no menu with the given |
|
952 name exists |
|
953 @rtype QMenu |
945 """ |
954 """ |
946 if name in self.__menus: |
955 if name in self.__menus: |
947 return self.__menus[name] |
956 return self.__menus[name] |
948 else: |
957 else: |
949 return None |
958 return None |
950 |
959 |
951 def getMenuNames(self): |
960 def getMenuNames(self): |
952 """ |
961 """ |
953 Public method to get the names of all menus. |
962 Public method to get the names of all menus. |
954 |
963 |
955 @return menu names (list of string) |
964 @return menu names |
|
965 @rtype list of str |
956 """ |
966 """ |
957 return list(self.__menus.keys()) |
967 return list(self.__menus.keys()) |
958 |
968 |
959 ################################################################## |
969 ################################################################## |
960 ## methods below implement the various hook related functions |
970 ## methods below implement the various hook related functions |
978 |
988 |
979 def projectOpenedHooks(self): |
989 def projectOpenedHooks(self): |
980 """ |
990 """ |
981 Public method to add our hook methods. |
991 Public method to add our hook methods. |
982 """ |
992 """ |
983 if self.__e5project.getProjectType() == "Django": |
993 if self.__ericProject.getProjectType() == "Django": |
984 self.__formsBrowser = ( |
994 self.__formsBrowser = ( |
985 e5App().getObject("ProjectBrowser").getProjectBrowser("forms") |
995 ericApp().getObject("ProjectBrowser") |
|
996 .getProjectBrowser("forms") |
986 ) |
997 ) |
987 self.__formsBrowser.addHookMethodAndMenuEntry( |
998 self.__formsBrowser.addHookMethodAndMenuEntry( |
988 "newForm", |
999 "newForm", |
989 self.newForm, self.tr("New template...")) |
1000 self.newForm, self.tr("New template...")) |
990 |
1001 |
991 self.__e5project.projectLanguageAddedByCode.connect( |
1002 self.__ericProject.projectLanguageAddedByCode.connect( |
992 self.__projectLanguageAdded) |
1003 self.__projectLanguageAdded) |
993 self.__translationsBrowser = ( |
1004 self.__translationsBrowser = ( |
994 e5App().getObject("ProjectBrowser") |
1005 ericApp().getObject("ProjectBrowser") |
995 .getProjectBrowser("translations")) |
1006 .getProjectBrowser("translations")) |
996 self.__translationsBrowser.addHookMethodAndMenuEntry( |
1007 self.__translationsBrowser.addHookMethodAndMenuEntry( |
997 "generateAll", |
1008 "generateAll", |
998 self.updateCatalogs, self.tr("Update all catalogs")) |
1009 self.updateCatalogs, self.tr("Update all catalogs")) |
999 self.__translationsBrowser.addHookMethodAndMenuEntry( |
1010 self.__translationsBrowser.addHookMethodAndMenuEntry( |
1025 """ |
1036 """ |
1026 if self.__hooksInstalled: |
1037 if self.__hooksInstalled: |
1027 self.__formsBrowser.removeHookMethod("newForm") |
1038 self.__formsBrowser.removeHookMethod("newForm") |
1028 self.__formsBrowser = None |
1039 self.__formsBrowser = None |
1029 |
1040 |
1030 self.__e5project.projectLanguageAddedByCode.disconnect( |
1041 self.__ericProject.projectLanguageAddedByCode.disconnect( |
1031 self.__projectLanguageAdded) |
1042 self.__projectLanguageAdded) |
1032 self.__translationsBrowser.removeHookMethod( |
1043 self.__translationsBrowser.removeHookMethod( |
1033 "generateAll") |
1044 "generateAll") |
1034 self.__translationsBrowser.removeHookMethod( |
1045 self.__translationsBrowser.removeHookMethod( |
1035 "generateSelected") |
1046 "generateSelected") |
1048 |
1059 |
1049 def newForm(self, path): |
1060 def newForm(self, path): |
1050 """ |
1061 """ |
1051 Public method to create a new form. |
1062 Public method to create a new form. |
1052 |
1063 |
1053 @param path full directory path for the new form file (string) |
1064 @param path full directory path for the new form file |
1054 """ |
1065 @type str |
1055 fname, selectedFilter = E5FileDialog.getSaveFileNameAndFilter( |
1066 """ |
|
1067 fname, selectedFilter = EricFileDialog.getSaveFileNameAndFilter( |
1056 self.__ui, |
1068 self.__ui, |
1057 self.tr("New Form"), |
1069 self.tr("New Form"), |
1058 path, |
1070 path, |
1059 filter, |
1071 filter, |
1060 None, |
1072 None, |
1061 E5FileDialog.Options(E5FileDialog.DontConfirmOverwrite)) |
1073 EricFileDialog.DontConfirmOverwrite) |
1062 |
1074 |
1063 if not fname: |
1075 if not fname: |
1064 # user aborted or didn't enter a filename |
1076 # user aborted or didn't enter a filename |
1065 return |
1077 return |
1066 |
1078 |
1069 ex = selectedFilter.split("(*")[1].split(")")[0] |
1081 ex = selectedFilter.split("(*")[1].split(")")[0] |
1070 if ex: |
1082 if ex: |
1071 fname += ex |
1083 fname += ex |
1072 |
1084 |
1073 if os.path.exists(fname): |
1085 if os.path.exists(fname): |
1074 res = E5MessageBox.yesNo( |
1086 res = EricMessageBox.yesNo( |
1075 self.__ui, |
1087 self.__ui, |
1076 self.tr("New Form"), |
1088 self.tr("New Form"), |
1077 self.tr("The file already exists! Overwrite it?"), |
1089 self.tr("The file already exists! Overwrite it?"), |
1078 icon=E5MessageBox.Warning) |
1090 icon=EricMessageBox.Warning) |
1079 |
1091 |
1080 if not res: |
1092 if not res: |
1081 # user selected to not overwrite |
1093 # user selected to not overwrite |
1082 return |
1094 return |
1083 |
1095 |
1101 f.write(' </div>') |
1113 f.write(' </div>') |
1102 f.write(' </body>\n') |
1114 f.write(' </body>\n') |
1103 f.close() |
1115 f.close() |
1104 f.write('</html>\n') |
1116 f.write('</html>\n') |
1105 except OSError as e: |
1117 except OSError as e: |
1106 E5MessageBox.critical( |
1118 EricMessageBox.critical( |
1107 self.__ui, |
1119 self.__ui, |
1108 self.tr("New Form"), |
1120 self.tr("New Form"), |
1109 self.tr("<p>The new form file <b>{0}</b> could not be" |
1121 self.tr("<p>The new form file <b>{0}</b> could not be" |
1110 " created.<br> Problem: {1}</p>") |
1122 " created.<br> Problem: {1}</p>") |
1111 .format(fname, str(e))) |
1123 .format(fname, str(e))) |
1112 return |
1124 return |
1113 |
1125 |
1114 self.__e5project.appendFile(fname) |
1126 self.__ericProject.appendFile(fname) |
1115 self.__formsBrowser.sourceFile.emit(fname) |
1127 self.__formsBrowser.sourceFile.emit(fname) |
1116 |
1128 |
1117 ################################################################## |
1129 ################################################################## |
1118 ## slots below implement general functionality |
1130 ## slots below implement general functionality |
1119 ################################################################## |
1131 ################################################################## |
1129 def __getExecutablePaths(self, file): |
1141 def __getExecutablePaths(self, file): |
1130 """ |
1142 """ |
1131 Private method to build all full paths of an executable file from |
1143 Private method to build all full paths of an executable file from |
1132 the environment. |
1144 the environment. |
1133 |
1145 |
1134 @param file filename of the executable (string) |
1146 @param file filename of the executable |
|
1147 @type str |
1135 @return list of full executable names, if the executable file is |
1148 @return list of full executable names, if the executable file is |
1136 accessible via the searchpath defined by the PATH environment |
1149 accessible via the searchpath defined by the PATH environment |
1137 variable, or an empty list otherwise. |
1150 variable, or an empty list otherwise. |
|
1151 @rtype list of str |
1138 """ |
1152 """ |
1139 paths = [] |
1153 paths = [] |
1140 |
1154 |
1141 if os.path.isabs(file): |
1155 if os.path.isabs(file): |
1142 if os.access(file, os.X_OK): |
1156 if os.access(file, os.X_OK): |
1217 def __getVirtualEnvironment(self, language=""): |
1232 def __getVirtualEnvironment(self, language=""): |
1218 """ |
1233 """ |
1219 Private method to get the path of the virtual environment. |
1234 Private method to get the path of the virtual environment. |
1220 |
1235 |
1221 @param language Python variant to get the virtual environment |
1236 @param language Python variant to get the virtual environment |
1222 for (string, one of '' or 'Python3') |
1237 for (one of '' or 'Python3') |
1223 @return path of the virtual environment (string) |
1238 @type str |
|
1239 @return path of the virtual environment |
|
1240 @rtype str |
1224 """ |
1241 """ |
1225 if not language: |
1242 if not language: |
1226 language = self.__e5project.getProjectLanguage() |
1243 language = self.__ericProject.getProjectLanguage() |
1227 venvName = ( |
1244 venvName = ( |
1228 self.__plugin.getPreferences("VirtualEnvironmentNamePy3") |
1245 self.__plugin.getPreferences("VirtualEnvironmentNamePy3") |
1229 if language == "Python3" else |
1246 if language == "Python3" else |
1230 "" |
1247 "" |
1231 ) |
1248 ) |
1247 def __getDebugEnvironment(self, language=""): |
1264 def __getDebugEnvironment(self, language=""): |
1248 """ |
1265 """ |
1249 Private method to get the path of the debugger environment. |
1266 Private method to get the path of the debugger environment. |
1250 |
1267 |
1251 @param language Python variant to get the debugger environment |
1268 @param language Python variant to get the debugger environment |
1252 for (string, one of '' or 'Python3') |
1269 for (one of '' or 'Python3') |
1253 @return path of the debugger environment (string) |
1270 @type str |
|
1271 @return path of the debugger environment |
|
1272 @rtype str |
1254 """ |
1273 """ |
1255 if not language: |
1274 if not language: |
1256 language = self.__e5project.getProjectLanguage() |
1275 language = self.__ericProject.getProjectLanguage() |
1257 debugEnv = self.__getVirtualEnvironment(language) |
1276 debugEnv = self.__getVirtualEnvironment(language) |
1258 if not debugEnv: |
1277 if not debugEnv: |
1259 if language == "Python3": |
1278 if language == "Python3": |
1260 venvName = Preferences.getDebugger("Python3VirtualEnv") |
1279 venvName = Preferences.getDebugger("Python3VirtualEnv") |
1261 else: |
1280 else: |
1271 def __getDjangoAdminCommand(self, language=""): |
1290 def __getDjangoAdminCommand(self, language=""): |
1272 """ |
1291 """ |
1273 Private method to build a django-admin.py command. |
1292 Private method to build a django-admin.py command. |
1274 |
1293 |
1275 @param language Python variant to get the django-admin.py |
1294 @param language Python variant to get the django-admin.py |
1276 command for (string, one of '' or 'Python3') |
1295 command for (one of '' or 'Python3') |
1277 @return full django-admin.py command (string) |
1296 @type str |
|
1297 @return full django-admin.py command |
|
1298 @rtype str |
1278 """ |
1299 """ |
1279 if not language: |
1300 if not language: |
1280 language = self.__e5project.getProjectLanguage() |
1301 language = self.__ericProject.getProjectLanguage() |
1281 |
1302 |
1282 virtualEnv = self.__getVirtualEnvironment(language) |
1303 virtualEnv = self.__getVirtualEnvironment(language) |
1283 if virtualEnv: |
1304 if virtualEnv: |
1284 if isWindowsPlatform(): |
1305 if isWindowsPlatform(): |
1285 for cmd in [ |
1306 for cmd in [ |
1319 else: |
1340 else: |
1320 cmd = "" |
1341 cmd = "" |
1321 else: |
1342 else: |
1322 if language == "Python3": |
1343 if language == "Python3": |
1323 cmds = ["django-admin3.py", "django-admin3", |
1344 cmds = ["django-admin3.py", "django-admin3", |
|
1345 "django-admin.py-3.10", |
|
1346 "django-admin.py-3.9", "django-admin.py-3.8", |
1324 "django-admin.py-3.7", "django-admin.py-3.6", |
1347 "django-admin.py-3.7", "django-admin.py-3.6", |
1325 "django-admin.py-3.5", "django-admin.py-3.4", |
|
1326 "django-admin.py-3.3", "django-admin.py-3.2", |
|
1327 ] |
1348 ] |
1328 else: |
1349 else: |
1329 cmds = [] |
1350 cmds = [] |
1330 cmds.extend(["django-admin.py", "django-admin"]) |
1351 cmds.extend(["django-admin.py", "django-admin"]) |
1331 for cmd in cmds: |
1352 for cmd in cmds: |
1338 |
1359 |
1339 def __getPythonExecutable(self): |
1360 def __getPythonExecutable(self): |
1340 """ |
1361 """ |
1341 Private method to build the Python command. |
1362 Private method to build the Python command. |
1342 |
1363 |
1343 @return python command (string) |
1364 @return python command |
1344 """ |
1365 @rtype str |
1345 language = self.__e5project.getProjectLanguage() |
1366 """ |
|
1367 language = self.__ericProject.getProjectLanguage() |
1346 if language == "Python3": |
1368 if language == "Python3": |
1347 venvName = self.__plugin.getPreferences( |
1369 venvName = self.__plugin.getPreferences( |
1348 "VirtualEnvironmentNamePy3") |
1370 "VirtualEnvironmentNamePy3") |
1349 if not venvName: |
1371 if not venvName: |
1350 # if none configured, use the global one |
1372 # if none configured, use the global one |
1364 Private slot to show some info about Django. |
1386 Private slot to show some info about Django. |
1365 """ |
1387 """ |
1366 version = self.getDjangoVersionString() |
1388 version = self.getDjangoVersionString() |
1367 url = "https://www.djangoproject.com" |
1389 url = "https://www.djangoproject.com" |
1368 |
1390 |
1369 msgBox = E5MessageBox.E5MessageBox( |
1391 msgBox = EricMessageBox.EricMessageBox( |
1370 E5MessageBox.Question, |
1392 EricMessageBox.Question, |
1371 self.tr("About Django"), |
1393 self.tr("About Django"), |
1372 self.tr( |
1394 self.tr( |
1373 "<p>Django is a high-level Python Web framework that" |
1395 "<p>Django is a high-level Python Web framework that" |
1374 " encourages rapid development and clean, pragmatic" |
1396 " encourages rapid development and clean, pragmatic" |
1375 " design.</p>" |
1397 " design.</p>" |
1378 "<tr><td>URL:</td><td><a href=\"{1}\">" |
1400 "<tr><td>URL:</td><td><a href=\"{1}\">" |
1379 "{1}</a></td></tr>" |
1401 "{1}</a></td></tr>" |
1380 "</table></p>" |
1402 "</table></p>" |
1381 ).format(version, url), |
1403 ).format(version, url), |
1382 modal=True, |
1404 modal=True, |
1383 buttons=E5MessageBox.Ok) |
1405 buttons=EricMessageBox.Ok) |
1384 msgBox.setIconPixmap(UI.PixmapCache.getPixmap( |
1406 msgBox.setIconPixmap(UI.PixmapCache.getPixmap( |
1385 os.path.join("ProjectDjango", "icons", |
1407 os.path.join("ProjectDjango", "icons", |
1386 "django64-{0}".format(self.__iconSuffix)))) |
1408 "django64-{0}".format(self.__iconSuffix)))) |
1387 msgBox.exec() |
1409 msgBox.exec() |
1388 |
1410 |
1389 def getDjangoVersionString(self): |
1411 def getDjangoVersionString(self): |
1390 """ |
1412 """ |
1391 Public method to get the Django version as a string. |
1413 Public method to get the Django version as a string. |
1392 |
1414 |
1393 @return Django version (string) |
1415 @return Django version |
|
1416 @rtype str |
1394 """ |
1417 """ |
1395 djangoVersion = "" |
1418 djangoVersion = "" |
1396 |
1419 |
1397 args = ['--version'] |
1420 args = ['--version'] |
1398 ioEncoding = Preferences.getSystem("IOEncoding") |
1421 ioEncoding = Preferences.getSystem("IOEncoding") |
1434 |
1457 |
1435 def __getApplications(self): |
1458 def __getApplications(self): |
1436 """ |
1459 """ |
1437 Private method to ask the user for a list of application names. |
1460 Private method to ask the user for a list of application names. |
1438 |
1461 |
1439 @return list of application names (list of strings) |
1462 @return list of application names |
|
1463 @rtype list of str |
1440 """ |
1464 """ |
1441 applStr, ok = QInputDialog.getItem( |
1465 applStr, ok = QInputDialog.getItem( |
1442 self.__ui, |
1466 self.__ui, |
1443 self.tr("Select Applications"), |
1467 self.tr("Select Applications"), |
1444 self.tr("Enter the list of applications separated by spaces."), |
1468 self.tr("Enter the list of applications separated by spaces."), |
1552 self.__recentTestData[key][:maxRecentTestData]) |
1577 self.__recentTestData[key][:maxRecentTestData]) |
1553 self.__saveRecentTestData() |
1578 self.__saveRecentTestData() |
1554 |
1579 |
1555 def getProjectPath(self): |
1580 def getProjectPath(self): |
1556 """ |
1581 """ |
1557 Public method to get the path of the eric6 project. |
1582 Public method to get the path of the eric7 project. |
1558 |
1583 |
1559 @return path of the eric6 project (string) |
1584 @return path of the eric7 project |
1560 """ |
1585 @rtype str |
1561 return self.__e5project.getProjectPath() |
1586 """ |
|
1587 return self.__ericProject.getProjectPath() |
1562 |
1588 |
1563 def __showHelpIndex(self): |
1589 def __showHelpIndex(self): |
1564 """ |
1590 """ |
1565 Private slot to show the help index page. |
1591 Private slot to show the help index page. |
1566 """ |
1592 """ |
1570 |
1596 |
1571 def __isSpawningConsole(self, consoleCmd): |
1597 def __isSpawningConsole(self, consoleCmd): |
1572 """ |
1598 """ |
1573 Private method to check, if the given console is a spawning console. |
1599 Private method to check, if the given console is a spawning console. |
1574 |
1600 |
1575 @param consoleCmd console command (string) |
1601 @param consoleCmd console command |
|
1602 @type str |
1576 @return tuple of two entries giving an indication, if the console |
1603 @return tuple of two entries giving an indication, if the console |
1577 is spawning (boolean) and the (possibly) cleaned console command |
1604 is spawning and the (possibly) cleaned console command |
1578 (string) |
1605 @rtype tuple of (bool, str) |
1579 """ |
1606 """ |
1580 if consoleCmd and consoleCmd[0] == '@': |
1607 if consoleCmd and consoleCmd[0] == '@': |
1581 return (True, consoleCmd[1:]) |
1608 return (True, consoleCmd[1:]) |
1582 else: |
1609 else: |
1583 return (False, consoleCmd) |
1610 return (False, consoleCmd) |
1606 |
1633 |
1607 def newProjectCreated(self): |
1634 def newProjectCreated(self): |
1608 """ |
1635 """ |
1609 Public slot to finish up the newly generated project. |
1636 Public slot to finish up the newly generated project. |
1610 """ |
1637 """ |
1611 if self.__e5project.getProjectType() == "Django": |
1638 if self.__ericProject.getProjectType() == "Django": |
1612 ppath = self.__e5project.getProjectPath() |
1639 ppath = self.__ericProject.getProjectPath() |
1613 |
1640 |
1614 # get rid of an __init__.py file because it would be in our way |
1641 # get rid of an __init__.py file because it would be in our way |
1615 initModule = os.path.join(ppath, "__init__.py") |
1642 initModule = os.path.join(ppath, "__init__.py") |
1616 if os.path.exists(initModule): |
1643 if os.path.exists(initModule): |
1617 self.__e5project.deleteFile("__init__.py") |
1644 self.__ericProject.deleteFile("__init__.py") |
1618 self.__e5project.saveProject() |
1645 self.__ericProject.saveProject() |
1619 |
1646 |
1620 def startProjectOrApplication(self): |
1647 def startProjectOrApplication(self): |
1621 """ |
1648 """ |
1622 Public slot to start a new Django project or application. |
1649 Public slot to start a new Django project or application. |
1623 """ |
1650 """ |
1624 if self.__e5project.getProjectType() == "Django": |
1651 if self.__ericProject.getProjectType() == "Django": |
1625 projectStr = self.tr("Project") |
1652 projectStr = self.tr("Project") |
1626 applStr = self.tr("Application") |
1653 applStr = self.tr("Application") |
1627 selections = ["", projectStr, applStr] |
1654 selections = ["", projectStr, applStr] |
1628 selection, ok = QInputDialog.getItem( |
1655 selection, ok = QInputDialog.getItem( |
1629 self.__ui, |
1656 self.__ui, |
1634 selections, |
1661 selections, |
1635 0, False) |
1662 0, False) |
1636 if ok and bool(selection): |
1663 if ok and bool(selection): |
1637 if selection == projectStr: |
1664 if selection == projectStr: |
1638 path, projectName = os.path.split( |
1665 path, projectName = os.path.split( |
1639 self.__e5project.getProjectPath()) |
1666 self.__ericProject.getProjectPath()) |
1640 self.__createProject(projectName, path) |
1667 self.__createProject(projectName, path) |
1641 elif selection == applStr: |
1668 elif selection == applStr: |
1642 path, applName = os.path.split( |
1669 path, applName = os.path.split( |
1643 self.__e5project.getProjectPath()) |
1670 self.__ericProject.getProjectPath()) |
1644 self.__createApplication(applName, path) |
1671 self.__createApplication(applName, path) |
1645 |
1672 |
1646 def __createProject(self, projectName, path): |
1673 def __createProject(self, projectName, path): |
1647 """ |
1674 """ |
1648 Private slot to create a new Django project. |
1675 Private slot to create a new Django project. |
1649 |
1676 |
1650 @param projectName name of the new project (string) |
1677 @param projectName name of the new project |
|
1678 @type str |
1651 @param path the directory where the project should be created |
1679 @param path the directory where the project should be created |
1652 (string) |
1680 @type str |
1653 @return flag indicating a successful creation (boolean) |
1681 @return flag indicating a successful creation |
|
1682 @rtype bool |
1654 """ |
1683 """ |
1655 title = self.tr("Start Django Project") |
1684 title = self.tr("Start Django Project") |
1656 |
1685 |
1657 # remove the project directory if it exists already |
1686 # remove the project directory if it exists already |
1658 ppath = os.path.join(path, projectName) |
1687 ppath = os.path.join(path, projectName) |
1659 if os.path.exists(ppath): |
1688 if os.path.exists(ppath): |
1660 okToRemove = E5MessageBox.yesNo( |
1689 okToRemove = EricMessageBox.yesNo( |
1661 self.__ui, |
1690 self.__ui, |
1662 title, |
1691 title, |
1663 self.tr("""<p>The Django project path <b>{0}</b> exists""" |
1692 self.tr("""<p>The Django project path <b>{0}</b> exists""" |
1664 """ already. Shall it be removed and recreated?""" |
1693 """ already. Shall it be removed and recreated?""" |
1665 """</p>""").format(ppath)) |
1694 """</p>""").format(ppath)) |
1666 if not okToRemove: |
1695 if not okToRemove: |
1667 E5MessageBox.information( |
1696 EricMessageBox.information( |
1668 self.__ui, |
1697 self.__ui, |
1669 title, |
1698 title, |
1670 self.tr("""<p>Please add the files to the eric project""" |
1699 self.tr("""<p>Please add the files to the eric project""" |
1671 """ manually.</p>""")) |
1700 """ manually.</p>""")) |
1672 return True |
1701 return True |
1718 """ |
1747 """ |
1719 projectName, ok = QInputDialog.getText( |
1748 projectName, ok = QInputDialog.getText( |
1720 self.__ui, |
1749 self.__ui, |
1721 self.tr("Start Django Project"), |
1750 self.tr("Start Django Project"), |
1722 self.tr("Enter the name of the new Django project."), |
1751 self.tr("Enter the name of the new Django project."), |
1723 QLineEdit.Normal) |
1752 QLineEdit.EchoMode.Normal) |
1724 if ok and projectName != "": |
1753 if ok and projectName != "": |
1725 res = self.__createProject(projectName, |
1754 res = self.__createProject(projectName, |
1726 self.__e5project.getProjectPath()) |
1755 self.__ericProject.getProjectPath()) |
1727 if res: |
1756 if res: |
1728 # search for new files and add them to the project |
1757 # search for new files and add them to the project |
1729 sitePath = os.path.join(self.__e5project.getProjectPath(), |
1758 sitePath = os.path.join(self.__ericProject.getProjectPath(), |
1730 projectName) |
1759 projectName) |
1731 for entry in os.walk(sitePath): |
1760 for entry in os.walk(sitePath): |
1732 for fileName in entry[2]: |
1761 for fileName in entry[2]: |
1733 fullName = os.path.join(entry[0], fileName) |
1762 fullName = os.path.join(entry[0], fileName) |
1734 self.__e5project.appendFile(fullName) |
1763 self.__ericProject.appendFile(fullName) |
1735 |
1764 |
1736 def __createApplication(self, applName, path, isGlobal=True): |
1765 def __createApplication(self, applName, path, isGlobal=True): |
1737 """ |
1766 """ |
1738 Private slot to create a new Django application. |
1767 Private slot to create a new Django application. |
1739 |
1768 |
1740 @param applName name of the new application (string) |
1769 @param applName name of the new application |
|
1770 @type str |
1741 @param path the directory where the application should be created |
1771 @param path the directory where the application should be created |
1742 (string) |
1772 @type str |
1743 @param isGlobal flag indicating a standalone Django application |
1773 @param isGlobal flag indicating a standalone Django application |
1744 (boolean) |
1774 @type bool |
1745 @return flag indicating a successful creation (boolean) |
1775 @return flag indicating a successful creation |
|
1776 @rtype bool |
1746 """ |
1777 """ |
1747 title = self.tr("Start Django Application") |
1778 title = self.tr("Start Django Application") |
1748 |
1779 |
1749 # remove the application directory if it exists already |
1780 # remove the application directory if it exists already |
1750 apath = os.path.join(path, applName) |
1781 apath = os.path.join(path, applName) |
1791 applName, ok = QInputDialog.getText( |
1822 applName, ok = QInputDialog.getText( |
1792 self.__ui, |
1823 self.__ui, |
1793 self.tr("Start Global Django Application"), |
1824 self.tr("Start Global Django Application"), |
1794 self.tr("Enter the name of the new global Django" |
1825 self.tr("Enter the name of the new global Django" |
1795 " application."), |
1826 " application."), |
1796 QLineEdit.Normal) |
1827 QLineEdit.EchoMode.Normal) |
1797 if ok and applName != "": |
1828 if ok and applName != "": |
1798 res = self.__createApplication(applName, |
1829 res = self.__createApplication(applName, |
1799 self.__e5project.getProjectPath()) |
1830 self.__ericProject.getProjectPath()) |
1800 if res: |
1831 if res: |
1801 # search for new files and add them to the project |
1832 # search for new files and add them to the project |
1802 appPath = os.path.join(self.__e5project.getProjectPath(), |
1833 appPath = os.path.join(self.__ericProject.getProjectPath(), |
1803 applName) |
1834 applName) |
1804 for entry in os.walk(appPath): |
1835 for entry in os.walk(appPath): |
1805 for fileName in entry[2]: |
1836 for fileName in entry[2]: |
1806 fullName = os.path.join(entry[0], fileName) |
1837 fullName = os.path.join(entry[0], fileName) |
1807 self.__e5project.appendFile(fullName) |
1838 self.__ericProject.appendFile(fullName) |
1808 |
1839 |
1809 def __startLocalApplication(self): |
1840 def __startLocalApplication(self): |
1810 """ |
1841 """ |
1811 Private slot to start a new local Django application. |
1842 Private slot to start a new local Django application. |
1812 """ |
1843 """ |
1813 applName, ok = QInputDialog.getText( |
1844 applName, ok = QInputDialog.getText( |
1814 self.__ui, |
1845 self.__ui, |
1815 self.tr("Start Local Django Application"), |
1846 self.tr("Start Local Django Application"), |
1816 self.tr("Enter the name of the new local Django application."), |
1847 self.tr("Enter the name of the new local Django application."), |
1817 QLineEdit.Normal) |
1848 QLineEdit.EchoMode.Normal) |
1818 if ok and applName != "": |
1849 if ok and applName != "": |
1819 res = self.__createApplication(applName, "", False) |
1850 res = self.__createApplication(applName, "", False) |
1820 if res: |
1851 if res: |
1821 try: |
1852 try: |
1822 # search for new files and add them to the project |
1853 # search for new files and add them to the project |
1823 appPath = os.path.join(self.__sitePath(), applName) |
1854 appPath = os.path.join(self.__sitePath(), applName) |
1824 for entry in os.walk(appPath): |
1855 for entry in os.walk(appPath): |
1825 for fileName in entry[2]: |
1856 for fileName in entry[2]: |
1826 fullName = os.path.join(entry[0], fileName) |
1857 fullName = os.path.join(entry[0], fileName) |
1827 self.__e5project.appendFile(fullName) |
1858 self.__ericProject.appendFile(fullName) |
1828 except DjangoNoSiteSelectedException: |
1859 except DjangoNoSiteSelectedException: |
1829 return |
1860 return |
1830 |
1861 |
1831 ################################################################## |
1862 ################################################################## |
1832 ## methods below implement site related functions |
1863 ## methods below implement site related functions |
1871 |
1903 |
1872 def __sitePath(self): |
1904 def __sitePath(self): |
1873 """ |
1905 """ |
1874 Private method to calculate the full path of the Django site. |
1906 Private method to calculate the full path of the Django site. |
1875 |
1907 |
|
1908 @return path of the site |
|
1909 @rtype str |
1876 @exception DjangoNoSiteSelectedException raised, if no site is selected |
1910 @exception DjangoNoSiteSelectedException raised, if no site is selected |
1877 @return path of the site (string) |
|
1878 """ |
1911 """ |
1879 if self.__currentSite is None: |
1912 if self.__currentSite is None: |
1880 self.__selectSite() |
1913 self.__selectSite() |
1881 |
1914 |
1882 if self.__currentSite is None: |
1915 if self.__currentSite is None: |
1883 raise DjangoNoSiteSelectedException |
1916 raise DjangoNoSiteSelectedException |
1884 else: |
1917 else: |
1885 path = os.path.join(self.__e5project.getProjectPath(), |
1918 path = os.path.join(self.__ericProject.getProjectPath(), |
1886 self.__currentSite) |
1919 self.__currentSite) |
1887 return path |
1920 return path |
1888 |
1921 |
1889 def __setCurrentSite(self, site): |
1922 def __setCurrentSite(self, site): |
1890 """ |
1923 """ |
1891 Private slot to set the current site. |
1924 Private slot to set the current site. |
1892 |
1925 |
1893 @param site name of the site (string) |
1926 @param site name of the site |
|
1927 @type str |
1894 """ |
1928 """ |
1895 self.__currentSite = site |
1929 self.__currentSite = site |
1896 if self.__currentSite is None: |
1930 if self.__currentSite is None: |
1897 curSite = self.tr("None") |
1931 curSite = self.tr("None") |
1898 elif self.__currentSite == "": |
1932 elif self.__currentSite == "": |
1901 curSite = self.__currentSite |
1935 curSite = self.__currentSite |
1902 self.selectSiteAct.setText( |
1936 self.selectSiteAct.setText( |
1903 self.tr('&Current Django project ({0})').format(curSite)) |
1937 self.tr('&Current Django project ({0})').format(curSite)) |
1904 |
1938 |
1905 if self.__currentSite is None: |
1939 if self.__currentSite is None: |
1906 self.__e5project.setTranslationPattern("") |
1940 self.__ericProject.setTranslationPattern("") |
1907 else: |
1941 else: |
1908 self.__e5project.setTranslationPattern( |
1942 self.__ericProject.setTranslationPattern( |
1909 os.path.join(site, "locale", "%language%", "LC_MESSAGES", |
1943 os.path.join(site, "locale", "%language%", "LC_MESSAGES", |
1910 "django.po") |
1944 "django.po") |
1911 ) |
1945 ) |
1912 |
1946 |
1913 def __site(self): |
1947 def __site(self): |
1914 """ |
1948 """ |
1915 Private method to get the name of the current site. |
1949 Private method to get the name of the current site. |
1916 |
1950 |
|
1951 @return name of the site |
|
1952 @rtype str |
1917 @exception DjangoNoSiteSelectedException raised, if no site is selected |
1953 @exception DjangoNoSiteSelectedException raised, if no site is selected |
1918 @return name of the site (string) |
|
1919 """ |
1954 """ |
1920 if self.__currentSite is None: |
1955 if self.__currentSite is None: |
1921 self.__selectSite() |
1956 self.__selectSite() |
1922 |
1957 |
1923 if self.__currentSite is None: |
1958 if self.__currentSite is None: |
1962 self.__serverProcFinished) |
1997 self.__serverProcFinished) |
1963 self.__serverProc.setWorkingDirectory(self.__sitePath()) |
1998 self.__serverProc.setWorkingDirectory(self.__sitePath()) |
1964 self.__serverProc.start(args[0], args[1:]) |
1999 self.__serverProc.start(args[0], args[1:]) |
1965 serverProcStarted = self.__serverProc.waitForStarted() |
2000 serverProcStarted = self.__serverProc.waitForStarted() |
1966 if not serverProcStarted: |
2001 if not serverProcStarted: |
1967 E5MessageBox.critical( |
2002 EricMessageBox.critical( |
1968 None, |
2003 None, |
1969 self.tr('Process Generation Error'), |
2004 self.tr('Process Generation Error'), |
1970 self.tr('The Django server could not be started.')) |
2005 self.tr('The Django server could not be started.')) |
1971 |
2006 |
1972 def __serverProcFinished(self): |
2007 def __serverProcFinished(self): |
1973 """ |
2008 """ |
1974 Private slot connected to the finished signal. |
2009 Private slot connected to the finished signal. |
1975 """ |
2010 """ |
1976 if ( |
2011 if ( |
1977 self.__serverProc is not None and |
2012 self.__serverProc is not None and |
1978 self.__serverProc.state() != QProcess.NotRunning |
2013 self.__serverProc.state() != QProcess.ProcessState.NotRunning |
1979 ): |
2014 ): |
1980 self.__serverProc.terminate() |
2015 self.__serverProc.terminate() |
1981 QTimer.singleShot(2000, self.__serverProc.kill) |
2016 QTimer.singleShot(2000, self.__serverProc.kill) |
1982 self.__serverProc.waitForFinished(3000) |
2017 self.__serverProc.waitForFinished(3000) |
1983 self.__serverProc = None |
2018 self.__serverProc = None |
2008 addr = "127.0.0.1" |
2043 addr = "127.0.0.1" |
2009 url = "http://{0}:{1}".format(addr, port) |
2044 url = "http://{0}:{1}".format(addr, port) |
2010 if self.__plugin.getPreferences("UseExternalBrowser"): |
2045 if self.__plugin.getPreferences("UseExternalBrowser"): |
2011 res = QDesktopServices.openUrl(QUrl(url)) |
2046 res = QDesktopServices.openUrl(QUrl(url)) |
2012 if not res: |
2047 if not res: |
2013 E5MessageBox.critical( |
2048 EricMessageBox.critical( |
2014 None, |
2049 None, |
2015 self.tr('Run Web-Browser'), |
2050 self.tr('Run Web-Browser'), |
2016 self.tr('Could not start the web-browser for the' |
2051 self.tr('Could not start the web-browser for the' |
2017 ' url "{0}".').format(url.toString())) |
2052 ' url "{0}".').format(url.toString())) |
2018 else: |
2053 else: |
2193 with contextlib.suppress(DjangoNoSiteSelectedException): |
2228 with contextlib.suppress(DjangoNoSiteSelectedException): |
2194 wd = self.__sitePath() |
2229 wd = self.__sitePath() |
2195 self.__adjustWorkingDirectory(args, wd) |
2230 self.__adjustWorkingDirectory(args, wd) |
2196 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
2231 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
2197 if not started: |
2232 if not started: |
2198 E5MessageBox.critical( |
2233 EricMessageBox.critical( |
2199 None, |
2234 None, |
2200 self.tr('Process Generation Error'), |
2235 self.tr('Process Generation Error'), |
2201 self.tr('The Django process could not be started.')) |
2236 self.tr('The Django process could not be started.')) |
2202 |
2237 |
2203 ####################################################################### |
2238 ####################################################################### |
2206 |
2241 |
2207 def __sqlCommand(self, title, command, requestApps=True): |
2242 def __sqlCommand(self, title, command, requestApps=True): |
2208 """ |
2243 """ |
2209 Private method to perform an SQL creation function. |
2244 Private method to perform an SQL creation function. |
2210 |
2245 |
2211 @param title dialog title (string) |
2246 @param title dialog title |
2212 @param command Django sql... command (string) |
2247 @type str |
|
2248 @param command Django sql... command |
|
2249 @type str |
2213 @param requestApps flag indicating to request a list of applications |
2250 @param requestApps flag indicating to request a list of applications |
2214 to work on (boolean) |
2251 to work on |
|
2252 @type bool |
2215 """ |
2253 """ |
2216 try: |
2254 try: |
2217 path = self.__sitePath() |
2255 path = self.__sitePath() |
2218 except DjangoNoSiteSelectedException: |
2256 except DjangoNoSiteSelectedException: |
2219 return |
2257 return |
2258 def __databaseSqlMigrate(self, backwards=False): |
2296 def __databaseSqlMigrate(self, backwards=False): |
2259 """ |
2297 """ |
2260 Private slot to print the SQL statements for a migration of an |
2298 Private slot to print the SQL statements for a migration of an |
2261 application. |
2299 application. |
2262 |
2300 |
2263 @param backwards flag indicating to generate the SQL code to unapply |
2301 @param backwards flag indicating to generate the SQL code to revert |
2264 a migration |
2302 a migration |
2265 @type bool |
2303 @type bool |
2266 """ |
2304 """ |
2267 try: |
2305 try: |
2268 path = self.__sitePath() |
2306 path = self.__sitePath() |
2269 except DjangoNoSiteSelectedException: |
2307 except DjangoNoSiteSelectedException: |
2270 return |
2308 return |
2271 |
2309 |
2272 migrations = self.__getMigrations() |
2310 migrations = self.__getMigrations() |
2273 if not migrations: |
2311 if not migrations: |
2274 E5MessageBox.information( |
2312 EricMessageBox.information( |
2275 None, |
2313 None, |
2276 self.tr("SQL Migrate"), |
2314 self.tr("SQL Migrate"), |
2277 self.tr("""No migrations available.""")) |
2315 self.tr("""No migrations available.""")) |
2278 return |
2316 return |
2279 |
2317 |
2283 DjangoMigrationSelectionDialog |
2321 DjangoMigrationSelectionDialog |
2284 ) |
2322 ) |
2285 dlg = DjangoMigrationSelectionDialog(migrations, |
2323 dlg = DjangoMigrationSelectionDialog(migrations, |
2286 migrationRequired=True, |
2324 migrationRequired=True, |
2287 suffix=self.__iconSuffix) |
2325 suffix=self.__iconSuffix) |
2288 if dlg.exec() == QDialog.Accepted: |
2326 if dlg.exec() == QDialog.DialogCode.Accepted: |
2289 app, migration = dlg.getData() |
2327 app, migration = dlg.getData() |
2290 |
2328 |
2291 args = [] |
2329 args = [] |
2292 args.append(self.__getPythonExecutable()) |
2330 args.append(self.__getPythonExecutable()) |
2293 args.append("manage.py") |
2331 args.append("manage.py") |
2353 """ |
2391 """ |
2354 Private slot to apply selected migrations of a selected app. |
2392 Private slot to apply selected migrations of a selected app. |
2355 """ |
2393 """ |
2356 migrations = self.__getMigrations() |
2394 migrations = self.__getMigrations() |
2357 if not migrations: |
2395 if not migrations: |
2358 E5MessageBox.information( |
2396 EricMessageBox.information( |
2359 None, |
2397 None, |
2360 self.tr("Apply Selected Migrations"), |
2398 self.tr("Apply Selected Migrations"), |
2361 self.tr("""No migrations available.""")) |
2399 self.tr("""No migrations available.""")) |
2362 return |
2400 return |
2363 |
2401 |
2364 from .DjangoMigrationSelectionDialog import ( |
2402 from .DjangoMigrationSelectionDialog import ( |
2365 DjangoMigrationSelectionDialog |
2403 DjangoMigrationSelectionDialog |
2366 ) |
2404 ) |
2367 dlg = DjangoMigrationSelectionDialog(migrations, |
2405 dlg = DjangoMigrationSelectionDialog(migrations, |
2368 suffix=self.__iconSuffix) |
2406 suffix=self.__iconSuffix) |
2369 if dlg.exec() == QDialog.Accepted: |
2407 if dlg.exec() == QDialog.DialogCode.Accepted: |
2370 app, migration = dlg.getData() |
2408 app, migration = dlg.getData() |
2371 self.applyMigrations(app=app, migration=migration) |
2409 self.applyMigrations(app=app, migration=migration) |
2372 |
2410 |
2373 def applyMigrations(self, app=None, migration=None): |
2411 def applyMigrations(self, app=None, migration=None): |
2374 """ |
2412 """ |
2474 """ |
2512 """ |
2475 Private slot to generate migrations for the Django project. |
2513 Private slot to generate migrations for the Django project. |
2476 """ |
2514 """ |
2477 from .DjangoMakeMigrationsDialog import DjangoMakeMigrationsDialog |
2515 from .DjangoMakeMigrationsDialog import DjangoMakeMigrationsDialog |
2478 dlg = DjangoMakeMigrationsDialog(self.getRecentApplications()) |
2516 dlg = DjangoMakeMigrationsDialog(self.getRecentApplications()) |
2479 if dlg.exec() == QDialog.Accepted: |
2517 if dlg.exec() == QDialog.DialogCode.Accepted: |
2480 apps, migration, dryRun, empty, merge = dlg.getData() |
2518 apps, migration, dryRun, empty, merge = dlg.getData() |
2481 if apps: |
2519 if apps: |
2482 self.setMostRecentApplication(apps) |
2520 self.setMostRecentApplication(apps) |
2483 apps = apps.split() |
2521 apps = apps.split() |
2484 self.makeMigrations(apps, migration, dryRun, empty, merge) |
2522 self.makeMigrations(apps, migration, dryRun, empty, merge) |
2531 """ |
2569 """ |
2532 Private slot to squash migrations. |
2570 Private slot to squash migrations. |
2533 """ |
2571 """ |
2534 migrations = self.__getMigrations() |
2572 migrations = self.__getMigrations() |
2535 if not migrations: |
2573 if not migrations: |
2536 E5MessageBox.information( |
2574 EricMessageBox.information( |
2537 None, |
2575 None, |
2538 self.tr("Squash Migrations"), |
2576 self.tr("Squash Migrations"), |
2539 self.tr("""No migrations available.""")) |
2577 self.tr("""No migrations available.""")) |
2540 return |
2578 return |
2541 |
2579 |
2542 from .DjangoSquashMigrationSelectionDialog import ( |
2580 from .DjangoSquashMigrationSelectionDialog import ( |
2543 DjangoSquashMigrationSelectionDialog |
2581 DjangoSquashMigrationSelectionDialog |
2544 ) |
2582 ) |
2545 dlg = DjangoSquashMigrationSelectionDialog( |
2583 dlg = DjangoSquashMigrationSelectionDialog( |
2546 migrations, self, self.__iconSuffix) |
2584 migrations, self, self.__iconSuffix) |
2547 if dlg.exec() == QDialog.Accepted: |
2585 if dlg.exec() == QDialog.DialogCode.Accepted: |
2548 app, start, end, noOptimize, name = dlg.getData() |
2586 app, start, end, noOptimize, name = dlg.getData() |
2549 |
2587 |
2550 title = self.tr("Squash Migrations") |
2588 title = self.tr("Squash Migrations") |
2551 |
2589 |
2552 try: |
2590 try: |
2583 """ |
2621 """ |
2584 title = self.tr("Diff Settings") |
2622 title = self.tr("Diff Settings") |
2585 |
2623 |
2586 from .DjangoDiffsettingsDataDialog import DjangoDiffsettingsDataDialog |
2624 from .DjangoDiffsettingsDataDialog import DjangoDiffsettingsDataDialog |
2587 dlg = DjangoDiffsettingsDataDialog(self, self.__ui) |
2625 dlg = DjangoDiffsettingsDataDialog(self, self.__ui) |
2588 if dlg.exec() == QDialog.Accepted: |
2626 if dlg.exec() == QDialog.DialogCode.Accepted: |
2589 showAll, defaultModule, outputFormat = dlg.getData() |
2627 showAll, defaultModule, outputFormat = dlg.getData() |
2590 |
2628 |
2591 args = [] |
2629 args = [] |
2592 args.append(self.__getPythonExecutable()) |
2630 args.append(self.__getPythonExecutable()) |
2593 args.append("manage.py") |
2631 args.append("manage.py") |
2626 with contextlib.suppress(DjangoNoSiteSelectedException): |
2664 with contextlib.suppress(DjangoNoSiteSelectedException): |
2627 wd = self.__sitePath() |
2665 wd = self.__sitePath() |
2628 self.__adjustWorkingDirectory(args, wd) |
2666 self.__adjustWorkingDirectory(args, wd) |
2629 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
2667 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
2630 if not started: |
2668 if not started: |
2631 E5MessageBox.critical( |
2669 EricMessageBox.critical( |
2632 None, |
2670 None, |
2633 self.tr('Process Generation Error'), |
2671 self.tr('Process Generation Error'), |
2634 self.tr('The Django process could not be started.')) |
2672 self.tr('The Django process could not be started.')) |
2635 |
2673 |
2636 def __sendTestEmail(self): |
2674 def __sendTestEmail(self): |
2641 |
2679 |
2642 from .DjangoSendTestEmailDataDialog import ( |
2680 from .DjangoSendTestEmailDataDialog import ( |
2643 DjangoSendTestEmailDataDialog |
2681 DjangoSendTestEmailDataDialog |
2644 ) |
2682 ) |
2645 dlg = DjangoSendTestEmailDataDialog(self.__ui) |
2683 dlg = DjangoSendTestEmailDataDialog(self.__ui) |
2646 if dlg.exec() == QDialog.Accepted: |
2684 if dlg.exec() == QDialog.DialogCode.Accepted: |
2647 managers, admins, recipients = dlg.getData() |
2685 managers, admins, recipients = dlg.getData() |
2648 |
2686 |
2649 args = [] |
2687 args = [] |
2650 args.append(self.__getPythonExecutable()) |
2688 args.append(self.__getPythonExecutable()) |
2651 args.append("manage.py") |
2689 args.append("manage.py") |
2715 except DjangoNoSiteSelectedException: |
2753 except DjangoNoSiteSelectedException: |
2716 return |
2754 return |
2717 |
2755 |
2718 from .DjangoDumpdataDataDialog import DjangoDumpdataDataDialog |
2756 from .DjangoDumpdataDataDialog import DjangoDumpdataDataDialog |
2719 dlg = DjangoDumpdataDataDialog(self, self.__ui) |
2757 dlg = DjangoDumpdataDataDialog(self, self.__ui) |
2720 if dlg.exec() == QDialog.Accepted: |
2758 if dlg.exec() == QDialog.DialogCode.Accepted: |
2721 appls, excls, dumpFormat, indent = dlg.getData() |
2759 appls, excls, dumpFormat, indent = dlg.getData() |
2722 |
2760 |
2723 args = [] |
2761 args = [] |
2724 args.append(self.__getPythonExecutable()) |
2762 args.append(self.__getPythonExecutable()) |
2725 args.append("manage.py") |
2763 args.append("manage.py") |
2756 except DjangoNoSiteSelectedException: |
2794 except DjangoNoSiteSelectedException: |
2757 return |
2795 return |
2758 |
2796 |
2759 from .DjangoLoaddataDataDialog import DjangoLoaddataDataDialog |
2797 from .DjangoLoaddataDataDialog import DjangoLoaddataDataDialog |
2760 dlg = DjangoLoaddataDataDialog(self, self.__ui) |
2798 dlg = DjangoLoaddataDataDialog(self, self.__ui) |
2761 if dlg.exec() == QDialog.Accepted: |
2799 if dlg.exec() == QDialog.DialogCode.Accepted: |
2762 fixtures, excludes, appLabel, ignore = dlg.getData() |
2800 fixtures, excludes, appLabel, ignore = dlg.getData() |
2763 |
2801 |
2764 args = [] |
2802 args = [] |
2765 args.append(self.__getPythonExecutable()) |
2803 args.append(self.__getPythonExecutable()) |
2766 args.append("manage.py") |
2804 args.append("manage.py") |
2797 |
2835 |
2798 from .DjangoTestDataDialog import DjangoTestDataDialog |
2836 from .DjangoTestDataDialog import DjangoTestDataDialog |
2799 dlg = DjangoTestDataDialog( |
2837 dlg = DjangoTestDataDialog( |
2800 self, self.__plugin.getPreferences("KeepTestDatabase"), |
2838 self, self.__plugin.getPreferences("KeepTestDatabase"), |
2801 self.__ui) |
2839 self.__ui) |
2802 if dlg.exec() == QDialog.Accepted: |
2840 if dlg.exec() == QDialog.DialogCode.Accepted: |
2803 labels, pattern, tags, excludeTags, keep, reverse = ( |
2841 labels, pattern, tags, excludeTags, keep, reverse = ( |
2804 dlg.getData()) |
2842 dlg.getData()) |
2805 |
2843 |
2806 self.__plugin.setPreferences("KeepTestDatabase", keep) |
2844 self.__plugin.setPreferences("KeepTestDatabase", keep) |
2807 |
2845 |
2825 args.extend(labels) |
2863 args.extend(labels) |
2826 |
2864 |
2827 self.__adjustWorkingDirectory(args, wd) |
2865 self.__adjustWorkingDirectory(args, wd) |
2828 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
2866 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
2829 if not started: |
2867 if not started: |
2830 E5MessageBox.critical( |
2868 EricMessageBox.critical( |
2831 None, |
2869 None, |
2832 self.tr('Process Generation Error'), |
2870 self.tr('Process Generation Error'), |
2833 self.tr('The Django process could not be started.')) |
2871 self.tr('The Django process could not be started.')) |
2834 |
2872 |
2835 def __runTestServer(self): |
2873 def __runTestServer(self): |
2842 if consoleCmd: |
2880 if consoleCmd: |
2843 from .DjangoRunTestServerDataDialog import ( |
2881 from .DjangoRunTestServerDataDialog import ( |
2844 DjangoRunTestServerDataDialog |
2882 DjangoRunTestServerDataDialog |
2845 ) |
2883 ) |
2846 dlg = DjangoRunTestServerDataDialog(self, self.__ui) |
2884 dlg = DjangoRunTestServerDataDialog(self, self.__ui) |
2847 if dlg.exec() == QDialog.Accepted: |
2885 if dlg.exec() == QDialog.DialogCode.Accepted: |
2848 fixtures = dlg.getData() |
2886 fixtures = dlg.getData() |
2849 |
2887 |
2850 args = Utilities.parseOptionString(consoleCmd) |
2888 args = Utilities.parseOptionString(consoleCmd) |
2851 args[0] = Utilities.getExecutablePath(args[0]) |
2889 args[0] = Utilities.getExecutablePath(args[0]) |
2852 args.append(self.__getPythonExecutable()) |
2890 args.append(self.__getPythonExecutable()) |
2874 self.__sitePath()) |
2912 self.__sitePath()) |
2875 self.__testServerProc.start(args[0], args[1:]) |
2913 self.__testServerProc.start(args[0], args[1:]) |
2876 serverProcStarted = ( |
2914 serverProcStarted = ( |
2877 self.__testServerProc.waitForStarted()) |
2915 self.__testServerProc.waitForStarted()) |
2878 if not serverProcStarted: |
2916 if not serverProcStarted: |
2879 E5MessageBox.critical( |
2917 EricMessageBox.critical( |
2880 None, |
2918 None, |
2881 self.tr('Process Generation Error'), |
2919 self.tr('Process Generation Error'), |
2882 self.tr('The Django test server could not be' |
2920 self.tr('The Django test server could not be' |
2883 ' started.')) |
2921 ' started.')) |
2884 |
2922 |
2886 """ |
2924 """ |
2887 Private slot connected to the finished signal of the test server. |
2925 Private slot connected to the finished signal of the test server. |
2888 """ |
2926 """ |
2889 if ( |
2927 if ( |
2890 self.__testServerProc is not None and |
2928 self.__testServerProc is not None and |
2891 self.__testServerProc.state() != QProcess.NotRunning |
2929 self.__testServerProc.state() != QProcess.ProcessState.NotRunning |
2892 ): |
2930 ): |
2893 self.__testServerProc.terminate() |
2931 self.__testServerProc.terminate() |
2894 QTimer.singleShot(2000, self.__testServerProc.kill) |
2932 QTimer.singleShot(2000, self.__testServerProc.kill) |
2895 self.__testServerProc.waitForFinished(3000) |
2933 self.__testServerProc.waitForFinished(3000) |
2896 self.__testServerProc = None |
2934 self.__testServerProc = None |
2908 if consoleCmd: |
2946 if consoleCmd: |
2909 userName, ok = QInputDialog.getText( |
2947 userName, ok = QInputDialog.getText( |
2910 self.__ui, |
2948 self.__ui, |
2911 self.tr("Change Password"), |
2949 self.tr("Change Password"), |
2912 self.tr("Enter the name of the user:"), |
2950 self.tr("Enter the name of the user:"), |
2913 QLineEdit.Normal) |
2951 QLineEdit.EchoMode.Normal) |
2914 if ok and userName != "": |
2952 if ok and userName != "": |
2915 args = Utilities.parseOptionString(consoleCmd) |
2953 args = Utilities.parseOptionString(consoleCmd) |
2916 args[0] = Utilities.getExecutablePath(args[0]) |
2954 args[0] = Utilities.getExecutablePath(args[0]) |
2917 args.append(self.__getPythonExecutable()) |
2955 args.append(self.__getPythonExecutable()) |
2918 args.append("manage.py") |
2956 args.append("manage.py") |
2922 wd = self.__sitePath() |
2960 wd = self.__sitePath() |
2923 self.__adjustWorkingDirectory(args, wd) |
2961 self.__adjustWorkingDirectory(args, wd) |
2924 started, pid = QProcess.startDetached( |
2962 started, pid = QProcess.startDetached( |
2925 args[0], args[1:], wd) |
2963 args[0], args[1:], wd) |
2926 if not started: |
2964 if not started: |
2927 E5MessageBox.critical( |
2965 EricMessageBox.critical( |
2928 None, |
2966 None, |
2929 self.tr('Process Generation Error'), |
2967 self.tr('Process Generation Error'), |
2930 self.tr('The Django process could not be' |
2968 self.tr('The Django process could not be' |
2931 ' started.')) |
2969 ' started.')) |
2932 |
2970 |
2945 with contextlib.suppress(DjangoNoSiteSelectedException): |
2983 with contextlib.suppress(DjangoNoSiteSelectedException): |
2946 wd = self.__sitePath() |
2984 wd = self.__sitePath() |
2947 self.__adjustWorkingDirectory(args, wd) |
2985 self.__adjustWorkingDirectory(args, wd) |
2948 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
2986 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
2949 if not started: |
2987 if not started: |
2950 E5MessageBox.critical( |
2988 EricMessageBox.critical( |
2951 None, |
2989 None, |
2952 self.tr('Process Generation Error'), |
2990 self.tr('Process Generation Error'), |
2953 self.tr('The Django process could not be started.')) |
2991 self.tr('The Django process could not be started.')) |
2954 |
2992 |
2955 ################################################################## |
2993 ################################################################## |
2985 |
3023 |
2986 def __getLocale(self, filename): |
3024 def __getLocale(self, filename): |
2987 """ |
3025 """ |
2988 Private method to extract the locale out of a file name. |
3026 Private method to extract the locale out of a file name. |
2989 |
3027 |
2990 @param filename name of the file used for extraction (string) |
3028 @param filename name of the file used for extraction |
2991 @return extracted locale (string) or None |
3029 @type str |
2992 """ |
3030 @return extracted locale or None |
2993 if self.__e5project.getTranslationPattern(): |
3031 @rtype str |
|
3032 """ |
|
3033 if self.__ericProject.getTranslationPattern(): |
2994 pattern = ( |
3034 pattern = ( |
2995 self.__e5project.getTranslationPattern() |
3035 self.__ericProject.getTranslationPattern() |
2996 .replace("%language%", "(.*?)") |
3036 .replace("%language%", "(.*?)") |
2997 ) |
3037 ) |
2998 match = re.search(pattern, filename) |
3038 match = re.search(pattern, filename) |
2999 if match is not None: |
3039 if match is not None: |
3000 loc = match.group(1) |
3040 loc = match.group(1) |
3008 |
3048 |
3009 def __normalizeList(self, filenames): |
3049 def __normalizeList(self, filenames): |
3010 """ |
3050 """ |
3011 Private method to normalize a list of file names. |
3051 Private method to normalize a list of file names. |
3012 |
3052 |
3013 @param filenames list of file names to normalize (list of strings) |
3053 @param filenames list of file names to normalize |
3014 @return normalized file names (list of strings) |
3054 @type list of str |
|
3055 @return normalized file names |
|
3056 @rtype list of str |
3015 """ |
3057 """ |
3016 nfilenames = [] |
3058 nfilenames = [] |
3017 for filename in filenames: |
3059 for filename in filenames: |
3018 if filename.endswith(".mo"): |
3060 if filename.endswith(".mo"): |
3019 filename = filename.replace(".mo", ".po") |
3061 filename = filename.replace(".mo", ".po") |
3024 |
3066 |
3025 def __siteFilteredList(self, filenames): |
3067 def __siteFilteredList(self, filenames): |
3026 """ |
3068 """ |
3027 Private method to filter a list of file names by site. |
3069 Private method to filter a list of file names by site. |
3028 |
3070 |
3029 @param filenames list of file names to be filtered (list of strings) |
3071 @param filenames list of file names to be filtered |
3030 @return file names belonging to the current site (list of strings) |
3072 @type list of str |
|
3073 @return file names belonging to the current site |
|
3074 @rtype list of str |
3031 """ |
3075 """ |
3032 site = self.__site() |
3076 site = self.__site() |
3033 nfilenames = [] |
3077 nfilenames = [] |
3034 for filename in filenames: |
3078 for filename in filenames: |
3035 if site == "" or filename.startswith(site + os.sep): |
3079 if site == "" or filename.startswith(site + os.sep): |
3071 res = dia.startProcess(args, wd) |
3116 res = dia.startProcess(args, wd) |
3072 if res: |
3117 if res: |
3073 dia.exec() |
3118 dia.exec() |
3074 |
3119 |
3075 langFile = ( |
3120 langFile = ( |
3076 self.__e5project.getTranslationPattern() |
3121 self.__ericProject.getTranslationPattern() |
3077 .replace("%language%", code) |
3122 .replace("%language%", code) |
3078 ) |
3123 ) |
3079 self.__e5project.appendFile(langFile) |
3124 self.__ericProject.appendFile(langFile) |
3080 |
3125 |
3081 def updateSelectedCatalogs(self, filenames): |
3126 def updateSelectedCatalogs(self, filenames): |
3082 """ |
3127 """ |
3083 Public method to update the message catalogs. |
3128 Public method to update the message catalogs. |
3084 |
3129 |
3085 @param filenames list of file names (list of strings) |
3130 @param filenames list of file names |
|
3131 @type list of str |
3086 """ |
3132 """ |
3087 title = self.tr("Updating message catalogs") |
3133 title = self.tr("Updating message catalogs") |
3088 |
3134 |
3089 try: |
3135 try: |
3090 wd = self.__sitePath() |
3136 wd = self.__sitePath() |
3091 except DjangoNoSiteSelectedException: |
3137 except DjangoNoSiteSelectedException: |
3092 E5MessageBox.warning( |
3138 EricMessageBox.warning( |
3093 None, |
3139 None, |
3094 title, |
3140 title, |
3095 self.tr('No current site selected or no site created yet.' |
3141 self.tr('No current site selected or no site created yet.' |
3096 ' Aborting...')) |
3142 ' Aborting...')) |
3097 return |
3143 return |
3127 def updateSelectedCatalogsWithObsolete(self, filenames): |
3173 def updateSelectedCatalogsWithObsolete(self, filenames): |
3128 """ |
3174 """ |
3129 Public method to update the message catalogs keeping obsolete messages. |
3175 Public method to update the message catalogs keeping obsolete messages. |
3130 |
3176 |
3131 @param filenames list of filenames |
3177 @param filenames list of filenames |
|
3178 @type list of str |
3132 """ |
3179 """ |
3133 title = self.tr("Updating message catalogs (keeping obsolete" |
3180 title = self.tr("Updating message catalogs (keeping obsolete" |
3134 " messages)") |
3181 " messages)") |
3135 |
3182 |
3136 try: |
3183 try: |
3137 wd = self.__sitePath() |
3184 wd = self.__sitePath() |
3138 except DjangoNoSiteSelectedException: |
3185 except DjangoNoSiteSelectedException: |
3139 E5MessageBox.warning( |
3186 EricMessageBox.warning( |
3140 None, |
3187 None, |
3141 title, |
3188 title, |
3142 self.tr('No current site selected or no site created yet.' |
3189 self.tr('No current site selected or no site created yet.' |
3143 ' Aborting...')) |
3190 ' Aborting...')) |
3144 return |
3191 return |
3237 def compileSelectedCatalogs(self, filenames): |
3286 def compileSelectedCatalogs(self, filenames): |
3238 """ |
3287 """ |
3239 Public method to update the message catalogs. |
3288 Public method to update the message catalogs. |
3240 |
3289 |
3241 @param filenames list of filenames |
3290 @param filenames list of filenames |
|
3291 @type list of str |
3242 """ |
3292 """ |
3243 title = self.tr("Compiling message catalogs") |
3293 title = self.tr("Compiling message catalogs") |
3244 |
3294 |
3245 try: |
3295 try: |
3246 wd = self.__sitePath() |
3296 wd = self.__sitePath() |
3247 except DjangoNoSiteSelectedException: |
3297 except DjangoNoSiteSelectedException: |
3248 E5MessageBox.warning( |
3298 EricMessageBox.warning( |
3249 None, |
3299 None, |
3250 title, |
3300 title, |
3251 self.tr('No current site selected or no site created yet.' |
3301 self.tr('No current site selected or no site created yet.' |
3252 ' Aborting...')) |
3302 ' Aborting...')) |
3253 return |
3303 return |
3284 |
3334 |
3285 for entry in os.walk(self.__sitePath()): |
3335 for entry in os.walk(self.__sitePath()): |
3286 for fileName in entry[2]: |
3336 for fileName in entry[2]: |
3287 fullName = os.path.join(entry[0], fileName) |
3337 fullName = os.path.join(entry[0], fileName) |
3288 if fullName.endswith('.mo'): |
3338 if fullName.endswith('.mo'): |
3289 self.__e5project.appendFile(fullName) |
3339 self.__ericProject.appendFile(fullName) |
3290 |
3340 |
3291 def compileCatalogs(self, filenames): |
3341 def compileCatalogs(self, filenames): |
3292 """ |
3342 """ |
3293 Public method to compile the message catalogs. |
3343 Public method to compile the message catalogs. |
3294 |
3344 |
3295 @param filenames list of filenames (not used) |
3345 @param filenames list of filenames (not used) |
|
3346 @type list of str |
3296 """ |
3347 """ |
3297 title = self.tr("Compiling message catalogs") |
3348 title = self.tr("Compiling message catalogs") |
3298 |
3349 |
3299 args = [] |
3350 args = [] |
3300 args.append(self.__getPythonExecutable()) |
3351 args.append(self.__getPythonExecutable()) |
3323 |
3374 |
3324 for entry in os.walk(self.__sitePath()): |
3375 for entry in os.walk(self.__sitePath()): |
3325 for fileName in entry[2]: |
3376 for fileName in entry[2]: |
3326 fullName = os.path.join(entry[0], fileName) |
3377 fullName = os.path.join(entry[0], fileName) |
3327 if fullName.endswith('.mo'): |
3378 if fullName.endswith('.mo'): |
3328 self.__e5project.appendFile(fullName) |
3379 self.__ericProject.appendFile(fullName) |
3329 |
3380 |
3330 def openPOEditor(self, poFile): |
3381 def openPOEditor(self, poFile): |
3331 """ |
3382 """ |
3332 Public method to edit the given file in an external .po editor. |
3383 Public method to edit the given file in an external .po editor. |
3333 |
3384 |
3334 @param poFile name of the .po file (string) |
3385 @param poFile name of the .po file |
|
3386 @type str |
3335 """ |
3387 """ |
3336 editor = self.__plugin.getPreferences("TranslationsEditor") |
3388 editor = self.__plugin.getPreferences("TranslationsEditor") |
3337 if poFile.endswith(".po") and editor: |
3389 if poFile.endswith(".po") and editor: |
3338 try: |
3390 try: |
3339 wd = self.__sitePath() |
3391 wd = self.__sitePath() |
3340 except DjangoNoSiteSelectedException: |
3392 except DjangoNoSiteSelectedException: |
3341 wd = "" |
3393 wd = "" |
3342 started, pid = QProcess.startDetached(editor, [poFile], wd) |
3394 started, pid = QProcess.startDetached(editor, [poFile], wd) |
3343 if not started: |
3395 if not started: |
3344 E5MessageBox.critical( |
3396 EricMessageBox.critical( |
3345 None, |
3397 None, |
3346 self.tr('Process Generation Error'), |
3398 self.tr('Process Generation Error'), |
3347 self.tr('The translations editor process ({0}) could' |
3399 self.tr('The translations editor process ({0}) could' |
3348 ' not be started.') |
3400 ' not be started.') |
3349 .format(os.path.basename(editor))) |
3401 .format(os.path.basename(editor))) |
3364 from .DjangoCheckOptionsDialog import DjangoCheckOptionsDialog |
3416 from .DjangoCheckOptionsDialog import DjangoCheckOptionsDialog |
3365 dlg = DjangoCheckOptionsDialog( |
3417 dlg = DjangoCheckOptionsDialog( |
3366 self.__getPythonExecutable(), path, self.getRecentApplications(), |
3418 self.__getPythonExecutable(), path, self.getRecentApplications(), |
3367 self.__plugin.getPreferences("CheckDeployMode"), |
3419 self.__plugin.getPreferences("CheckDeployMode"), |
3368 ) |
3420 ) |
3369 if dlg.exec() == QDialog.Accepted: |
3421 if dlg.exec() == QDialog.DialogCode.Accepted: |
3370 deploy, tags, appsStr, settingsFile = dlg.getData() |
3422 deploy, tags, appsStr, settingsFile = dlg.getData() |
3371 self.__plugin.setPreferences("CheckDeployMode", deploy) |
3423 self.__plugin.setPreferences("CheckDeployMode", deploy) |
3372 if appsStr != "": |
3424 if appsStr != "": |
3373 self.setMostRecentApplication(appsStr) |
3425 self.setMostRecentApplication(appsStr) |
3374 apps = appsStr.split() |
3426 apps = appsStr.split() |