PluginManager/PluginRepositoryDialog.py

Sat, 01 Dec 2018 11:34:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 01 Dec 2018 11:34:23 +0100
changeset 6599
419f36a46608
parent 6156
ac12549e521a
child 6600
092cb8a3fc34
permissions
-rw-r--r--

PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.

0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
6048
82ad8ec9548c Updated copyright for 2018.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6024
diff changeset
3 # Copyright (c) 2007 - 2018 Detlev Offenbach <detlev@die-offenbachs.de>
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
7 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 Module implementing a dialog showing the available plugins.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
9 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 3142
diff changeset
11 from __future__ import unicode_literals
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2404
diff changeset
12
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13 import sys
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
14 import os
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
15 import zipfile
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
16 import glob
5975
3bc24855b254 Fixed an issue cleaning up the plug-in download area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
17 import re
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
18
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
19 from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QFile, QIODevice, QUrl, \
5739
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
20 QProcess, QPoint, QCoreApplication
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
21 from PyQt5.QtWidgets import QWidget, QDialogButtonBox, QAbstractButton, \
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
22 QTreeWidgetItem, QDialog, QVBoxLayout, QMenu
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
23 from PyQt5.QtNetwork import QNetworkAccessManager, QNetworkRequest, \
4629
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
24 QNetworkReply, QNetworkConfigurationManager
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
25
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
26 from .Ui_PluginRepositoryDialog import Ui_PluginRepositoryDialog
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
27
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
28 from E5Gui import E5MessageBox
2101
5bac7dee9e1a Introduced the E5MainWindow class allowing to set a style for all the main windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2094
diff changeset
29 from E5Gui.E5MainWindow import E5MainWindow
2192
61b3849df76d Changed a few places to use the new notification system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2101
diff changeset
30 from E5Gui.E5Application import e5App
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
31
286
652f5159f1c3 Prepared to have individual proxies per scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 270
diff changeset
32 from E5Network.E5NetworkProxyFactory import proxyAuthenticationRequired
2354
c63de4af553d Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
33 try:
c63de4af553d Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
34 from E5Network.E5SslErrorHandler import E5SslErrorHandler
c63de4af553d Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
35 SSL_AVAILABLE = True
c63de4af553d Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
36 except ImportError:
c63de4af553d Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
37 SSL_AVAILABLE = False
286
652f5159f1c3 Prepared to have individual proxies per scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 270
diff changeset
38
6599
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
39 import Globals
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 import Utilities
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 import Preferences
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 import UI.PixmapCache
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
45 from eric6config import getConfig
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
47
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
48 class PluginRepositoryWidget(QWidget, Ui_PluginRepositoryDialog):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
50 Class implementing a dialog showing the available plugins.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
52 @signal closeAndInstall() emitted when the Close & Install button is
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
53 pressed
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
54 """
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 465
diff changeset
55 closeAndInstall = pyqtSignal()
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 465
diff changeset
56
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
57 DescrRole = Qt.UserRole
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
58 UrlRole = Qt.UserRole + 1
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
59 FilenameRole = Qt.UserRole + 2
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
60 AuthorRole = Qt.UserRole + 3
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
61
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
62 PluginStatusUpToDate = 0
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
63 PluginStatusNew = 1
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
64 PluginStatusLocalUpdate = 2
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
65 PluginStatusRemoteUpdate = 3
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
66
6599
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
67 def __init__(self, pluginManager, parent=None):#, external=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
69 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70
6599
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
71 @param pluginManager reference to the plugin manager object
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
72 @type PluginManager
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
73 @param parent parent of this dialog
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
74 @type QWidget
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
75 @param external flag indicating an instantiation as a main
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
76 window
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
77 @type bool
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
78 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2404
diff changeset
79 super(PluginRepositoryWidget, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 self.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81
6599
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
82 if pluginManager is None:
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
83 # started as external plug-in repository dialog
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
84 from .PluginManager import PluginManager
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
85 self.__pluginManager = PluginManager()
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
86 self.__external = True
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
87 else:
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
88 self.__pluginManager = pluginManager
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
89 self.__external = False
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
90
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
91 self.__updateButton = self.buttonBox.addButton(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
92 self.tr("Update"), QDialogButtonBox.ActionRole)
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
93 self.__downloadButton = self.buttonBox.addButton(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
94 self.tr("Download"), QDialogButtonBox.ActionRole)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
95 self.__downloadButton.setEnabled(False)
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
96 self.__downloadInstallButton = self.buttonBox.addButton(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
97 self.tr("Download && Install"),
1364
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
98 QDialogButtonBox.ActionRole)
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
99 self.__downloadInstallButton.setEnabled(False)
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
100 self.__downloadCancelButton = self.buttonBox.addButton(
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
101 self.tr("Cancel"), QDialogButtonBox.ActionRole)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
102 self.__installButton = \
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
103 self.buttonBox.addButton(self.tr("Close && Install"),
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
104 QDialogButtonBox.ActionRole)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
105 self.__downloadCancelButton.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
106 self.__installButton.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
107
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
108 self.repositoryUrlEdit.setText(
3676
2f62b060a931 Renamed a few excternal references.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3670
diff changeset
109 Preferences.getUI("PluginRepositoryUrl6"))
1763
25a83ac16a5e Extended the Plugin Repository dialog to allow to change the repository URL manually and to show a message, if the URL has changed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1582
diff changeset
110
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
111 self.repositoryList.headerItem().setText(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
112 self.repositoryList.columnCount(), "")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 self.repositoryList.header().setSortIndicator(0, Qt.AscendingOrder)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
115 self.__pluginContextMenu = QMenu(self)
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
116 self.__hideAct = self.__pluginContextMenu.addAction(
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
117 self.tr("Hide"), self.__hidePlugin)
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
118 self.__hideSelectedAct = self.__pluginContextMenu.addAction(
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
119 self.tr("Hide Selected"), self.__hideSelectedPlugins)
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
120 self.__pluginContextMenu.addSeparator()
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
121 self.__showAllAct = self.__pluginContextMenu.addAction(
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
122 self.tr("Show All"), self.__showAllPlugins)
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
123 self.__pluginContextMenu.addSeparator()
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
124 self.__pluginContextMenu.addAction(
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
125 self.tr("Cleanup Downloads"), self.__cleanupDownloads)
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
126
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 self.pluginRepositoryFile = \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 os.path.join(Utilities.getConfigDir(), "PluginRepository")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129
270
41505c92ac31 Added code to enhance the proxy configuration and removed the usage of QHttp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 80
diff changeset
130 # attributes for the network objects
41505c92ac31 Added code to enhance the proxy configuration and removed the usage of QHttp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 80
diff changeset
131 self.__networkManager = QNetworkAccessManager(self)
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 465
diff changeset
132 self.__networkManager.proxyAuthenticationRequired.connect(
286
652f5159f1c3 Prepared to have individual proxies per scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 270
diff changeset
133 proxyAuthenticationRequired)
798
5c1786fad576 Fixed an issue with Qt installations that don't support SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
134 if SSL_AVAILABLE:
2354
c63de4af553d Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
135 self.__sslErrorHandler = E5SslErrorHandler(self)
798
5c1786fad576 Fixed an issue with Qt installations that don't support SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
136 self.__networkManager.sslErrors.connect(self.__sslErrors)
270
41505c92ac31 Added code to enhance the proxy configuration and removed the usage of QHttp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 80
diff changeset
137 self.__replies = []
41505c92ac31 Added code to enhance the proxy configuration and removed the usage of QHttp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 80
diff changeset
138
5047
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
139 if Preferences.getUI("DynamicOnlineCheck"):
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
140 self.__networkConfigurationManager = \
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
141 QNetworkConfigurationManager(self)
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
142 self.__onlineStateChanged(
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
143 self.__networkConfigurationManager.isOnline())
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
144 self.__networkConfigurationManager.onlineStateChanged.connect(
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
145 self.__onlineStateChanged)
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
146 else:
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
147 self.__networkConfigurationManager = None
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
148 self.__onlineStateChanged(True)
4629
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
149
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
150 self.__pluginsToDownload = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
151 self.__pluginsDownloaded = []
1364
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
152 self.__isDownloadInstall = False
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
153 self.__allDownloadedOk = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
155 self.__hiddenPlugins = Preferences.getPluginManager("HiddenPlugins")
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
156
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 self.__populateList()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
158
4629
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
159 @pyqtSlot(bool)
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
160 def __onlineStateChanged(self, online):
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
161 """
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
162 Private slot handling online state changes.
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
163
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
164 @param online flag indicating the online status
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
165 @type bool
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
166 """
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
167 self.__updateButton.setEnabled(online)
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
168 self.on_repositoryList_itemSelectionChanged()
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
169 if online:
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
170 msg = self.tr("Network Status: online")
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
171 else:
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
172 msg = self.tr("Network Status: offline")
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
173 self.statusLabel.setText(msg)
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
174
5047
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
175 def __isOnline(self):
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
176 """
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
177 Private method to check the online status.
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
178
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
179 @return flag indicating the online status
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
180 @rtype bool
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
181 """
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
182 if self.__networkConfigurationManager is not None:
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
183 return self.__networkConfigurationManager.isOnline()
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
184 else:
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
185 return True
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
186
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 @pyqtSlot(QAbstractButton)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 def on_buttonBox_clicked(self, button):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 Private slot to handle the click of a button of the button box.
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
191
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
192 @param button reference to the button pressed (QAbstractButton)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 if button == self.__updateButton:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 self.__updateList()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 elif button == self.__downloadButton:
1364
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
197 self.__isDownloadInstall = False
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
198 self.__downloadPlugins()
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
199 elif button == self.__downloadInstallButton:
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
200 self.__isDownloadInstall = True
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
201 self.__allDownloadedOk = True
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 self.__downloadPlugins()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 elif button == self.__downloadCancelButton:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 self.__downloadCancel()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205 elif button == self.__installButton:
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
206 self.__closeAndInstall()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 def __formatDescription(self, lines):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 Private method to format the description.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 @param lines lines of the description (list of strings)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
213 @return formatted description (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
214 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
215 # remove empty line at start and end
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 newlines = lines[:]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 if len(newlines) and newlines[0] == '':
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 del newlines[0]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219 if len(newlines) and newlines[-1] == '':
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 del newlines[-1]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 # replace empty lines by newline character
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 index = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 while index < len(newlines):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 if newlines[index] == '':
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 newlines[index] = '\n'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 index += 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 # join lines by a blank
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 return ' '.join(newlines)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
232 @pyqtSlot(QPoint)
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
233 def on_repositoryList_customContextMenuRequested(self, pos):
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
234 """
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
235 Private slot to show the context menu.
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
236
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
237 @param pos position to show the menu (QPoint)
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
238 """
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
239 self.__hideAct.setEnabled(
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
240 self.repositoryList.currentItem() is not None and
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
241 len(self.__selectedItems()) == 1)
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
242 self.__hideSelectedAct.setEnabled(
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
243 len(self.__selectedItems()) > 1)
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
244 self.__showAllAct.setEnabled(bool(self.__hasHiddenPlugins()))
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
245 self.__pluginContextMenu.popup(self.repositoryList.mapToGlobal(pos))
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
246
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 def on_repositoryList_currentItemChanged(self, current, previous):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 Private slot to handle the change of the current item.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 @param current reference to the new current item (QTreeWidgetItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 @param previous reference to the old current item (QTreeWidgetItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 if self.__repositoryMissing or current is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
258 self.urlEdit.setText(
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
259 current.data(0, PluginRepositoryWidget.UrlRole) or "")
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
260 self.descriptionEdit.setPlainText(
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
261 current.data(0, PluginRepositoryWidget.DescrRole) and
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
262 self.__formatDescription(
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
263 current.data(0, PluginRepositoryWidget.DescrRole)) or "")
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
264 self.authorEdit.setText(
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
265 current.data(0, PluginRepositoryWidget.AuthorRole) or "")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 def __selectedItems(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 Private method to get all selected items without the toplevel ones.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271 @return list of selected items (list)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 ql = self.repositoryList.selectedItems()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274 for index in range(self.repositoryList.topLevelItemCount()):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 ti = self.repositoryList.topLevelItem(index)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 if ti in ql:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 ql.remove(ti)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278 return ql
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 def on_repositoryList_itemSelectionChanged(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283 Private slot to handle a change of the selection.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 """
4629
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
285 self.__downloadButton.setEnabled(
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
286 len(self.__selectedItems()) and
5047
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
287 self.__isOnline())
4629
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
288 self.__downloadInstallButton.setEnabled(
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
289 len(self.__selectedItems()) and
5047
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
290 self.__isOnline())
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
291 self.__installButton.setEnabled(len(self.__selectedItems()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
293 def __updateList(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
294 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295 Private slot to download a new list and display the contents.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 """
1763
25a83ac16a5e Extended the Plugin Repository dialog to allow to change the repository URL manually and to show a message, if the URL has changed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1582
diff changeset
297 url = self.repositoryUrlEdit.text()
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
298 self.__downloadFile(url,
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
299 self.pluginRepositoryFile,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 self.__downloadRepositoryFileDone)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
301
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
302 def __downloadRepositoryFileDone(self, status, filename):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
303 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
304 Private method called after the repository file was downloaded.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
306 @param status flaging indicating a successful download (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
307 @param filename full path of the downloaded file (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309 self.__populateList()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 def __downloadPluginDone(self, status, filename):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 Private method called, when the download of a plugin is finished.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314
1364
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
315 @param status flag indicating a successful download (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 @param filename full path of the downloaded file (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
317 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 if status:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 self.__pluginsDownloaded.append(filename)
1364
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
320 if self.__isDownloadInstall:
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
321 self.__allDownloadedOk &= status
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
322
6156
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
323 self.__pluginsToDownload.pop(0)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 if len(self.__pluginsToDownload):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
325 self.__downloadPlugin()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 self.__downloadPluginsDone()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
328
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
329 def __downloadPlugin(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
330 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
331 Private method to download the next plugin.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
333 self.__downloadFile(self.__pluginsToDownload[0][0],
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
334 self.__pluginsToDownload[0][1],
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 self.__downloadPluginDone)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
337 def __downloadPlugins(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
338 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
339 Private slot to download the selected plugins.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
340 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
341 self.__pluginsDownloaded = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
342 self.__pluginsToDownload = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
343 self.__downloadButton.setEnabled(False)
1364
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
344 self.__downloadInstallButton.setEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
345 self.__installButton.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
346 for itm in self.repositoryList.selectedItems():
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
347 if itm not in [self.__stableItem, self.__unstableItem,
6023
c6dabc972560 Added an "obsolete" category to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5975
diff changeset
348 self.__unknownItem, self.__obsoleteItem]:
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
349 url = itm.data(0, PluginRepositoryWidget.UrlRole)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
350 filename = os.path.join(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
351 Preferences.getPluginManager("DownloadPath"),
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
352 itm.data(0, PluginRepositoryWidget.FilenameRole))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
353 self.__pluginsToDownload.append((url, filename))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
354 self.__downloadPlugin()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
355
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
356 def __downloadPluginsDone(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
357 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
358 Private method called, when the download of the plugins is finished.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
359 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
360 self.__downloadButton.setEnabled(len(self.__selectedItems()))
1364
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
361 self.__downloadInstallButton.setEnabled(len(self.__selectedItems()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 self.__installButton.setEnabled(True)
2192
61b3849df76d Changed a few places to use the new notification system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2101
diff changeset
363 if not self.__external:
61b3849df76d Changed a few places to use the new notification system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2101
diff changeset
364 ui = e5App().getObject("UserInterface")
61b3849df76d Changed a few places to use the new notification system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2101
diff changeset
365 else:
61b3849df76d Changed a few places to use the new notification system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2101
diff changeset
366 ui = None
61b3849df76d Changed a few places to use the new notification system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2101
diff changeset
367 if ui and ui.notificationsEnabled():
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
368 ui.showNotification(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
369 UI.PixmapCache.getPixmap("plugin48.png"),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
370 self.tr("Download Plugin Files"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
371 self.tr("""The requested plugins were downloaded."""))
2192
61b3849df76d Changed a few places to use the new notification system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2101
diff changeset
372
1364
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
373 if self.__isDownloadInstall:
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
374 self.closeAndInstall.emit()
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
375 else:
2192
61b3849df76d Changed a few places to use the new notification system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2101
diff changeset
376 if ui is None or not ui.notificationsEnabled():
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
377 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
378 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
379 self.tr("Download Plugin Files"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
380 self.tr("""The requested plugins were downloaded."""))
1364
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
381 self.downloadProgress.setValue(0)
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
382
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
383 # repopulate the list to update the refresh icons
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
384 self.__populateList()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 def __resortRepositoryList(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 Private method to resort the tree.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 """
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
390 self.repositoryList.sortItems(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
391 self.repositoryList.sortColumn(),
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
392 self.repositoryList.header().sortIndicatorOrder())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
394 def __populateList(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396 Private method to populate the list of available plugins.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
398 self.repositoryList.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
399 self.__stableItem = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400 self.__unstableItem = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 self.__unknownItem = None
6023
c6dabc972560 Added an "obsolete" category to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5975
diff changeset
402 self.__obsoleteItem = None
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
403
5854
be976799b8c0 Added a bar with counts for new/local updates/remote updates to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5755
diff changeset
404 self.__newItems = 0
be976799b8c0 Added a bar with counts for new/local updates/remote updates to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5755
diff changeset
405 self.__updateLocalItems = 0
be976799b8c0 Added a bar with counts for new/local updates/remote updates to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5755
diff changeset
406 self.__updateRemoteItems = 0
be976799b8c0 Added a bar with counts for new/local updates/remote updates to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5755
diff changeset
407
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 self.downloadProgress.setValue(0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
410 if os.path.exists(self.pluginRepositoryFile):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
411 self.__repositoryMissing = False
580
45c38566b001 Implemented the plug-in repository reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 553
diff changeset
412 f = QFile(self.pluginRepositoryFile)
45c38566b001 Implemented the plug-in repository reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 553
diff changeset
413 if f.open(QIODevice.ReadOnly):
2404
cba0ff902c2b Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2360
diff changeset
414 from E5XML.PluginRepositoryReader import PluginRepositoryReader
3113
2780e230f129 Continued implementing the automatic plug-in update check in the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3112
diff changeset
415 reader = PluginRepositoryReader(f, self.addEntry)
580
45c38566b001 Implemented the plug-in repository reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 553
diff changeset
416 reader.readXML()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
417 self.repositoryList.resizeColumnToContents(0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 self.repositoryList.resizeColumnToContents(1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 self.repositoryList.resizeColumnToContents(2)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420 self.__resortRepositoryList()
3676
2f62b060a931 Renamed a few excternal references.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3670
diff changeset
421 url = Preferences.getUI("PluginRepositoryUrl6")
1763
25a83ac16a5e Extended the Plugin Repository dialog to allow to change the repository URL manually and to show a message, if the URL has changed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1582
diff changeset
422 if url != self.repositoryUrlEdit.text():
25a83ac16a5e Extended the Plugin Repository dialog to allow to change the repository URL manually and to show a message, if the URL has changed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1582
diff changeset
423 self.repositoryUrlEdit.setText(url)
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
424 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
425 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
426 self.tr("Plugins Repository URL Changed"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
427 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
428 """The URL of the Plugins Repository has"""
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
429 """ changed. Select the "Update" button to get"""
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
430 """ the new repository file."""))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
431 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
432 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
433 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
434 self.tr("Read plugins repository file"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
435 self.tr("<p>The plugins repository file <b>{0}</b> "
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
436 "could not be read. Select Update</p>")
3036
30c81c9e88b8 Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
437 .format(self.pluginRepositoryFile))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
438 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
439 self.__repositoryMissing = True
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
440 QTreeWidgetItem(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
441 self.repositoryList,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
442 ["", self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
443 "No plugin repository file available.\nSelect Update.")
3036
30c81c9e88b8 Fixed a bunch of indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3034
diff changeset
444 ])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 self.repositoryList.resizeColumnToContents(1)
5854
be976799b8c0 Added a bar with counts for new/local updates/remote updates to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5755
diff changeset
446
be976799b8c0 Added a bar with counts for new/local updates/remote updates to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5755
diff changeset
447 self.newLabel.setText(self.tr("New: <b>{0}</b>")
be976799b8c0 Added a bar with counts for new/local updates/remote updates to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5755
diff changeset
448 .format(self.__newItems))
be976799b8c0 Added a bar with counts for new/local updates/remote updates to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5755
diff changeset
449 self.updateLocalLabel.setText(self.tr("Local Updates: <b>{0}</b>")
be976799b8c0 Added a bar with counts for new/local updates/remote updates to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5755
diff changeset
450 .format(self.__updateLocalItems))
be976799b8c0 Added a bar with counts for new/local updates/remote updates to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5755
diff changeset
451 self.updateRemoteLabel.setText(self.tr("Remote Updates: <b>{0}</b>")
be976799b8c0 Added a bar with counts for new/local updates/remote updates to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5755
diff changeset
452 .format(self.__updateRemoteItems))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
454 def __downloadFile(self, url, filename, doneMethod=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 Private slot to download the given file.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 @param url URL for the download (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 @param filename local name of the file (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 @param doneMethod method to be called when done
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 """
5047
04e5dfbd3f3d Added a configuration option to override the online status check.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
462 if self.__isOnline():
4629
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
463 self.__updateButton.setEnabled(False)
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
464 self.__downloadButton.setEnabled(False)
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
465 self.__downloadInstallButton.setEnabled(False)
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
466 self.__downloadCancelButton.setEnabled(True)
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
467
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
468 self.statusLabel.setText(url)
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
469
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
470 request = QNetworkRequest(QUrl(url))
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
471 request.setAttribute(QNetworkRequest.CacheLoadControlAttribute,
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
472 QNetworkRequest.AlwaysNetwork)
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
473 reply = self.__networkManager.get(request)
6156
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
474 reply.finished.connect(
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
475 lambda: self.__downloadFileDone(reply, filename, doneMethod))
4629
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
476 reply.downloadProgress.connect(self.__downloadProgress)
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
477 self.__replies.append(reply)
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
478 else:
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
479 E5MessageBox.warning(
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
480 self,
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
481 self.tr("Error downloading file"),
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
482 self.tr(
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
483 """<p>Could not download the requested file"""
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
484 """ from {0}.</p><p>Error: {1}</p>"""
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
485 ).format(url, self.tr("Computer is offline.")))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
486
6156
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
487 def __downloadFileDone(self, reply, fileName, doneMethod):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
488 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489 Private method called, after the file has been downloaded
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5854
diff changeset
490 from the Internet.
6088
b7fdd0db835e Removed use of sender() in the plug-in repository dialog and the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6064
diff changeset
491
b7fdd0db835e Removed use of sender() in the plug-in repository dialog and the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6064
diff changeset
492 @param reply reference to the reply object of the download
b7fdd0db835e Removed use of sender() in the plug-in repository dialog and the plug-in manager.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6064
diff changeset
493 @type QNetworkReply
6156
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
494 @param fileName local name of the file
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
495 @type str
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
496 @param doneMethod method to be called when done
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
497 @type func
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 self.__updateButton.setEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 self.__downloadCancelButton.setEnabled(False)
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5854
diff changeset
501 self.__onlineStateChanged(self.__isOnline())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503 ok = True
270
41505c92ac31 Added code to enhance the proxy configuration and removed the usage of QHttp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 80
diff changeset
504 if reply in self.__replies:
41505c92ac31 Added code to enhance the proxy configuration and removed the usage of QHttp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 80
diff changeset
505 self.__replies.remove(reply)
41505c92ac31 Added code to enhance the proxy configuration and removed the usage of QHttp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 80
diff changeset
506 if reply.error() != QNetworkReply.NoError:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507 ok = False
6156
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
508 if reply.error() != QNetworkReply.OperationCanceledError:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
509 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
510 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
511 self.tr("Error downloading file"),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
512 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
513 """<p>Could not download the requested file"""
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
514 """ from {0}.</p><p>Error: {1}</p>"""
6156
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
515 ).format(reply.url().toString(), reply.errorString())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
517 self.downloadProgress.setValue(0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
518 if self.repositoryList.topLevelItemCount():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
519 if self.repositoryList.currentItem() is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
520 self.repositoryList.setCurrentItem(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
521 self.repositoryList.topLevelItem(0))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
522 else:
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
523 self.__downloadButton.setEnabled(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
524 len(self.__selectedItems()))
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
525 self.__downloadInstallButton.setEnabled(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
526 len(self.__selectedItems()))
4626
c891c7ad6b60 Added some missing deleteLater() calls.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
527 reply.deleteLater()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
528 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529
6156
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
530 downloadIODevice = QFile(fileName + ".tmp")
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
531 downloadIODevice.open(QIODevice.WriteOnly)
5755
83fe98028532 Fixed an issue causing the downloading of Plug-in archives bigger than 128MB to fail on Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5739
diff changeset
532 # read data in chunks
83fe98028532 Fixed an issue causing the downloading of Plug-in archives bigger than 128MB to fail on Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5739
diff changeset
533 chunkSize = 64 * 1024 * 1024
83fe98028532 Fixed an issue causing the downloading of Plug-in archives bigger than 128MB to fail on Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5739
diff changeset
534 while True:
83fe98028532 Fixed an issue causing the downloading of Plug-in archives bigger than 128MB to fail on Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5739
diff changeset
535 data = reply.read(chunkSize)
83fe98028532 Fixed an issue causing the downloading of Plug-in archives bigger than 128MB to fail on Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5739
diff changeset
536 if data is None or len(data) == 0:
83fe98028532 Fixed an issue causing the downloading of Plug-in archives bigger than 128MB to fail on Windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5739
diff changeset
537 break
6156
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
538 downloadIODevice.write(data)
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
539 downloadIODevice.close()
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
540 if QFile.exists(fileName):
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
541 QFile.remove(fileName)
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
542 downloadIODevice.rename(fileName)
4626
c891c7ad6b60 Added some missing deleteLater() calls.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
543 reply.deleteLater()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
544
6156
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
545 if doneMethod is not None:
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
546 doneMethod(ok, fileName)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
547
6156
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
548 def __downloadCancel(self, reply=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550 Private slot to cancel the current download.
6156
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
551
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
552 @param reply reference to the network reply
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
553 @type QNetworkReply
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554 """
6156
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
555 if reply is None:
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
556 if self.__replies:
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
557 reply = self.__replies[0]
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
558 self.__pluginsToDownload = []
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
559 if reply is not None:
270
41505c92ac31 Added code to enhance the proxy configuration and removed the usage of QHttp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 80
diff changeset
560 reply.abort()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561
270
41505c92ac31 Added code to enhance the proxy configuration and removed the usage of QHttp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 80
diff changeset
562 def __downloadProgress(self, done, total):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
564 Private slot to show the download progress.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
565
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
566 @param done number of bytes downloaded so far (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567 @param total total bytes to be downloaded (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
568 """
270
41505c92ac31 Added code to enhance the proxy configuration and removed the usage of QHttp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 80
diff changeset
569 if total:
41505c92ac31 Added code to enhance the proxy configuration and removed the usage of QHttp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 80
diff changeset
570 self.downloadProgress.setMaximum(total)
41505c92ac31 Added code to enhance the proxy configuration and removed the usage of QHttp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 80
diff changeset
571 self.downloadProgress.setValue(done)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
572
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
573 def addEntry(self, name, short, description, url, author, version,
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
574 filename, status):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
575 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
576 Public method to add an entry to the list.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
577
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
578 @param name data for the name field (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
579 @param short data for the short field (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
580 @param description data for the description field (list of strings)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
581 @param url data for the url field (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
582 @param author data for the author field (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
583 @param version data for the version field (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
584 @param filename data for the filename field (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
585 @param status status of the plugin (string [stable, unstable, unknown])
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
586 """
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
587 pluginName = filename.rsplit("-", 1)[0]
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
588 if pluginName in self.__hiddenPlugins:
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
589 return
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
590
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
591 if status == "stable":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
592 if self.__stableItem is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
593 self.__stableItem = \
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
594 QTreeWidgetItem(self.repositoryList,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
595 [self.tr("Stable")])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
596 self.__stableItem.setExpanded(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
597 parent = self.__stableItem
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
598 elif status == "unstable":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
599 if self.__unstableItem is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
600 self.__unstableItem = \
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
601 QTreeWidgetItem(self.repositoryList,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
602 [self.tr("Unstable")])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
603 self.__unstableItem.setExpanded(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
604 parent = self.__unstableItem
6023
c6dabc972560 Added an "obsolete" category to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5975
diff changeset
605 elif status == "obsolete":
c6dabc972560 Added an "obsolete" category to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5975
diff changeset
606 if self.__obsoleteItem is None:
c6dabc972560 Added an "obsolete" category to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5975
diff changeset
607 self.__obsoleteItem = \
c6dabc972560 Added an "obsolete" category to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5975
diff changeset
608 QTreeWidgetItem(self.repositoryList,
c6dabc972560 Added an "obsolete" category to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5975
diff changeset
609 [self.tr("Obsolete")])
c6dabc972560 Added an "obsolete" category to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5975
diff changeset
610 self.__obsoleteItem.setExpanded(True)
c6dabc972560 Added an "obsolete" category to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5975
diff changeset
611 parent = self.__obsoleteItem
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
612 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
613 if self.__unknownItem is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
614 self.__unknownItem = \
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
615 QTreeWidgetItem(self.repositoryList,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
616 [self.tr("Unknown")])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
617 self.__unknownItem.setExpanded(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
618 parent = self.__unknownItem
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
619 itm = QTreeWidgetItem(parent, [name, version, short])
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
620
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
621 itm.setData(0, PluginRepositoryWidget.UrlRole, url)
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
622 itm.setData(0, PluginRepositoryWidget.FilenameRole, filename)
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
623 itm.setData(0, PluginRepositoryWidget.AuthorRole, author)
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
624 itm.setData(0, PluginRepositoryWidget.DescrRole, description)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
625
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
626 updateStatus = self.__updateStatus(filename, version)
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
627 if updateStatus == PluginRepositoryWidget.PluginStatusUpToDate:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
628 itm.setIcon(1, UI.PixmapCache.getIcon("empty.png"))
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
629 itm.setToolTip(1, self.tr("up-to-date"))
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
630 elif updateStatus == PluginRepositoryWidget.PluginStatusNew:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
631 itm.setIcon(1, UI.PixmapCache.getIcon("download.png"))
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
632 itm.setToolTip(1, self.tr("new download available"))
5854
be976799b8c0 Added a bar with counts for new/local updates/remote updates to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5755
diff changeset
633 self.__newItems += 1
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
634 elif updateStatus == PluginRepositoryWidget.PluginStatusLocalUpdate:
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
635 itm.setIcon(1, UI.PixmapCache.getIcon("updateLocal.png"))
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
636 itm.setToolTip(1, self.tr("update installable"))
5854
be976799b8c0 Added a bar with counts for new/local updates/remote updates to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5755
diff changeset
637 self.__updateLocalItems += 1
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
638 elif updateStatus == PluginRepositoryWidget.PluginStatusRemoteUpdate:
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
639 itm.setIcon(1, UI.PixmapCache.getIcon("updateRemote.png"))
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
640 itm.setToolTip(1, self.tr("updated download available"))
5854
be976799b8c0 Added a bar with counts for new/local updates/remote updates to the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5755
diff changeset
641 self.__updateRemoteItems += 1
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
642
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
643 def __updateStatus(self, filename, version):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
644 """
5868
c1a98c164cd3 Started implementing a downloader and installer for web browser spell check dictionaries.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5854
diff changeset
645 Private method to check the given archive update status.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
646
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
647 @param filename data for the filename field (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
648 @param version data for the version field (string)
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
649 @return plug-in update status (integer, one of PluginStatusNew,
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
650 PluginStatusUpToDate, PluginStatusLocalUpdate,
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
651 PluginStatusRemoteUpdate)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
652 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
653 archive = os.path.join(Preferences.getPluginManager("DownloadPath"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
654 filename)
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
655
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
656 # check, if it is an update (i.e. we already have archives
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
657 # with the same pattern)
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
658 archivesPattern = archive.rsplit('-', 1)[0] + "-*.zip"
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
659 if len(glob.glob(archivesPattern)) == 0:
6599
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
660 # Check against installed/loaded plug-ins
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
661 pluginName = filename.rsplit('-', 1)[0]
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
662 pluginDetails = self.__pluginManager.getPluginDetails(pluginName)
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
663 if pluginDetails is None:
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
664 return PluginRepositoryWidget.PluginStatusNew
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
665 pluginVersionTuple = Globals.versionToTuple(
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
666 pluginDetails["version"])[:3]
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
667 versionTuple = Globals.versionToTuple(version)[:3]
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
668 if pluginVersionTuple < versionTuple:
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
669 return PluginRepositoryWidget.PluginStatusRemoteUpdate
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
670 else:
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
671 return PluginRepositoryWidget.PluginStatusUpToDate
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
672
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
673 # check, if the archive exists
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
674 if not os.path.exists(archive):
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
675 return PluginRepositoryWidget.PluginStatusRemoteUpdate
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
676
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
677 # check, if the archive is a valid zip file
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
678 if not zipfile.is_zipfile(archive):
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
679 return PluginRepositoryWidget.PluginStatusRemoteUpdate
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
680
5588
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5395
diff changeset
681 zipFile = zipfile.ZipFile(archive, "r")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
682 try:
5588
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5395
diff changeset
683 aversion = zipFile.read("VERSION").decode("utf-8")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
684 except KeyError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
685 aversion = ""
5588
6ba512d9f46a Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5395
diff changeset
686 zipFile.close()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
687
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
688 if aversion == version:
6599
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
689 # Check against installed/loaded plug-ins
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
690 pluginName = filename.rsplit('-', 1)[0]
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
691 pluginDetails = self.__pluginManager.getPluginDetails(pluginName)
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
692 if pluginDetails is None:
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
693 return PluginRepositoryWidget.PluginStatusLocalUpdate
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
694 if Globals.versionToTuple(pluginDetails["version"])[:3] < \
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
695 Globals.versionToTuple(version)[:3]:
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
696 return PluginRepositoryWidget.PluginStatusLocalUpdate
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
697 else:
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
698 return PluginRepositoryWidget.PluginStatusUpToDate
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
699 else:
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
700 return PluginRepositoryWidget.PluginStatusRemoteUpdate
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
701
270
41505c92ac31 Added code to enhance the proxy configuration and removed the usage of QHttp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 80
diff changeset
702 def __sslErrors(self, reply, errors):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
703 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
704 Private slot to handle SSL errors.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
705
270
41505c92ac31 Added code to enhance the proxy configuration and removed the usage of QHttp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 80
diff changeset
706 @param reply reference to the reply object (QNetworkReply)
41505c92ac31 Added code to enhance the proxy configuration and removed the usage of QHttp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 80
diff changeset
707 @param errors list of SSL errors (list of QSslError)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
708 """
2360
b6bf3925e3e1 Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2354
diff changeset
709 ignored = self.__sslErrorHandler.sslErrorsReply(reply, errors)[0]
b6bf3925e3e1 Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2354
diff changeset
710 if ignored == E5SslErrorHandler.NotIgnored:
6156
ac12549e521a PluginRepositoryWidget: Did some code optimizations in order to get rid of status attributes.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6088
diff changeset
711 self.__downloadCancel(reply)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
712
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
713 def getDownloadedPlugins(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
714 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
715 Public method to get the list of recently downloaded plugin files.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
716
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
717 @return list of plugin filenames (list of strings)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
718 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
719 return self.__pluginsDownloaded
1763
25a83ac16a5e Extended the Plugin Repository dialog to allow to change the repository URL manually and to show a message, if the URL has changed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1582
diff changeset
720
25a83ac16a5e Extended the Plugin Repository dialog to allow to change the repository URL manually and to show a message, if the URL has changed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1582
diff changeset
721 @pyqtSlot(bool)
25a83ac16a5e Extended the Plugin Repository dialog to allow to change the repository URL manually and to show a message, if the URL has changed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1582
diff changeset
722 def on_repositoryUrlEditButton_toggled(self, checked):
25a83ac16a5e Extended the Plugin Repository dialog to allow to change the repository URL manually and to show a message, if the URL has changed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1582
diff changeset
723 """
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
724 Private slot to set the read only status of the repository URL line
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
725 edit.
1763
25a83ac16a5e Extended the Plugin Repository dialog to allow to change the repository URL manually and to show a message, if the URL has changed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1582
diff changeset
726
25a83ac16a5e Extended the Plugin Repository dialog to allow to change the repository URL manually and to show a message, if the URL has changed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1582
diff changeset
727 @param checked state of the push button (boolean)
25a83ac16a5e Extended the Plugin Repository dialog to allow to change the repository URL manually and to show a message, if the URL has changed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1582
diff changeset
728 """
25a83ac16a5e Extended the Plugin Repository dialog to allow to change the repository URL manually and to show a message, if the URL has changed.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1582
diff changeset
729 self.repositoryUrlEdit.setReadOnly(not checked)
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
730
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
731 def __closeAndInstall(self):
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
732 """
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
733 Private method to close the dialog and invoke the install dialog.
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
734 """
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
735 if not self.__pluginsDownloaded and self.__selectedItems():
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
736 for itm in self.__selectedItems():
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
737 filename = os.path.join(
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
738 Preferences.getPluginManager("DownloadPath"),
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
739 itm.data(0, PluginRepositoryWidget.FilenameRole))
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
740 self.__pluginsDownloaded.append(filename)
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
741 self.closeAndInstall.emit()
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
742
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
743 def __hidePlugin(self):
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
744 """
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
745 Private slot to hide the current plug-in.
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
746 """
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
747 itm = self.__selectedItems()[0]
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
748 pluginName = (itm.data(0, PluginRepositoryWidget.FilenameRole)
3246
4cd58a0d6c28 Some code style fixes and renaming of UtilitiesPython2.py2flakes to UtilitiesPython2.pyflakes to make it clear, that it is just a copy of the one in Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3200
diff changeset
749 .rsplit("-", 1)[0])
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
750 self.__updateHiddenPluginsList([pluginName])
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
751
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
752 def __hideSelectedPlugins(self):
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
753 """
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
754 Private slot to hide all selected plug-ins.
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
755 """
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
756 hideList = []
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
757 for itm in self.__selectedItems():
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
758 pluginName = (itm.data(0, PluginRepositoryWidget.FilenameRole)
3246
4cd58a0d6c28 Some code style fixes and renaming of UtilitiesPython2.py2flakes to UtilitiesPython2.pyflakes to make it clear, that it is just a copy of the one in Utilities.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3200
diff changeset
759 .rsplit("-", 1)[0])
3200
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
760 hideList.append(pluginName)
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
761 self.__updateHiddenPluginsList(hideList)
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
762
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
763 def __showAllPlugins(self):
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
764 """
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
765 Private slot to show all plug-ins.
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
766 """
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
767 self.__hiddenPlugins = []
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
768 self.__updateHiddenPluginsList([])
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
769
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
770 def __hasHiddenPlugins(self):
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
771 """
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
772 Private method to check, if there are any hidden plug-ins.
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
773
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
774 @return flag indicating the presence of hidden plug-ins (boolean)
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
775 """
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
776 return bool(self.__hiddenPlugins)
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
777
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
778 def __updateHiddenPluginsList(self, hideList):
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
779 """
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
780 Private method to store the list of hidden plug-ins to the settings.
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
781
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
782 @param hideList list of plug-ins to add to the list of hidden ones
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
783 (list of string)
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
784 """
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
785 if hideList:
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
786 self.__hiddenPlugins.extend(
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
787 [p for p in hideList if p not in self.__hiddenPlugins])
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
788 Preferences.setPluginManager("HiddenPlugins", self.__hiddenPlugins)
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
789 self.__populateList()
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
790
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
791 def __cleanupDownloads(self):
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
792 """
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
793 Private slot to cleanup the plug-in downloads area.
83bde5e6f146 Extended the plugin repository dialog to allow to hide unwanted entries and cleanup the plugin downloads area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3190
diff changeset
794 """
5739
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
795 PluginRepositoryDownloadCleanup()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
796
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
797
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
798 class PluginRepositoryDialog(QDialog):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
799 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
800 Class for the dialog variant.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
801 """
6599
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
802 def __init__(self, pluginManager, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
803 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
804 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
805
6599
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
806 @param pluginManager reference to the plugin manager object
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
807 @type PluginManager
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
808 @param parent reference to the parent widget
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
809 @type QWidget
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
810 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2404
diff changeset
811 super(PluginRepositoryDialog, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
812 self.setSizeGripEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
813
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
814 self.__layout = QVBoxLayout(self)
2824
858412c29c34 Replaced the obsoleted method setMargin() with setContentsMargins().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
815 self.__layout.setContentsMargins(0, 0, 0, 0)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
816 self.setLayout(self.__layout)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
817
6599
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
818 self.cw = PluginRepositoryWidget(pluginManager, self)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
819 size = self.cw.size()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
820 self.__layout.addWidget(self.cw)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
821 self.resize(size)
3189
9a21c547de5f Fixed issues showing the correct window title for some dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
822 self.setWindowTitle(self.cw.windowTitle())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
823
3345
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3246
diff changeset
824 self.cw.buttonBox.accepted.connect(self.accept)
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3246
diff changeset
825 self.cw.buttonBox.rejected.connect(self.reject)
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 465
diff changeset
826 self.cw.closeAndInstall.connect(self.__closeAndInstall)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
827
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
828 def __closeAndInstall(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
829 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
830 Private slot to handle the closeAndInstall signal.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
831 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
832 self.done(QDialog.Accepted + 1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
833
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
834 def getDownloadedPlugins(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
835 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
836 Public method to get the list of recently downloaded plugin files.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
837
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
838 @return list of plugin filenames (list of strings)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
839 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
840 return self.cw.getDownloadedPlugins()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
841
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
842
2101
5bac7dee9e1a Introduced the E5MainWindow class allowing to set a style for all the main windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2094
diff changeset
843 class PluginRepositoryWindow(E5MainWindow):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
844 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
845 Main window class for the standalone dialog.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
846 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
847 def __init__(self, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
848 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
849 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
850
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
851 @param parent reference to the parent widget (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
852 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2404
diff changeset
853 super(PluginRepositoryWindow, self).__init__(parent)
6599
419f36a46608 PluginRepositoryDialog: added version check for situation, where the downloaded files have been deleted already.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6156
diff changeset
854 self.cw = PluginRepositoryWidget(None, self)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
855 size = self.cw.size()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
856 self.setCentralWidget(self.cw)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
857 self.resize(size)
3189
9a21c547de5f Fixed issues showing the correct window title for some dialogs.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3160
diff changeset
858 self.setWindowTitle(self.cw.windowTitle())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
859
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
860 self.setStyle(Preferences.getUI("Style"),
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
861 Preferences.getUI("StyleSheet"))
2101
5bac7dee9e1a Introduced the E5MainWindow class allowing to set a style for all the main windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2094
diff changeset
862
3345
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3246
diff changeset
863 self.cw.buttonBox.accepted.connect(self.close)
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3246
diff changeset
864 self.cw.buttonBox.rejected.connect(self.close)
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 465
diff changeset
865 self.cw.closeAndInstall.connect(self.__startPluginInstall)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
866
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
867 def __startPluginInstall(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
868 """
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
869 Private slot to start the eric6 plugin installation dialog.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
870 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
871 proc = QProcess()
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
872 applPath = os.path.join(getConfig("ericDir"), "eric6_plugininstall.py")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
873
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
874 args = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
875 args.append(applPath)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
876 args += self.cw.getDownloadedPlugins()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
877
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
878 if not os.path.isfile(applPath) or \
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
879 not proc.startDetached(sys.executable, args):
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
880 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
881 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
882 self.tr('Process Generation Error'),
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
883 self.tr(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
884 '<p>Could not start the process.<br>'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
885 'Ensure that it is available as <b>{0}</b>.</p>'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
886 ).format(applPath),
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
887 self.tr('OK'))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
888
580
45c38566b001 Implemented the plug-in repository reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 553
diff changeset
889 self.close()
5739
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
890
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
891
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
892 def PluginRepositoryDownloadCleanup(quiet=False):
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
893 """
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
894 Module function to clean up the plug-in downloads area.
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
895
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
896 @param quiet flag indicating quiet operations
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
897 @type bool
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
898 """
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
899 downloadPath = Preferences.getPluginManager("DownloadPath")
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
900 downloads = {} # plug-in name as key, file name as value
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
901
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
902 # step 1: extract plug-ins and downloaded files
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
903 for pluginFile in os.listdir(downloadPath):
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
904 if not os.path.isfile(os.path.join(downloadPath, pluginFile)):
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
905 continue
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
906
6064
32a8b51c89da Fixed a bug in the plug-in repository dialog causing the cleanup function to fail, if the download directory contains a file without version info seperated by '-'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
907 try:
32a8b51c89da Fixed a bug in the plug-in repository dialog causing the cleanup function to fail, if the download directory contains a file without version info seperated by '-'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
908 pluginName, pluginVersion = \
32a8b51c89da Fixed a bug in the plug-in repository dialog causing the cleanup function to fail, if the download directory contains a file without version info seperated by '-'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
909 pluginFile.replace(".zip", "").rsplit("-", 1)
32a8b51c89da Fixed a bug in the plug-in repository dialog causing the cleanup function to fail, if the download directory contains a file without version info seperated by '-'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
910 pluginVersionList = re.split("[._-]", pluginVersion)
32a8b51c89da Fixed a bug in the plug-in repository dialog causing the cleanup function to fail, if the download directory contains a file without version info seperated by '-'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
911 for index in range(len(pluginVersionList)):
32a8b51c89da Fixed a bug in the plug-in repository dialog causing the cleanup function to fail, if the download directory contains a file without version info seperated by '-'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
912 try:
32a8b51c89da Fixed a bug in the plug-in repository dialog causing the cleanup function to fail, if the download directory contains a file without version info seperated by '-'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
913 pluginVersionList[index] = int(pluginVersionList[index])
32a8b51c89da Fixed a bug in the plug-in repository dialog causing the cleanup function to fail, if the download directory contains a file without version info seperated by '-'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
914 except ValueError:
32a8b51c89da Fixed a bug in the plug-in repository dialog causing the cleanup function to fail, if the download directory contains a file without version info seperated by '-'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
915 # use default of 0
32a8b51c89da Fixed a bug in the plug-in repository dialog causing the cleanup function to fail, if the download directory contains a file without version info seperated by '-'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
916 pluginVersionList[index] = 0
32a8b51c89da Fixed a bug in the plug-in repository dialog causing the cleanup function to fail, if the download directory contains a file without version info seperated by '-'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
917 except ValueError:
32a8b51c89da Fixed a bug in the plug-in repository dialog causing the cleanup function to fail, if the download directory contains a file without version info seperated by '-'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
918 # rsplit() returned just one entry, i.e. file name doesn't contain
32a8b51c89da Fixed a bug in the plug-in repository dialog causing the cleanup function to fail, if the download directory contains a file without version info seperated by '-'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
919 # version info separated by '-'
32a8b51c89da Fixed a bug in the plug-in repository dialog causing the cleanup function to fail, if the download directory contains a file without version info seperated by '-'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
920 # => assume version 0.0.0
32a8b51c89da Fixed a bug in the plug-in repository dialog causing the cleanup function to fail, if the download directory contains a file without version info seperated by '-'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
921 pluginName = pluginFile.replace(".zip", "")
32a8b51c89da Fixed a bug in the plug-in repository dialog causing the cleanup function to fail, if the download directory contains a file without version info seperated by '-'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
922 pluginVersionList = [0, 0, 0]
5975
3bc24855b254 Fixed an issue cleaning up the plug-in download area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
923
5739
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
924 if pluginName not in downloads:
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
925 downloads[pluginName] = []
5975
3bc24855b254 Fixed an issue cleaning up the plug-in download area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
926 downloads[pluginName].append((pluginFile, tuple(pluginVersionList)))
5739
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
927
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
928 # step 2: delete old entries
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
929 hiddenPlugins = Preferences.getPluginManager("HiddenPlugins")
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
930 for pluginName in downloads:
5975
3bc24855b254 Fixed an issue cleaning up the plug-in download area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
931 downloads[pluginName].sort(key=lambda x: x[1])
5739
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
932
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
933 if pluginName in hiddenPlugins and \
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
934 not Preferences.getPluginManager("KeepHidden"):
6024
e5a2b8b613dd Fix for the plug-in repository dialog.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6023
diff changeset
935 removeFiles = [f[0] for f in downloads[pluginName]]
5739
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
936 else:
5975
3bc24855b254 Fixed an issue cleaning up the plug-in download area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
937 removeFiles = [f[0] for f in downloads[pluginName][
3bc24855b254 Fixed an issue cleaning up the plug-in download area.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5868
diff changeset
938 :-Preferences.getPluginManager("KeepGenerations")]]
5739
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
939 for removeFile in removeFiles:
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
940 try:
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
941 os.remove(os.path.join(downloadPath, removeFile))
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
942 except (IOError, OSError) as err:
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
943 if not quiet:
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
944 E5MessageBox.critical(
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
945 None,
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
946 QCoreApplication.translate(
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
947 "PluginRepositoryWidget",
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
948 "Cleanup of Plugin Downloads"),
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
949 QCoreApplication.translate(
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
950 "PluginRepositoryWidget",
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
951 """<p>The plugin download <b>{0}</b> could"""
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
952 """ not be deleted.</p><p>Reason: {1}</p>""")
a870f5f03baa Added an option to the plug-in manager to cleanup the plug-ins download area during startup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5588
diff changeset
953 .format(removeFile, str(err)))

eric ide

mercurial