61 PluginStatusUpToDate = 0 |
62 PluginStatusUpToDate = 0 |
62 PluginStatusNew = 1 |
63 PluginStatusNew = 1 |
63 PluginStatusLocalUpdate = 2 |
64 PluginStatusLocalUpdate = 2 |
64 PluginStatusRemoteUpdate = 3 |
65 PluginStatusRemoteUpdate = 3 |
65 |
66 |
66 def __init__(self, parent=None, external=False): |
67 def __init__(self, pluginManager, parent=None):#, external=False): |
67 """ |
68 """ |
68 Constructor |
69 Constructor |
69 |
70 |
70 @param parent parent of this dialog (QWidget) |
71 @param pluginManager reference to the plugin manager object |
71 @param external flag indicating an instatiation as a main |
72 @type PluginManager |
72 window (boolean) |
73 @param parent parent of this dialog |
|
74 @type QWidget |
|
75 @param external flag indicating an instantiation as a main |
|
76 window |
|
77 @type bool |
73 """ |
78 """ |
74 super(PluginRepositoryWidget, self).__init__(parent) |
79 super(PluginRepositoryWidget, self).__init__(parent) |
75 self.setupUi(self) |
80 self.setupUi(self) |
|
81 |
|
82 if pluginManager is None: |
|
83 # started as external plug-in repository dialog |
|
84 from .PluginManager import PluginManager |
|
85 self.__pluginManager = PluginManager() |
|
86 self.__external = True |
|
87 else: |
|
88 self.__pluginManager = pluginManager |
|
89 self.__external = False |
76 |
90 |
77 self.__updateButton = self.buttonBox.addButton( |
91 self.__updateButton = self.buttonBox.addButton( |
78 self.tr("Update"), QDialogButtonBox.ActionRole) |
92 self.tr("Update"), QDialogButtonBox.ActionRole) |
79 self.__downloadButton = self.buttonBox.addButton( |
93 self.__downloadButton = self.buttonBox.addButton( |
80 self.tr("Download"), QDialogButtonBox.ActionRole) |
94 self.tr("Download"), QDialogButtonBox.ActionRole) |
110 self.__pluginContextMenu.addAction( |
124 self.__pluginContextMenu.addAction( |
111 self.tr("Cleanup Downloads"), self.__cleanupDownloads) |
125 self.tr("Cleanup Downloads"), self.__cleanupDownloads) |
112 |
126 |
113 self.pluginRepositoryFile = \ |
127 self.pluginRepositoryFile = \ |
114 os.path.join(Utilities.getConfigDir(), "PluginRepository") |
128 os.path.join(Utilities.getConfigDir(), "PluginRepository") |
115 |
|
116 self.__external = external |
|
117 |
129 |
118 # attributes for the network objects |
130 # attributes for the network objects |
119 self.__networkManager = QNetworkAccessManager(self) |
131 self.__networkManager = QNetworkAccessManager(self) |
120 self.__networkManager.proxyAuthenticationRequired.connect( |
132 self.__networkManager.proxyAuthenticationRequired.connect( |
121 proxyAuthenticationRequired) |
133 proxyAuthenticationRequired) |
643 |
655 |
644 # check, if it is an update (i.e. we already have archives |
656 # check, if it is an update (i.e. we already have archives |
645 # with the same pattern) |
657 # with the same pattern) |
646 archivesPattern = archive.rsplit('-', 1)[0] + "-*.zip" |
658 archivesPattern = archive.rsplit('-', 1)[0] + "-*.zip" |
647 if len(glob.glob(archivesPattern)) == 0: |
659 if len(glob.glob(archivesPattern)) == 0: |
648 return PluginRepositoryWidget.PluginStatusNew |
660 # Check against installed/loaded plug-ins |
|
661 pluginName = filename.rsplit('-', 1)[0] |
|
662 pluginDetails = self.__pluginManager.getPluginDetails(pluginName) |
|
663 if pluginDetails is None: |
|
664 return PluginRepositoryWidget.PluginStatusNew |
|
665 pluginVersionTuple = Globals.versionToTuple( |
|
666 pluginDetails["version"])[:3] |
|
667 versionTuple = Globals.versionToTuple(version)[:3] |
|
668 if pluginVersionTuple < versionTuple: |
|
669 return PluginRepositoryWidget.PluginStatusRemoteUpdate |
|
670 else: |
|
671 return PluginRepositoryWidget.PluginStatusUpToDate |
649 |
672 |
650 # check, if the archive exists |
673 # check, if the archive exists |
651 if not os.path.exists(archive): |
674 if not os.path.exists(archive): |
652 return PluginRepositoryWidget.PluginStatusRemoteUpdate |
675 return PluginRepositoryWidget.PluginStatusRemoteUpdate |
653 |
676 |
661 except KeyError: |
684 except KeyError: |
662 aversion = "" |
685 aversion = "" |
663 zipFile.close() |
686 zipFile.close() |
664 |
687 |
665 if aversion == version: |
688 if aversion == version: |
666 if not self.__external: |
689 # Check against installed/loaded plug-ins |
667 # Check against installed/loaded plug-ins |
690 pluginName = filename.rsplit('-', 1)[0] |
668 pluginManager = e5App().getObject("PluginManager") |
691 pluginDetails = self.__pluginManager.getPluginDetails(pluginName) |
669 pluginName = filename.rsplit('-', 1)[0] |
692 if pluginDetails is None: |
670 pluginDetails = pluginManager.getPluginDetails(pluginName) |
693 return PluginRepositoryWidget.PluginStatusLocalUpdate |
671 if pluginDetails is None: |
694 if Globals.versionToTuple(pluginDetails["version"])[:3] < \ |
672 return PluginRepositoryWidget.PluginStatusLocalUpdate |
695 Globals.versionToTuple(version)[:3]: |
673 if version.count(".") >= 3: |
696 return PluginRepositoryWidget.PluginStatusLocalUpdate |
674 # cope for extended version numbers by ignoring |
697 else: |
675 # the extension |
698 return PluginRepositoryWidget.PluginStatusUpToDate |
676 version = ".".join(version.split(".", 3)[:3]) |
|
677 if pluginDetails["version"] < version: |
|
678 return PluginRepositoryWidget.PluginStatusLocalUpdate |
|
679 |
|
680 return PluginRepositoryWidget.PluginStatusUpToDate |
|
681 else: |
699 else: |
682 return PluginRepositoryWidget.PluginStatusRemoteUpdate |
700 return PluginRepositoryWidget.PluginStatusRemoteUpdate |
683 |
701 |
684 def __sslErrors(self, reply, errors): |
702 def __sslErrors(self, reply, errors): |
685 """ |
703 """ |
779 |
797 |
780 class PluginRepositoryDialog(QDialog): |
798 class PluginRepositoryDialog(QDialog): |
781 """ |
799 """ |
782 Class for the dialog variant. |
800 Class for the dialog variant. |
783 """ |
801 """ |
784 def __init__(self, parent=None): |
802 def __init__(self, pluginManager, parent=None): |
785 """ |
803 """ |
786 Constructor |
804 Constructor |
787 |
805 |
788 @param parent reference to the parent widget (QWidget) |
806 @param pluginManager reference to the plugin manager object |
|
807 @type PluginManager |
|
808 @param parent reference to the parent widget |
|
809 @type QWidget |
789 """ |
810 """ |
790 super(PluginRepositoryDialog, self).__init__(parent) |
811 super(PluginRepositoryDialog, self).__init__(parent) |
791 self.setSizeGripEnabled(True) |
812 self.setSizeGripEnabled(True) |
792 |
813 |
793 self.__layout = QVBoxLayout(self) |
814 self.__layout = QVBoxLayout(self) |
794 self.__layout.setContentsMargins(0, 0, 0, 0) |
815 self.__layout.setContentsMargins(0, 0, 0, 0) |
795 self.setLayout(self.__layout) |
816 self.setLayout(self.__layout) |
796 |
817 |
797 self.cw = PluginRepositoryWidget(self) |
818 self.cw = PluginRepositoryWidget(pluginManager, self) |
798 size = self.cw.size() |
819 size = self.cw.size() |
799 self.__layout.addWidget(self.cw) |
820 self.__layout.addWidget(self.cw) |
800 self.resize(size) |
821 self.resize(size) |
801 self.setWindowTitle(self.cw.windowTitle()) |
822 self.setWindowTitle(self.cw.windowTitle()) |
802 |
823 |
828 Constructor |
849 Constructor |
829 |
850 |
830 @param parent reference to the parent widget (QWidget) |
851 @param parent reference to the parent widget (QWidget) |
831 """ |
852 """ |
832 super(PluginRepositoryWindow, self).__init__(parent) |
853 super(PluginRepositoryWindow, self).__init__(parent) |
833 self.cw = PluginRepositoryWidget(self, external=True) |
854 self.cw = PluginRepositoryWidget(None, self) |
834 size = self.cw.size() |
855 size = self.cw.size() |
835 self.setCentralWidget(self.cw) |
856 self.setCentralWidget(self.cw) |
836 self.resize(size) |
857 self.resize(size) |
837 self.setWindowTitle(self.cw.windowTitle()) |
858 self.setWindowTitle(self.cw.windowTitle()) |
838 |
859 |