95 class Project(QObject): |
95 class Project(QObject): |
96 """ |
96 """ |
97 Class implementing the Django project support. |
97 Class implementing the Django project support. |
98 """ |
98 """ |
99 RecentApplicationsKey = "Django/RecentApplications" |
99 RecentApplicationsKey = "Django/RecentApplications" |
|
100 ## RecentTestLabelsKey = "Django/RecentTestLabels" |
|
101 ## RecentTestTagsKey = "Django/RecentTestTags" |
|
102 ## RecentTestExcludeTagsKey = "Django/RecentTestExcludeTags" |
100 |
103 |
101 def __init__(self, plugin, parent=None): |
104 def __init__(self, plugin, parent=None): |
102 """ |
105 """ |
103 Constructor |
106 Constructor |
104 |
107 |
117 self.__serverProc = None |
120 self.__serverProc = None |
118 self.__testServerProc = None |
121 self.__testServerProc = None |
119 |
122 |
120 self.__recentApplications = [] |
123 self.__recentApplications = [] |
121 self.__loadRecentApplications() |
124 self.__loadRecentApplications() |
|
125 |
|
126 self.__recentTestData = { |
|
127 "RecentTestLabels": [], |
|
128 "RecentTestTags": [], |
|
129 "RecentTestExcludeTags": [], |
|
130 } |
|
131 self.__loadRecentTestData() |
122 |
132 |
123 def initActions(self): |
133 def initActions(self): |
124 """ |
134 """ |
125 Public method to define the Django actions. |
135 Public method to define the Django actions. |
126 """ |
136 """ |
1557 if len(self.__recentApplications) > maxRecentApps: |
1567 if len(self.__recentApplications) > maxRecentApps: |
1558 self.__recentApplications = \ |
1568 self.__recentApplications = \ |
1559 self.__recentApplications[:maxRecentApps] |
1569 self.__recentApplications[:maxRecentApps] |
1560 self.__saveRecentApplications() |
1570 self.__saveRecentApplications() |
1561 |
1571 |
|
1572 def __loadRecentTestData(self): |
|
1573 """ |
|
1574 Private method to load the recently used test data lists. |
|
1575 """ |
|
1576 self.__recentTestData = { |
|
1577 "RecentTestLabels": [], |
|
1578 "RecentTestTags": [], |
|
1579 "RecentTestExcludeTags": [], |
|
1580 } |
|
1581 Preferences.Prefs.rsettings.sync() |
|
1582 maxRecentTestData = self.__plugin.getPreferences( |
|
1583 "RecentNumberTestData") |
|
1584 for key in self.__recentTestData: |
|
1585 recent = Preferences.Prefs.rsettings.value("Django/" + key) |
|
1586 if recent is not None: |
|
1587 self.__recentTestData[key] = recent[:maxRecentTestData] |
|
1588 |
|
1589 def __saveRecentTestData(self): |
|
1590 """ |
|
1591 Private method to save the list of recently used test data. |
|
1592 """ |
|
1593 for key in self.__recentTestData: |
|
1594 Preferences.Prefs.rsettings.setValue("Django/" + key, |
|
1595 self.__recentTestData[key]) |
|
1596 Preferences.Prefs.rsettings.sync() |
|
1597 |
|
1598 def getRecentTestData(self, key): |
|
1599 """ |
|
1600 Public method to get the list of recent test data. |
|
1601 |
|
1602 @param key key (name) of the test data to get |
|
1603 @type str |
|
1604 @return list of recent test data entries |
|
1605 @rtype list of str |
|
1606 """ |
|
1607 self.__loadRecentTestData() |
|
1608 return self.__recentTestData[key] |
|
1609 |
|
1610 def setMostRecentTestData(self, key, data): |
|
1611 """ |
|
1612 Public method to set the most recently used test data entry. |
|
1613 |
|
1614 @param key key (name) of the test data to set |
|
1615 @type str |
|
1616 @param data test data entry to be set |
|
1617 @type str |
|
1618 """ |
|
1619 if data in self.__recentTestData[key]: |
|
1620 self.__recentTestData[key].remove(data) |
|
1621 self.__recentTestData[key].insert(0, data) |
|
1622 |
|
1623 maxRecentTestData = self.__plugin.getPreferences( |
|
1624 "RecentNumberTestData") |
|
1625 if len(self.__recentTestData[key]) > maxRecentTestData: |
|
1626 self.__recentTestData[key] = \ |
|
1627 self.__recentTestData[key][:maxRecentTestData] |
|
1628 self.__saveRecentTestData() |
|
1629 |
1562 def getProjectPath(self): |
1630 def getProjectPath(self): |
1563 """ |
1631 """ |
1564 Public method to get the path of the eric6 project. |
1632 Public method to get the path of the eric6 project. |
1565 |
1633 |
1566 @return path of the eric6 project (string) |
1634 @return path of the eric6 project (string) |
1875 self.__selectSite() |
1943 self.__selectSite() |
1876 |
1944 |
1877 if self.__currentSite is None: |
1945 if self.__currentSite is None: |
1878 raise DjangoNoSiteSelectedException |
1946 raise DjangoNoSiteSelectedException |
1879 else: |
1947 else: |
1880 return os.path.join(self.__e5project.getProjectPath(), |
1948 path = os.path.join(self.__e5project.getProjectPath(), |
1881 self.__currentSite) |
1949 self.__currentSite) |
|
1950 return path |
1882 |
1951 |
1883 def __setCurrentSite(self, site): |
1952 def __setCurrentSite(self, site): |
1884 """ |
1953 """ |
1885 Private slot to set the current site. |
1954 Private slot to set the current site. |
1886 |
1955 |
2686 try: |
2755 try: |
2687 wd = self.__sitePath() |
2756 wd = self.__sitePath() |
2688 except DjangoNoSiteSelectedException: |
2757 except DjangoNoSiteSelectedException: |
2689 return |
2758 return |
2690 |
2759 |
|
2760 from .DjangoTestDataDialog import DjangoTestDataDialog |
|
2761 dlg = DjangoTestDataDialog(self, self.__ui) |
|
2762 if dlg.exec_() == QDialog.Accepted: |
|
2763 labels, pattern, tags, excludeTags, keep, reverse = \ |
|
2764 dlg.getData() |
|
2765 |
2691 args = Utilities.parseOptionString(consoleCmd) |
2766 args = Utilities.parseOptionString(consoleCmd) |
2692 args[0] = Utilities.getExecutablePath(args[0]) |
2767 args[0] = Utilities.getExecutablePath(args[0]) |
2693 args.append(self.__getPythonExecutable()) |
2768 args.append(self.__getPythonExecutable()) |
2694 if deprecation: |
2769 if deprecation: |
2695 args.append("-Wall") |
2770 args.append("-Wall") |
2696 args.append("manage.py") |
2771 args.append("manage.py") |
2697 args.append("test") |
2772 args.append("test") |
2698 args += self.__getApplications() |
2773 if pattern: |
|
2774 args.append("--pattern") |
|
2775 args.append(pattern) |
|
2776 for tag in tags: |
|
2777 args.append("--tag") |
|
2778 args.append(tag) |
|
2779 for tag in excludeTags: |
|
2780 args.append("--exclude-tag") |
|
2781 args.append(tag) |
|
2782 if keep: |
|
2783 args.append("--keepdb") |
|
2784 if reverse: |
|
2785 args.append("--reverse") |
|
2786 args.extend(labels) |
2699 |
2787 |
2700 self.__adjustWorkingDirectory(args, wd) |
2788 self.__adjustWorkingDirectory(args, wd) |
2701 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
2789 started, pid = QProcess.startDetached(args[0], args[1:], wd) |
2702 if not started: |
2790 if not started: |
2703 E5MessageBox.critical( |
2791 E5MessageBox.critical( |