1097 def projectOpenedHooks(self): |
1097 def projectOpenedHooks(self): |
1098 """ |
1098 """ |
1099 Public method to add our hook methods. |
1099 Public method to add our hook methods. |
1100 """ |
1100 """ |
1101 if self.__e5project.getProjectType() == "Django": |
1101 if self.__e5project.getProjectType() == "Django": |
1102 self.__formsBrowser = \ |
1102 self.__formsBrowser = ( |
1103 e5App().getObject("ProjectBrowser").getProjectBrowser("forms") |
1103 e5App().getObject("ProjectBrowser").getProjectBrowser("forms") |
|
1104 ) |
1104 self.__formsBrowser.addHookMethodAndMenuEntry( |
1105 self.__formsBrowser.addHookMethodAndMenuEntry( |
1105 "newForm", |
1106 "newForm", |
1106 self.newForm, self.tr("New template...")) |
1107 self.newForm, self.tr("New template...")) |
1107 |
1108 |
1108 self.__e5project.projectLanguageAddedByCode.connect( |
1109 self.__e5project.projectLanguageAddedByCode.connect( |
1109 self.__projectLanguageAdded) |
1110 self.__projectLanguageAdded) |
1110 self.__translationsBrowser = \ |
1111 self.__translationsBrowser = ( |
1111 e5App().getObject("ProjectBrowser")\ |
1112 e5App().getObject("ProjectBrowser") |
1112 .getProjectBrowser("translations") |
1113 .getProjectBrowser("translations")) |
1113 self.__translationsBrowser.addHookMethodAndMenuEntry( |
1114 self.__translationsBrowser.addHookMethodAndMenuEntry( |
1114 "generateAll", |
1115 "generateAll", |
1115 self.updateCatalogs, self.tr("Update all catalogs")) |
1116 self.updateCatalogs, self.tr("Update all catalogs")) |
1116 self.__translationsBrowser.addHookMethodAndMenuEntry( |
1117 self.__translationsBrowser.addHookMethodAndMenuEntry( |
1117 "generateSelected", |
1118 "generateSelected", |
1277 if os.access(exe, os.X_OK) and exe not in paths: |
1278 if os.access(exe, os.X_OK) and exe not in paths: |
1278 paths.append(exe) |
1279 paths.append(exe) |
1279 |
1280 |
1280 return paths |
1281 return paths |
1281 |
1282 |
|
1283 # TODO: eliminate Python2 |
1282 def supportedPythonVariants(self): |
1284 def supportedPythonVariants(self): |
1283 """ |
1285 """ |
1284 Public method to get the supported Python variants. |
1286 Public method to get the supported Python variants. |
1285 |
1287 |
1286 @return list of supported Python variants (list of strings) |
1288 @return list of supported Python variants (list of strings) |
1287 """ |
1289 """ |
1288 variants = [] |
1290 variants = [] |
1289 for variant in 'Python2', 'Python3': |
1291 for variant in ['Python3']: |
1290 virtEnv = self.__getVirtualEnvironment(variant) |
1292 virtEnv = self.__getVirtualEnvironment(variant) |
1291 if virtEnv: |
1293 if virtEnv: |
1292 if self.__getDjangoAdminCommand(variant): |
1294 if self.__getDjangoAdminCommand(variant): |
1293 variants.append(variant) |
1295 variants.append(variant) |
1294 else: |
1296 else: |
1313 variants.append(variant) |
1315 variants.append(variant) |
1314 break |
1316 break |
1315 |
1317 |
1316 return variants |
1318 return variants |
1317 |
1319 |
|
1320 # TODO: eliminate Python2 |
1318 def __isSuitableForVariant(self, variant, line0): |
1321 def __isSuitableForVariant(self, variant, line0): |
1319 """ |
1322 """ |
1320 Private method to test, if a detected command file is suitable for the |
1323 Private method to test, if a detected command file is suitable for the |
1321 given Python variant. |
1324 given Python variant. |
1322 |
1325 |
1323 @param variant Python variant to test for |
1326 @param variant Python variant to test for |
1324 @type str (one of Python2 or Python3) |
1327 @type str |
1325 @param line0 first line of the executable |
1328 @param line0 first line of the executable |
1326 @type str |
1329 @type str |
1327 """ |
1330 @return flag indicating a suitable file was found |
1328 assert variant in ("Python2", "Python3") |
1331 @rtype bool |
1329 |
1332 """ |
1330 l0 = line0.lower() |
1333 l0 = line0.lower() |
1331 ok = (variant.lower() in l0 or |
1334 ok = (variant.lower() in l0 or |
1332 "{0}.".format(variant[-1]) in l0) |
1335 "{0}.".format(variant[-1]) in l0) |
1333 if variant == "Python2": |
1336 ok |= "pypy3" in l0 |
1334 ok |= "python3" not in l0 and "python" in l0 |
|
1335 ok |= "pypy2" in l0 |
|
1336 ok |= "pypy3" not in l0 and "pypy" in l0 |
|
1337 else: |
|
1338 ok |= "pypy3" in l0 |
|
1339 |
1337 |
1340 return ok |
1338 return ok |
1341 |
1339 |
1342 def __getVirtualEnvironment(self, language=""): |
1340 def __getVirtualEnvironment(self, language=""): |
1343 """ |
1341 """ |
1344 Private method to get the path of the virtual environment. |
1342 Private method to get the path of the virtual environment. |
1345 |
1343 |
1346 @param language Python variant to get the virtual environment |
1344 @param language Python variant to get the virtual environment |
1347 for (string, one of '', 'Python2' or 'Python3') |
1345 for (string, one of '' or 'Python3') |
1348 @return path of the virtual environment (string) |
1346 @return path of the virtual environment (string) |
1349 """ |
1347 """ |
1350 if not language: |
1348 if not language: |
1351 language = self.__e5project.getProjectLanguage() |
1349 language = self.__e5project.getProjectLanguage() |
1352 if self.__virtualEnvManager: |
1350 if self.__virtualEnvManager: |
1353 if language == "Python3": |
1351 if language == "Python3": |
1354 venvName = self.__plugin.getPreferences( |
1352 venvName = self.__plugin.getPreferences( |
1355 "VirtualEnvironmentNamePy3") |
1353 "VirtualEnvironmentNamePy3") |
1356 elif language == "Python2": |
|
1357 venvName = self.__plugin.getPreferences( |
|
1358 "VirtualEnvironmentNamePy2") |
|
1359 else: |
1354 else: |
1360 venvName = "" |
1355 venvName = "" |
1361 if venvName: |
1356 if venvName: |
1362 virtEnv = self.__virtualEnvManager.getVirtualenvDirectory( |
1357 virtEnv = self.__virtualEnvManager.getVirtualenvDirectory( |
1363 venvName) |
1358 venvName) |
1384 def __getDebugEnvironment(self, language=""): |
1377 def __getDebugEnvironment(self, language=""): |
1385 """ |
1378 """ |
1386 Private method to get the path of the debugger environment. |
1379 Private method to get the path of the debugger environment. |
1387 |
1380 |
1388 @param language Python variant to get the debugger environment |
1381 @param language Python variant to get the debugger environment |
1389 for (string, one of '', 'Python2' or 'Python3') |
1382 for (string, one of '' or 'Python3') |
1390 @return path of the debugger environment (string) |
1383 @return path of the debugger environment (string) |
1391 """ |
1384 """ |
1392 if not language: |
1385 if not language: |
1393 language = self.__e5project.getProjectLanguage() |
1386 language = self.__e5project.getProjectLanguage() |
1394 if self.__virtualEnvManager: |
1387 if self.__virtualEnvManager: |
1395 debugEnv = self.__getVirtualEnvironment(language) |
1388 debugEnv = self.__getVirtualEnvironment(language) |
1396 if not debugEnv: |
1389 if not debugEnv: |
1397 if language == "Python3": |
1390 if language == "Python3": |
1398 venvName = Preferences.getDebugger("Python3VirtualEnv") |
1391 venvName = Preferences.getDebugger("Python3VirtualEnv") |
1399 elif language == "Python2": |
|
1400 venvName = Preferences.getDebugger("Python2VirtualEnv") |
|
1401 else: |
1392 else: |
1402 venvName = "" |
1393 venvName = "" |
1403 |
1394 |
1404 if venvName: |
1395 if venvName: |
1405 debugEnv = self.__virtualEnvManager.getVirtualenvDirectory( |
1396 debugEnv = self.__virtualEnvManager.getVirtualenvDirectory( |
1408 debugEnv = "" |
1399 debugEnv = "" |
1409 else: |
1400 else: |
1410 # backward compatibility |
1401 # backward compatibility |
1411 if language == "Python3": |
1402 if language == "Python3": |
1412 debugEnv = Preferences.getDebugger("Python3Interpreter") |
1403 debugEnv = Preferences.getDebugger("Python3Interpreter") |
1413 if not debugEnv and sys.version_info[0] == 3: |
1404 if not debugEnv and sys.version_info[0] >= 3: |
1414 debugEnv = sys.executable |
|
1415 elif language == "Python2": |
|
1416 debugEnv = Preferences.getDebugger("PythonInterpreter") |
|
1417 if not debugEnv and sys.version_info[0] == 2: |
|
1418 debugEnv = sys.executable |
1405 debugEnv = sys.executable |
1419 else: |
1406 else: |
1420 debugEnv = sys.executable |
1407 debugEnv = sys.executable |
1421 debugEnv = os.path.dirname(debugEnv) |
1408 debugEnv = os.path.dirname(debugEnv) |
1422 if debugEnv and not os.path.exists(debugEnv): |
1409 if debugEnv and not os.path.exists(debugEnv): |
1423 if (language == "Python3" and sys.version_info[0] == 3) or \ |
1410 if language == "Python3" and sys.version_info[0] >= 3: |
1424 (language == "Python2" and sys.version_info[0] == 2): |
|
1425 debugEnv = sys.exec_prefix |
1411 debugEnv = sys.exec_prefix |
1426 else: |
1412 else: |
1427 debugEnv = "" |
1413 debugEnv = "" |
1428 return debugEnv |
1414 return debugEnv |
1429 |
1415 |
1430 def __getDjangoAdminCommand(self, language=""): |
1416 def __getDjangoAdminCommand(self, language=""): |
1431 """ |
1417 """ |
1432 Private method to build a django-admin.py command. |
1418 Private method to build a django-admin.py command. |
1433 |
1419 |
1434 @param language Python variant to get the django-admin.py |
1420 @param language Python variant to get the django-admin.py |
1435 command for (string, one of '', 'Python2' or 'Python3') |
1421 command for (string, one of '' or 'Python3') |
1436 @return full django-admin.py command (string) |
1422 @return full django-admin.py command (string) |
1437 """ |
1423 """ |
1438 if not language: |
1424 if not language: |
1439 language = self.__e5project.getProjectLanguage() |
1425 language = self.__e5project.getProjectLanguage() |
1440 |
1426 |
1476 if os.path.exists(cmd): |
1462 if os.path.exists(cmd): |
1477 break |
1463 break |
1478 else: |
1464 else: |
1479 cmd = "" |
1465 cmd = "" |
1480 else: |
1466 else: |
1481 if language == "Python2": |
1467 if language == "Python3": |
1482 cmds = ["django-admin2.py", "django-admin2", |
|
1483 "django-admin.py-2.7", "django-admin.py-2.6" |
|
1484 ] |
|
1485 elif language == "Python3": |
|
1486 cmds = ["django-admin3.py", "django-admin3", |
1468 cmds = ["django-admin3.py", "django-admin3", |
1487 "django-admin.py-3.7", "django-admin.py-3.6", |
1469 "django-admin.py-3.7", "django-admin.py-3.6", |
1488 "django-admin.py-3.5", "django-admin.py-3.4", |
1470 "django-admin.py-3.5", "django-admin.py-3.4", |
1489 "django-admin.py-3.3", "django-admin.py-3.2", |
1471 "django-admin.py-3.3", "django-admin.py-3.2", |
1490 ] |
1472 ] |
1511 venvName = self.__plugin.getPreferences( |
1493 venvName = self.__plugin.getPreferences( |
1512 "VirtualEnvironmentNamePy3") |
1494 "VirtualEnvironmentNamePy3") |
1513 if not venvName: |
1495 if not venvName: |
1514 # if none configured, use the global one |
1496 # if none configured, use the global one |
1515 venvName = Preferences.getDebugger("Python3VirtualEnv") |
1497 venvName = Preferences.getDebugger("Python3VirtualEnv") |
1516 elif language == "Python2": |
|
1517 venvName = self.__plugin.getPreferences( |
|
1518 "VirtualEnvironmentNamePy2") |
|
1519 if not venvName: |
|
1520 # if none configured, use the global one |
|
1521 venvName = Preferences.getDebugger("Python2VirtualEnv") |
|
1522 else: |
1498 else: |
1523 venvName = "" |
1499 venvName = "" |
1524 if venvName: |
1500 if venvName: |
1525 python = self.__virtualEnvManager.getVirtualenvInterpreter( |
1501 python = self.__virtualEnvManager.getVirtualenvInterpreter( |
1526 venvName) |
1502 venvName) |
1706 self.__recentApplications.remove(applStr) |
1679 self.__recentApplications.remove(applStr) |
1707 self.__recentApplications.insert(0, applStr) |
1680 self.__recentApplications.insert(0, applStr) |
1708 |
1681 |
1709 maxRecentApps = self.__plugin.getPreferences("RecentNumberApps") |
1682 maxRecentApps = self.__plugin.getPreferences("RecentNumberApps") |
1710 if len(self.__recentApplications) > maxRecentApps: |
1683 if len(self.__recentApplications) > maxRecentApps: |
1711 self.__recentApplications = \ |
1684 self.__recentApplications = ( |
1712 self.__recentApplications[:maxRecentApps] |
1685 self.__recentApplications[:maxRecentApps]) |
1713 self.__saveRecentApplications() |
1686 self.__saveRecentApplications() |
1714 |
1687 |
1715 def __loadRecentTestData(self): |
1688 def __loadRecentTestData(self): |
1716 """ |
1689 """ |
1717 Private method to load the recently used test data lists. |
1690 Private method to load the recently used test data lists. |
1764 self.__recentTestData[key].insert(0, data) |
1737 self.__recentTestData[key].insert(0, data) |
1765 |
1738 |
1766 maxRecentTestData = self.__plugin.getPreferences( |
1739 maxRecentTestData = self.__plugin.getPreferences( |
1767 "RecentNumberTestData") |
1740 "RecentNumberTestData") |
1768 if len(self.__recentTestData[key]) > maxRecentTestData: |
1741 if len(self.__recentTestData[key]) > maxRecentTestData: |
1769 self.__recentTestData[key] = \ |
1742 self.__recentTestData[key] = ( |
1770 self.__recentTestData[key][:maxRecentTestData] |
1743 self.__recentTestData[key][:maxRecentTestData]) |
1771 self.__saveRecentTestData() |
1744 self.__saveRecentTestData() |
1772 |
1745 |
1773 def getProjectPath(self): |
1746 def getProjectPath(self): |
1774 """ |
1747 """ |
1775 Public method to get the path of the eric6 project. |
1748 Public method to get the path of the eric6 project. |
1918 # create the base directory for translations |
1891 # create the base directory for translations |
1919 i18nPath = os.path.join(path, projectName, "locale") |
1892 i18nPath = os.path.join(path, projectName, "locale") |
1920 if not os.path.exists(i18nPath): |
1893 if not os.path.exists(i18nPath): |
1921 os.makedirs(i18nPath) |
1894 os.makedirs(i18nPath) |
1922 |
1895 |
1923 if os.path.join(path, projectName) == \ |
1896 if ( |
1924 self.__e5project.getProjectPath(): |
1897 os.path.join(path, projectName) == |
|
1898 self.__e5project.getProjectPath() |
|
1899 ): |
1925 self.__setCurrentSite("") |
1900 self.__setCurrentSite("") |
1926 else: |
1901 else: |
1927 self.__setCurrentSite(projectName) |
1902 self.__setCurrentSite(projectName) |
1928 |
1903 |
1929 return res |
1904 return res |
1979 self.__ui, |
1954 self.__ui, |
1980 title, |
1955 title, |
1981 self.tr("""<p>The <b>django-admin.py</b> script""" |
1956 self.tr("""<p>The <b>django-admin.py</b> script""" |
1982 """ is not in the path.""" |
1957 """ is not in the path.""" |
1983 """ Aborting...</p>""")) |
1958 """ Aborting...</p>""")) |
1984 return |
1959 return False |
1985 else: |
1960 else: |
1986 args.append(self.__getPythonExecutable()) |
1961 args.append(self.__getPythonExecutable()) |
1987 args.append("manage.py") |
1962 args.append("manage.py") |
1988 try: |
1963 try: |
1989 path = self.__sitePath() |
1964 path = self.__sitePath() |
2200 |
2175 |
2201 def __serverProcFinished(self): |
2176 def __serverProcFinished(self): |
2202 """ |
2177 """ |
2203 Private slot connected to the finished signal. |
2178 Private slot connected to the finished signal. |
2204 """ |
2179 """ |
2205 if self.__serverProc is not None and \ |
2180 if ( |
2206 self.__serverProc.state() != QProcess.NotRunning: |
2181 self.__serverProc is not None and |
|
2182 self.__serverProc.state() != QProcess.NotRunning |
|
2183 ): |
2207 self.__serverProc.terminate() |
2184 self.__serverProc.terminate() |
2208 QTimer.singleShot(2000, self.__serverProc.kill) |
2185 QTimer.singleShot(2000, self.__serverProc.kill) |
2209 self.__serverProc.waitForFinished(3000) |
2186 self.__serverProc.waitForFinished(3000) |
2210 self.__serverProc = None |
2187 self.__serverProc = None |
2211 |
2188 |
2256 """ |
2233 """ |
2257 self.__recentDatabaseNames = [""] |
2234 self.__recentDatabaseNames = [""] |
2258 Preferences.Prefs.rsettings.sync() |
2235 Preferences.Prefs.rsettings.sync() |
2259 rdb = Preferences.Prefs.rsettings.value(self.RecentDatabaseNamesKey) |
2236 rdb = Preferences.Prefs.rsettings.value(self.RecentDatabaseNamesKey) |
2260 if rdb is not None: |
2237 if rdb is not None: |
2261 maxRecentDatabaseNames = \ |
2238 maxRecentDatabaseNames = ( |
2262 self.__plugin.getPreferences("RecentNumberDatabaseNames") |
2239 self.__plugin.getPreferences("RecentNumberDatabaseNames")) |
2263 self.__recentDatabaseNames = rdb[:maxRecentDatabaseNames] |
2240 self.__recentDatabaseNames = rdb[:maxRecentDatabaseNames] |
2264 |
2241 |
2265 def __saveRecentDatabaseNames(self): |
2242 def __saveRecentDatabaseNames(self): |
2266 """ |
2243 """ |
2267 Private method to save the list of recently used database names. |
2244 Private method to save the list of recently used database names. |
2289 """ |
2266 """ |
2290 if dbName in self.__recentDatabaseNames: |
2267 if dbName in self.__recentDatabaseNames: |
2291 self.__recentDatabaseNames.remove(dbName) |
2268 self.__recentDatabaseNames.remove(dbName) |
2292 self.__recentDatabaseNames.insert(0, dbName) |
2269 self.__recentDatabaseNames.insert(0, dbName) |
2293 |
2270 |
2294 maxRecentDatabaseNames = \ |
2271 maxRecentDatabaseNames = ( |
2295 self.__plugin.getPreferences("RecentNumberDatabaseNames") |
2272 self.__plugin.getPreferences("RecentNumberDatabaseNames")) |
2296 if len(self.__recentDatabaseNames) > maxRecentDatabaseNames: |
2273 if len(self.__recentDatabaseNames) > maxRecentDatabaseNames: |
2297 self.__recentDatabaseNames = \ |
2274 self.__recentDatabaseNames = ( |
2298 self.__recentDatabaseNames[:maxRecentDatabaseNames] |
2275 self.__recentDatabaseNames[:maxRecentDatabaseNames]) |
2299 self.__saveRecentDatabaseNames() |
2276 self.__saveRecentDatabaseNames() |
2300 |
2277 |
2301 def __selectDatabaseName(self): |
2278 def __selectDatabaseName(self): |
2302 """ |
2279 """ |
2303 Private method to select the name of the database to work with. |
2280 Private method to select the name of the database to work with. |
2563 self.tr("""No migrations available.""")) |
2540 self.tr("""No migrations available.""")) |
2564 return |
2541 return |
2565 |
2542 |
2566 title = self.tr("SQL Migrate") |
2543 title = self.tr("SQL Migrate") |
2567 |
2544 |
2568 from .DjangoMigrationSelectionDialog import \ |
2545 from .DjangoMigrationSelectionDialog import ( |
2569 DjangoMigrationSelectionDialog |
2546 DjangoMigrationSelectionDialog |
|
2547 ) |
2570 dlg = DjangoMigrationSelectionDialog(migrations, |
2548 dlg = DjangoMigrationSelectionDialog(migrations, |
2571 migrationRequired=True, |
2549 migrationRequired=True, |
2572 suffix=self.__iconSuffix) |
2550 suffix=self.__iconSuffix) |
2573 if dlg.exec_() == QDialog.Accepted: |
2551 if dlg.exec_() == QDialog.Accepted: |
2574 app, migration = dlg.getData() |
2552 app, migration = dlg.getData() |
2644 None, |
2622 None, |
2645 self.tr("Apply Selected Migrations"), |
2623 self.tr("Apply Selected Migrations"), |
2646 self.tr("""No migrations available.""")) |
2624 self.tr("""No migrations available.""")) |
2647 return |
2625 return |
2648 |
2626 |
2649 from .DjangoMigrationSelectionDialog import \ |
2627 from .DjangoMigrationSelectionDialog import ( |
2650 DjangoMigrationSelectionDialog |
2628 DjangoMigrationSelectionDialog |
|
2629 ) |
2651 dlg = DjangoMigrationSelectionDialog(migrations, |
2630 dlg = DjangoMigrationSelectionDialog(migrations, |
2652 suffix=self.__iconSuffix) |
2631 suffix=self.__iconSuffix) |
2653 if dlg.exec_() == QDialog.Accepted: |
2632 if dlg.exec_() == QDialog.Accepted: |
2654 app, migration = dlg.getData() |
2633 app, migration = dlg.getData() |
2655 self.applyMigrations(app=app, migration=migration) |
2634 self.applyMigrations(app=app, migration=migration) |
2822 None, |
2801 None, |
2823 self.tr("Squash Migrations"), |
2802 self.tr("Squash Migrations"), |
2824 self.tr("""No migrations available.""")) |
2803 self.tr("""No migrations available.""")) |
2825 return |
2804 return |
2826 |
2805 |
2827 from .DjangoSquashMigrationSelectionDialog import \ |
2806 from .DjangoSquashMigrationSelectionDialog import ( |
2828 DjangoSquashMigrationSelectionDialog |
2807 DjangoSquashMigrationSelectionDialog |
|
2808 ) |
2829 dlg = DjangoSquashMigrationSelectionDialog( |
2809 dlg = DjangoSquashMigrationSelectionDialog( |
2830 migrations, self, self.__iconSuffix) |
2810 migrations, self, self.__iconSuffix) |
2831 if dlg.exec_() == QDialog.Accepted: |
2811 if dlg.exec_() == QDialog.Accepted: |
2832 app, start, end, noOptimize, name = dlg.getData() |
2812 app, start, end, noOptimize, name = dlg.getData() |
2833 |
2813 |
2903 args = Utilities.parseOptionString(consoleCmd) |
2883 args = Utilities.parseOptionString(consoleCmd) |
2904 args[0] = Utilities.getExecutablePath(args[0]) |
2884 args[0] = Utilities.getExecutablePath(args[0]) |
2905 args.append(self.__getPythonExecutable()) |
2885 args.append(self.__getPythonExecutable()) |
2906 args.append("manage.py") |
2886 args.append("manage.py") |
2907 args.append("shell") |
2887 args.append("shell") |
2908 language = self.__e5project.getProjectLanguage() |
2888 if self.getDjangoVersion() < (1, 10, 0): |
2909 if language == "Python2": |
2889 if (self.__plugin.getPreferences("Python3ConsoleType") == |
2910 if self.getDjangoVersion() < (1, 10, 0): |
2890 "python"): |
2911 if (self.__plugin.getPreferences("Python2ConsoleType") == |
2891 args.append("--plain") |
2912 "python"): |
|
2913 args.append("--plain") |
|
2914 else: |
|
2915 args.append("--interface={0}".format( |
|
2916 self.__plugin.getPreferences("Python2ConsoleType"))) |
|
2917 else: |
2892 else: |
2918 if self.getDjangoVersion() < (1, 10, 0): |
2893 args.append("--interface={0}".format( |
2919 if (self.__plugin.getPreferences("Python3ConsoleType") == |
2894 self.__plugin.getPreferences("Python3ConsoleType"))) |
2920 "python"): |
|
2921 args.append("--plain") |
|
2922 else: |
|
2923 args.append("--interface={0}".format( |
|
2924 self.__plugin.getPreferences("Python3ConsoleType"))) |
|
2925 try: |
2895 try: |
2926 wd = self.__sitePath() |
2896 wd = self.__sitePath() |
2927 self.__adjustWorkingDirectory(args, wd) |
2897 self.__adjustWorkingDirectory(args, wd) |
2928 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
2898 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
2929 if not started: |
2899 if not started: |
2941 if self.getDjangoVersion() < (1, 9, 0): |
2911 if self.getDjangoVersion() < (1, 9, 0): |
2942 return |
2912 return |
2943 |
2913 |
2944 title = self.tr("Send Test Email") |
2914 title = self.tr("Send Test Email") |
2945 |
2915 |
2946 from .DjangoSendTestEmailDataDialog import \ |
2916 from .DjangoSendTestEmailDataDialog import ( |
2947 DjangoSendTestEmailDataDialog |
2917 DjangoSendTestEmailDataDialog |
|
2918 ) |
2948 dlg = DjangoSendTestEmailDataDialog(self.__ui) |
2919 dlg = DjangoSendTestEmailDataDialog(self.__ui) |
2949 if dlg.exec_() == QDialog.Accepted: |
2920 if dlg.exec_() == QDialog.Accepted: |
2950 managers, admins, recipients = dlg.getData() |
2921 managers, admins, recipients = dlg.getData() |
2951 |
2922 |
2952 args = [] |
2923 args = [] |
3104 from .DjangoTestDataDialog import DjangoTestDataDialog |
3075 from .DjangoTestDataDialog import DjangoTestDataDialog |
3105 dlg = DjangoTestDataDialog( |
3076 dlg = DjangoTestDataDialog( |
3106 self, self.__plugin.getPreferences("KeepTestDatabase"), |
3077 self, self.__plugin.getPreferences("KeepTestDatabase"), |
3107 self.__ui) |
3078 self.__ui) |
3108 if dlg.exec_() == QDialog.Accepted: |
3079 if dlg.exec_() == QDialog.Accepted: |
3109 labels, pattern, tags, excludeTags, keep, reverse = \ |
3080 labels, pattern, tags, excludeTags, keep, reverse = ( |
3110 dlg.getData() |
3081 dlg.getData()) |
3111 |
3082 |
3112 self.__plugin.setPreferences("KeepTestDatabase", keep) |
3083 self.__plugin.setPreferences("KeepTestDatabase", keep) |
3113 |
3084 |
3114 args = Utilities.parseOptionString(consoleCmd) |
3085 args = Utilities.parseOptionString(consoleCmd) |
3115 args[0] = Utilities.getExecutablePath(args[0]) |
3086 args[0] = Utilities.getExecutablePath(args[0]) |
3144 fixtures. |
3115 fixtures. |
3145 """ |
3116 """ |
3146 consoleCmd = self.__isSpawningConsole( |
3117 consoleCmd = self.__isSpawningConsole( |
3147 self.__plugin.getPreferences("ConsoleCommand"))[1] |
3118 self.__plugin.getPreferences("ConsoleCommand"))[1] |
3148 if consoleCmd: |
3119 if consoleCmd: |
3149 from .DjangoRunTestServerDataDialog import \ |
3120 from .DjangoRunTestServerDataDialog import ( |
3150 DjangoRunTestServerDataDialog |
3121 DjangoRunTestServerDataDialog |
|
3122 ) |
3151 dlg = DjangoRunTestServerDataDialog(self, self.__ui) |
3123 dlg = DjangoRunTestServerDataDialog(self, self.__ui) |
3152 if dlg.exec_() == QDialog.Accepted: |
3124 if dlg.exec_() == QDialog.Accepted: |
3153 fixtures = dlg.getData() |
3125 fixtures = dlg.getData() |
3154 |
3126 |
3155 args = Utilities.parseOptionString(consoleCmd) |
3127 args = Utilities.parseOptionString(consoleCmd) |
3176 self.__testServerProc.finished.connect( |
3148 self.__testServerProc.finished.connect( |
3177 self.__serverProcFinished) |
3149 self.__serverProcFinished) |
3178 self.__testServerProc.setWorkingDirectory( |
3150 self.__testServerProc.setWorkingDirectory( |
3179 self.__sitePath()) |
3151 self.__sitePath()) |
3180 self.__testServerProc.start(args[0], args[1:]) |
3152 self.__testServerProc.start(args[0], args[1:]) |
3181 serverProcStarted = \ |
3153 serverProcStarted = ( |
3182 self.__testServerProc.waitForStarted() |
3154 self.__testServerProc.waitForStarted()) |
3183 if not serverProcStarted: |
3155 if not serverProcStarted: |
3184 E5MessageBox.critical( |
3156 E5MessageBox.critical( |
3185 None, |
3157 None, |
3186 self.tr('Process Generation Error'), |
3158 self.tr('Process Generation Error'), |
3187 self.tr('The Django test server could not be' |
3159 self.tr('The Django test server could not be' |
3191 |
3163 |
3192 def __testServerProcFinished(self): |
3164 def __testServerProcFinished(self): |
3193 """ |
3165 """ |
3194 Private slot connected to the finished signal of the test server. |
3166 Private slot connected to the finished signal of the test server. |
3195 """ |
3167 """ |
3196 if self.__testServerProc is not None and \ |
3168 if ( |
3197 self.__testServerProc.state() != QProcess.NotRunning: |
3169 self.__testServerProc is not None and |
|
3170 self.__testServerProc.state() != QProcess.NotRunning |
|
3171 ): |
3198 self.__testServerProc.terminate() |
3172 self.__testServerProc.terminate() |
3199 QTimer.singleShot(2000, self.__testServerProc.kill) |
3173 QTimer.singleShot(2000, self.__testServerProc.kill) |
3200 self.__testServerProc.waitForFinished(3000) |
3174 self.__testServerProc.waitForFinished(3000) |
3201 self.__testServerProc = None |
3175 self.__testServerProc = None |
3202 |
3176 |
3298 |
3272 |
3299 @param filename name of the file used for extraction (string) |
3273 @param filename name of the file used for extraction (string) |
3300 @return extracted locale (string) or None |
3274 @return extracted locale (string) or None |
3301 """ |
3275 """ |
3302 if self.__e5project.getTranslationPattern(): |
3276 if self.__e5project.getTranslationPattern(): |
3303 pattern = self.__e5project.getTranslationPattern()\ |
3277 pattern = ( |
|
3278 self.__e5project.getTranslationPattern() |
3304 .replace("%language%", "(.*?)") |
3279 .replace("%language%", "(.*?)") |
|
3280 ) |
3305 match = re.search(pattern, filename) |
3281 match = re.search(pattern, filename) |
3306 if match is not None: |
3282 if match is not None: |
3307 loc = match.group(1) |
3283 loc = match.group(1) |
3308 return loc |
3284 return loc |
3309 else: |
3285 else: |
3348 """ |
3324 """ |
3349 Private slot handling the addition of a new language. |
3325 Private slot handling the addition of a new language. |
3350 |
3326 |
3351 @param code language code of the new language (string) |
3327 @param code language code of the new language (string) |
3352 """ |
3328 """ |
3353 title = self.tr("Initializing message catalog for '{0}'")\ |
3329 title = ( |
|
3330 self.tr("Initializing message catalog for '{0}'") |
3354 .format(code) |
3331 .format(code) |
|
3332 ) |
3355 |
3333 |
3356 args = [] |
3334 args = [] |
3357 args.append(self.__getPythonExecutable()) |
3335 args.append(self.__getPythonExecutable()) |
3358 args.append("manage.py") |
3336 args.append("manage.py") |
3359 args.append("makemessages") |
3337 args.append("makemessages") |
3375 "\nMessage catalog initialized successfully.")) |
3353 "\nMessage catalog initialized successfully.")) |
3376 res = dia.startProcess(args, wd) |
3354 res = dia.startProcess(args, wd) |
3377 if res: |
3355 if res: |
3378 dia.exec_() |
3356 dia.exec_() |
3379 |
3357 |
3380 langFile = self.__e5project.getTranslationPattern()\ |
3358 langFile = ( |
|
3359 self.__e5project.getTranslationPattern() |
3381 .replace("%language%", code) |
3360 .replace("%language%", code) |
|
3361 ) |
3382 self.__e5project.appendFile(langFile) |
3362 self.__e5project.appendFile(langFile) |
3383 |
3363 |
3384 def updateSelectedCatalogs(self, filenames): |
3364 def updateSelectedCatalogs(self, filenames): |
3385 """ |
3365 """ |
3386 Public method to update the message catalogs. |
3366 Public method to update the message catalogs. |