PluginManager/PluginRepositoryDialog.py

Fri, 01 Jan 2016 12:12:12 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Fri, 01 Jan 2016 12:12:12 +0100
changeset 4631
5c1a96925da4
parent 4629
99aaac59be4f
child 5047
04e5dfbd3f3d
permissions
-rw-r--r--

Updated copyright for 2016.

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
4631
5c1a96925da4 Updated copyright for 2016.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4629
diff changeset
3 # Copyright (c) 2007 - 2016 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
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
17
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
18 from PyQt5.QtCore import pyqtSignal, pyqtSlot, Qt, QFile, QIODevice, QUrl, \
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
19 QProcess, QPoint
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
20 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
21 QTreeWidgetItem, QDialog, QVBoxLayout, QMenu
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3484
diff changeset
22 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
23 QNetworkReply, QNetworkConfigurationManager
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
25 from .Ui_PluginRepositoryDialog import Ui_PluginRepositoryDialog
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
26
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
27 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
28 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
29 from E5Gui.E5Application import e5App
536
6d8d39753c82 Started replaceing QMessageBox methods with own methods.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 501
diff changeset
30
286
652f5159f1c3 Prepared to have individual proxies per scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 270
diff changeset
31 from E5Network.E5NetworkProxyFactory import proxyAuthenticationRequired
2354
c63de4af553d Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
32 try:
c63de4af553d Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
33 from E5Network.E5SslErrorHandler import E5SslErrorHandler
c63de4af553d Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
34 SSL_AVAILABLE = True
c63de4af553d Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
35 except ImportError:
c63de4af553d Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
36 SSL_AVAILABLE = False
286
652f5159f1c3 Prepared to have individual proxies per scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 270
diff changeset
37
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 import Utilities
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 import Preferences
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 import UI.PixmapCache
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
42
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
43 from eric6config import getConfig
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 class PluginRepositoryWidget(QWidget, Ui_PluginRepositoryDialog):
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 implementing a dialog showing the available plugins.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
50 @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
51 pressed
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 """
495
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 465
diff changeset
53 closeAndInstall = pyqtSignal()
b31b0bffa5b0 Continued porting signal/slot usage to the new API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 465
diff changeset
54
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
55 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
56 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
57 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
58 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
59
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 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
61 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
62 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
63 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
64
2192
61b3849df76d Changed a few places to use the new notification system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2101
diff changeset
65 def __init__(self, parent=None, external=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
66 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
67 Constructor
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 @param parent parent of this dialog (QWidget)
2960
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
70 @param external flag indicating an instatiation as a main
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
71 window (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72 """
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
73 super(PluginRepositoryWidget, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 self.setupUi(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
76 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
77 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
78 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
79 self.tr("Download"), QDialogButtonBox.ActionRole)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 self.__downloadButton.setEnabled(False)
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
81 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
82 self.tr("Download && Install"),
1364
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
83 QDialogButtonBox.ActionRole)
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
84 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
85 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
86 self.tr("Cancel"), QDialogButtonBox.ActionRole)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 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
88 self.buttonBox.addButton(self.tr("Close && Install"),
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89 QDialogButtonBox.ActionRole)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 self.__downloadCancelButton.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 self.__installButton.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
92
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
93 self.repositoryUrlEdit.setText(
3676
2f62b060a931 Renamed a few excternal references.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3670
diff changeset
94 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
95
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
96 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
97 self.repositoryList.columnCount(), "")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 self.repositoryList.header().setSortIndicator(0, Qt.AscendingOrder)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99
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
100 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
101 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
102 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
103 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
104 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
105 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
106 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
107 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
108 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
109 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
110 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
111
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
112 self.pluginRepositoryFile = \
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
113 os.path.join(Utilities.getConfigDir(), "PluginRepository")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
114
2192
61b3849df76d Changed a few places to use the new notification system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2101
diff changeset
115 self.__external = external
61b3849df76d Changed a few places to use the new notification system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2101
diff changeset
116
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
117 # 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
118 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
119 self.__networkManager.proxyAuthenticationRequired.connect(
286
652f5159f1c3 Prepared to have individual proxies per scheme.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 270
diff changeset
120 proxyAuthenticationRequired)
798
5c1786fad576 Fixed an issue with Qt installations that don't support SSL.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
121 if SSL_AVAILABLE:
2354
c63de4af553d Centralized the SSL error handling in E5SslErrorHandler.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2302
diff changeset
122 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
123 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
124 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
125
4629
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
126 self.__networkConfigurationManager = QNetworkConfigurationManager(self)
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
127 self.__onlineStateChanged(
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
128 self.__networkConfigurationManager.isOnline())
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
129
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
130 self.__networkConfigurationManager.onlineStateChanged.connect(
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
131 self.__onlineStateChanged)
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
132
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 self.__doneMethod = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 self.__inDownload = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135 self.__pluginsToDownload = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 self.__pluginsDownloaded = []
1364
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
137 self.__isDownloadInstall = False
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
138 self.__allDownloadedOk = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
139
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
140 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
141
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 self.__populateList()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
143
4629
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
144 @pyqtSlot(bool)
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
145 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
146 """
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
147 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
148
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
149 @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
150 @type bool
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
151 """
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
152 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
153 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
154 if online:
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
155 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
156 else:
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
157 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
158 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
159
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
160 @pyqtSlot(QAbstractButton)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
161 def on_buttonBox_clicked(self, button):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
162 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
163 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
164
9453efa25fd5 Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2824
diff changeset
165 @param button reference to the button pressed (QAbstractButton)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
166 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
167 if button == self.__updateButton:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
168 self.__updateList()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
169 elif button == self.__downloadButton:
1364
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
170 self.__isDownloadInstall = False
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
171 self.__downloadPlugins()
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
172 elif button == self.__downloadInstallButton:
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
173 self.__isDownloadInstall = True
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
174 self.__allDownloadedOk = True
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 self.__downloadPlugins()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176 elif button == self.__downloadCancelButton:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 self.__downloadCancel()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 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
179 self.__closeAndInstall()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 def __formatDescription(self, lines):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 Private method to format the description.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 @param lines lines of the description (list of strings)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 @return formatted description (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 # remove empty line at start and end
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 newlines = lines[:]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 if len(newlines) and newlines[0] == '':
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191 del newlines[0]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 if len(newlines) and newlines[-1] == '':
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 del newlines[-1]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 # replace empty lines by newline character
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 index = 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197 while index < len(newlines):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 if newlines[index] == '':
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 newlines[index] = '\n'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200 index += 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
201
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 # join lines by a blank
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203 return ' '.join(newlines)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204
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
205 @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
206 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
207 """
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
208 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
209
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
210 @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
211 """
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
212 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
213 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
214 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
215 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
216 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
217 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
218 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
219
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 @pyqtSlot(QTreeWidgetItem, QTreeWidgetItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 def on_repositoryList_currentItemChanged(self, current, previous):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 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
224
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 @param current reference to the new current item (QTreeWidgetItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226 @param previous reference to the old current item (QTreeWidgetItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228 if self.__repositoryMissing or current is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
229 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230
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
231 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
232 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
233 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
234 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
235 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
236 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
237 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
238 current.data(0, PluginRepositoryWidget.AuthorRole) or "")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
239
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
240 def __selectedItems(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
241 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 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
243
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 @return list of selected items (list)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 ql = self.repositoryList.selectedItems()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 for index in range(self.repositoryList.topLevelItemCount()):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
248 ti = self.repositoryList.topLevelItem(index)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
249 if ti in ql:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 ql.remove(ti)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 return ql
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253 @pyqtSlot()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 def on_repositoryList_itemSelectionChanged(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 Private slot to handle a change of the selection.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 """
4629
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
258 self.__downloadButton.setEnabled(
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
259 len(self.__selectedItems()) and
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
260 self.__networkConfigurationManager.isOnline())
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
261 self.__downloadInstallButton.setEnabled(
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
262 len(self.__selectedItems()) and
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
263 self.__networkConfigurationManager.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
264 self.__installButton.setEnabled(len(self.__selectedItems()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 def __updateList(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 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
269 """
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
270 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
271 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
272 self.pluginRepositoryFile,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273 self.__downloadRepositoryFileDone)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
274
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
275 def __downloadRepositoryFileDone(self, status, filename):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
276 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
277 Private method called after the repository file was downloaded.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
278
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
279 @param status flaging indicating a successful download (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
280 @param filename full path of the downloaded file (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
281 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
282 self.__populateList()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
283
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
284 def __downloadPluginDone(self, status, filename):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
285 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
286 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
287
1364
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
288 @param status flag indicating a successful download (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
289 @param filename full path of the downloaded file (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
290 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
291 if status:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
292 self.__pluginsDownloaded.append(filename)
1364
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
293 if self.__isDownloadInstall:
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
294 self.__allDownloadedOk &= status
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
295
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
296 del self.__pluginsToDownload[0]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
297 if len(self.__pluginsToDownload):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
298 self.__downloadPlugin()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
299 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
300 self.__downloadPluginsDone()
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 __downloadPlugin(self):
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 to download the next plugin.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
305 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
306 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
307 self.__pluginsToDownload[0][1],
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
308 self.__downloadPluginDone)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
309
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
310 def __downloadPlugins(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
311 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
312 Private slot to download the selected plugins.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
313 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
314 self.__pluginsDownloaded = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
315 self.__pluginsToDownload = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
316 self.__downloadButton.setEnabled(False)
1364
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
317 self.__downloadInstallButton.setEnabled(False)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
318 self.__installButton.setEnabled(False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
319 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
320 if itm not in [self.__stableItem, self.__unstableItem,
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
321 self.__unknownItem]:
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
322 url = itm.data(0, PluginRepositoryWidget.UrlRole)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
323 filename = os.path.join(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
324 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
325 itm.data(0, PluginRepositoryWidget.FilenameRole))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
326 self.__pluginsToDownload.append((url, filename))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
327 self.__downloadPlugin()
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 __downloadPluginsDone(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 called, when the download of the plugins is finished.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
332 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
333 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
334 self.__downloadInstallButton.setEnabled(len(self.__selectedItems()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
335 self.__installButton.setEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
336 self.__doneMethod = None
2192
61b3849df76d Changed a few places to use the new notification system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2101
diff changeset
337 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
338 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
339 else:
61b3849df76d Changed a few places to use the new notification system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2101
diff changeset
340 ui = None
61b3849df76d Changed a few places to use the new notification system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2101
diff changeset
341 if ui and ui.notificationsEnabled():
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
342 ui.showNotification(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
343 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
344 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
345 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
346
1364
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
347 if self.__isDownloadInstall:
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
348 self.closeAndInstall.emit()
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
349 else:
2192
61b3849df76d Changed a few places to use the new notification system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2101
diff changeset
350 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
351 E5MessageBox.information(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
352 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
353 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
354 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
355 self.downloadProgress.setValue(0)
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
356
a2e74a43fadc Added code to download and install plug-ins.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1310
diff changeset
357 # 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
358 self.__populateList()
0
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 def __resortRepositoryList(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
361 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
362 Private method to resort the tree.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
363 """
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
364 self.repositoryList.sortItems(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
365 self.repositoryList.sortColumn(),
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
366 self.repositoryList.header().sortIndicatorOrder())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
367
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
368 def __populateList(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
369 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
370 Private method to populate the list of available plugins.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
371 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
372 self.repositoryList.clear()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
373 self.__stableItem = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
374 self.__unstableItem = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
375 self.__unknownItem = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
376
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
377 self.downloadProgress.setValue(0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
378 self.__doneMethod = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
379
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
380 if os.path.exists(self.pluginRepositoryFile):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
381 self.__repositoryMissing = False
580
45c38566b001 Implemented the plug-in repository reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 553
diff changeset
382 f = QFile(self.pluginRepositoryFile)
45c38566b001 Implemented the plug-in repository reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 553
diff changeset
383 if f.open(QIODevice.ReadOnly):
2404
cba0ff902c2b Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2360
diff changeset
384 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
385 reader = PluginRepositoryReader(f, self.addEntry)
580
45c38566b001 Implemented the plug-in repository reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 553
diff changeset
386 reader.readXML()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
387 self.repositoryList.resizeColumnToContents(0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 self.repositoryList.resizeColumnToContents(1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 self.repositoryList.resizeColumnToContents(2)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 self.__resortRepositoryList()
3676
2f62b060a931 Renamed a few excternal references.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3670
diff changeset
391 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
392 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
393 self.repositoryUrlEdit.setText(url)
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
394 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
395 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
396 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
397 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
398 """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
399 """ 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
400 """ the new repository file."""))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
401 else:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
402 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
403 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
404 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
405 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
406 "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
407 .format(self.pluginRepositoryFile))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
408 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
409 self.__repositoryMissing = True
3022
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
410 QTreeWidgetItem(
57179e4cdadd Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3020
diff changeset
411 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
412 ["", self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
413 "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
414 ])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
415 self.repositoryList.resizeColumnToContents(1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
416
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
417 def __downloadFile(self, url, filename, doneMethod=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
418 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
419 Private slot to download the given file.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
420
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
421 @param url URL for the download (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
422 @param filename local name of the file (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
423 @param doneMethod method to be called when done
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
424 """
4629
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
425 if self.__networkConfigurationManager.isOnline():
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
426 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
427 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
428 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
429 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
430
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
431 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
432
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
433 self.__doneMethod = doneMethod
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
434 self.__downloadURL = url
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
435 self.__downloadFileName = filename
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
436 self.__downloadIODevice = QFile(self.__downloadFileName + ".tmp")
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
437 self.__downloadCancelled = False
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
438
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
439 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
440 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
441 QNetworkRequest.AlwaysNetwork)
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
442 reply = self.__networkManager.get(request)
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
443 reply.finished.connect(self.__downloadFileDone)
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
444 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
445 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
446 else:
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
447 E5MessageBox.warning(
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
448 self,
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
449 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
450 self.tr(
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
451 """<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
452 """ 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
453 ).format(url, self.tr("Computer is offline.")))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454
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
455 def __downloadFileDone(self):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457 Private method called, after the file has been downloaded
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458 from the internet.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 self.__updateButton.setEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 self.__downloadCancelButton.setEnabled(False)
4629
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
462 self.__onlineStateChanged(
99aaac59be4f Added a status bar icon to show the online status.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4626
diff changeset
463 self.__networkConfigurationManager.isOnline())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 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
466 reply = self.sender()
41505c92ac31 Added code to enhance the proxy configuration and removed the usage of QHttp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 80
diff changeset
467 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
468 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
469 if reply.error() != QNetworkReply.NoError:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 ok = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 if not self.__downloadCancelled:
3020
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
472 E5MessageBox.warning(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
473 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
474 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
475 self.tr(
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
476 """<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
477 """ from {0}.</p><p>Error: {1}</p>"""
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
478 ).format(self.__downloadURL, reply.errorString())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479 )
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 self.downloadProgress.setValue(0)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481 self.__downloadURL = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 self.__downloadIODevice.remove()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483 self.__downloadIODevice = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
484 if self.repositoryList.topLevelItemCount():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
485 if self.repositoryList.currentItem() is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
486 self.repositoryList.setCurrentItem(
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
487 self.repositoryList.topLevelItem(0))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
488 else:
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
489 self.__downloadButton.setEnabled(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
490 len(self.__selectedItems()))
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
491 self.__downloadInstallButton.setEnabled(
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
492 len(self.__selectedItems()))
4626
c891c7ad6b60 Added some missing deleteLater() calls.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
493 reply.deleteLater()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
494 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495
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
496 self.__downloadIODevice.open(QIODevice.WriteOnly)
41505c92ac31 Added code to enhance the proxy configuration and removed the usage of QHttp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 80
diff changeset
497 self.__downloadIODevice.write(reply.readAll())
41505c92ac31 Added code to enhance the proxy configuration and removed the usage of QHttp.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 80
diff changeset
498 self.__downloadIODevice.close()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 if QFile.exists(self.__downloadFileName):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 QFile.remove(self.__downloadFileName)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501 self.__downloadIODevice.rename(self.__downloadFileName)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 self.__downloadIODevice = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503 self.__downloadURL = None
4626
c891c7ad6b60 Added some missing deleteLater() calls.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4021
diff changeset
504 reply.deleteLater()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
506 if self.__doneMethod is not None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507 self.__doneMethod(ok, self.__downloadFileName)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509 def __downloadCancel(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
510 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
511 Private slot to cancel the current download.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
512 """
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
513 if 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
514 reply = self.__replies[0]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
515 self.__downloadCancelled = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516 self.__pluginsToDownload = []
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
517 reply.abort()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
518
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
519 def __downloadProgress(self, done, total):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
520 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
521 Private slot to show the download progress.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
522
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523 @param done number of bytes downloaded so far (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
524 @param total total bytes to be downloaded (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525 """
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
526 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
527 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
528 self.downloadProgress.setValue(done)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
530 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
531 filename, status):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
532 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
533 Public method to add an entry to the list.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
535 @param name data for the name field (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
536 @param short data for the short field (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
537 @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
538 @param url data for the url field (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539 @param author data for the author field (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
540 @param version data for the version field (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541 @param filename data for the filename field (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 @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
543 """
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
544 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
545 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
546 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
547
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 if status == "stable":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549 if self.__stableItem is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550 self.__stableItem = \
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
551 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
552 [self.tr("Stable")])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553 self.__stableItem.setExpanded(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554 parent = self.__stableItem
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
555 elif status == "unstable":
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
556 if self.__unstableItem is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
557 self.__unstableItem = \
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
558 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
559 [self.tr("Unstable")])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
560 self.__unstableItem.setExpanded(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
561 parent = self.__unstableItem
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
562 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563 if self.__unknownItem is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
564 self.__unknownItem = \
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
565 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
566 [self.tr("Unknown")])
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567 self.__unknownItem.setExpanded(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
568 parent = self.__unknownItem
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
569 itm = QTreeWidgetItem(parent, [name, version, short])
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
570
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
571 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
572 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
573 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
574 itm.setData(0, PluginRepositoryWidget.DescrRole, description)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
575
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
576 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
577 if updateStatus == PluginRepositoryWidget.PluginStatusUpToDate:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
578 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
579 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
580 elif updateStatus == PluginRepositoryWidget.PluginStatusNew:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
581 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
582 itm.setToolTip(1, self.tr("new download available"))
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
583 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
584 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
585 itm.setToolTip(1, self.tr("update installable"))
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
586 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
587 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
588 itm.setToolTip(1, self.tr("updated download available"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
589
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
590 def __updateStatus(self, filename, version):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
591 """
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
592 Private method to check, if the given archive update status.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
593
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
594 @param filename data for the filename field (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
595 @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
596 @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
597 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
598 PluginStatusRemoteUpdate)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
599 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
600 archive = os.path.join(Preferences.getPluginManager("DownloadPath"),
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
601 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
602
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
603 # 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
604 # 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
605 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
606 if len(glob.glob(archivesPattern)) == 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
607 return PluginRepositoryWidget.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
608
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
609 # check, if the archive exists
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
610 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
611 return PluginRepositoryWidget.PluginStatusRemoteUpdate
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
612
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
613 # check, if the archive is a valid zip file
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
614 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
615 return PluginRepositoryWidget.PluginStatusRemoteUpdate
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
616
75
035e71f2edcd Fixed a porting bug related to the usage of zipfile.ZipFile.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 50
diff changeset
617 zip = zipfile.ZipFile(archive, "r")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
618 try:
48
f4274afeba82 Ported the zipfile related code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 45
diff changeset
619 aversion = zip.read("VERSION").decode("utf-8")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
620 except KeyError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
621 aversion = ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
622 zip.close()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
623
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
624 if aversion == 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
625 if not self.__external:
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 # Check against installed/loaded 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
627 pluginManager = e5App().getObject("PluginManager")
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
628 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
629 pluginDetails = pluginManager.getPluginDetails(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
630 if pluginDetails is None or pluginDetails["version"] < 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
631 return 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
632
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
633 return PluginRepositoryWidget.PluginStatusUpToDate
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 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
635 return PluginRepositoryWidget.PluginStatusRemoteUpdate
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636
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
637 def __sslErrors(self, reply, errors):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
638 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
639 Private slot to handle SSL errors.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
640
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
641 @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
642 @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
643 """
2360
b6bf3925e3e1 Improved the SSL error handling logic a bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2354
diff changeset
644 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
645 if ignored == E5SslErrorHandler.NotIgnored:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
646 self.__downloadCancelled = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
647
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
648 def getDownloadedPlugins(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
649 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
650 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
651
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
652 @return list of plugin filenames (list of strings)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
653 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
654 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
655
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
656 @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
657 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
658 """
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
659 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
660 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
661
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
662 @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
663 """
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
664 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
665
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
666 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
667 """
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
668 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
669 """
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
670 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
671 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
672 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
673 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
674 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
675 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
676 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
677
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
678 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
679 """
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
680 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
681 """
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
682 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
683 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
684 .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
685 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
686
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
687 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
688 """
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
689 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
690 """
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
691 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
692 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
693 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
694 .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
695 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
696 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
697
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
698 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
699 """
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 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
701 """
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
702 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
703 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
704
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
705 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
706 """
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
707 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
708
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
709 @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
710 """
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
711 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
712
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
713 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
714 """
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
715 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
716
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
717 @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
718 (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
719 """
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
720 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
721 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
722 [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
723 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
724 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
725
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
726 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
727 """
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
728 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
729 """
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 downloadPath = 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
731 downloads = {} # plug-in name as key, file name as value
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 # step 1: extract plug-ins and downloaded files
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 for pluginFile in os.listdir(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
735 if not os.path.isfile(os.path.join(downloadPath, pluginFile)):
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 continue
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
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 pluginName = pluginFile.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
739 if pluginName not in downloads:
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 downloads[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
741 downloads[pluginName].append(pluginFile)
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 # step 2: delete old entries
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 for pluginName in downloads:
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 downloads[pluginName].sort()
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 if pluginName in self.__hiddenPlugins 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
748 not Preferences.getPluginManager("KeepHidden"):
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
749 removeFiles = downloads[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
750 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
751 removeFiles = downloads[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
752 :-Preferences.getPluginManager("KeepGenerations")]
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 for removeFile in removeFiles:
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 try:
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 os.remove(os.path.join(downloadPath, removeFile))
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 except (IOError, OSError) as err:
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 E5MessageBox.critical(
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 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
759 self.tr("Cleanup of Plugin Downloads"),
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 self.tr("""<p>The plugin download <b>{0}</b> could"""
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 """ not be deleted.</p><p>Reason: {1}</p>""")
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 .format(removeFile, str(err)))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
763
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
764
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
765 class PluginRepositoryDialog(QDialog):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
766 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
767 Class for the dialog variant.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
768 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
769 def __init__(self, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
770 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
771 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
772
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
773 @param parent reference to the parent widget (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
774 """
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
775 super(PluginRepositoryDialog, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
776 self.setSizeGripEnabled(True)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
777
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
778 self.__layout = QVBoxLayout(self)
2824
858412c29c34 Replaced the obsoleted method setMargin() with setContentsMargins().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2404
diff changeset
779 self.__layout.setContentsMargins(0, 0, 0, 0)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
780 self.setLayout(self.__layout)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
781
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
782 self.cw = PluginRepositoryWidget(self)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
783 size = self.cw.size()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
784 self.__layout.addWidget(self.cw)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
785 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
786 self.setWindowTitle(self.cw.windowTitle())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
787
3345
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3246
diff changeset
788 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
789 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
790 self.cw.closeAndInstall.connect(self.__closeAndInstall)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
791
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
792 def __closeAndInstall(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
793 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
794 Private slot to handle the closeAndInstall signal.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
795 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
796 self.done(QDialog.Accepted + 1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
797
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
798 def getDownloadedPlugins(self):
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 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
801
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
802 @return list of plugin filenames (list of strings)
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 return self.cw.getDownloadedPlugins()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
805
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
806
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
807 class PluginRepositoryWindow(E5MainWindow):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
808 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
809 Main window class for the standalone dialog.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
810 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 896
diff changeset
811 def __init__(self, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
812 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
813 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
814
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
815 @param parent reference to the parent widget (QWidget)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
816 """
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
817 super(PluginRepositoryWindow, self).__init__(parent)
2192
61b3849df76d Changed a few places to use the new notification system.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2101
diff changeset
818 self.cw = PluginRepositoryWidget(self, external=True)
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.setCentralWidget(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
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
824 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
825 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
826
3345
071afe8be2a1 Changed signal/slot usage to not use constructs like 'triggered[()].connect(...)' anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3246
diff changeset
827 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
828 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
829 self.cw.closeAndInstall.connect(self.__startPluginInstall)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
830
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
831 def __startPluginInstall(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
832 """
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
833 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
834 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
835 proc = QProcess()
3670
f0cb7579c0b4 Finished renaming eric5 for PyQt5 to eric6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3656
diff changeset
836 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
837
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
838 args = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
839 args.append(applPath)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
840 args += self.cw.getDownloadedPlugins()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
841
2992
dbdf27746da5 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2960
diff changeset
842 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
843 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
844 E5MessageBox.critical(
542e97d4ecb3 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2992
diff changeset
845 self,
3190
a9a94491c4fd Changed the code to use QObject.tr() instead of QObject.trUtf8().
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3189
diff changeset
846 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
847 self.tr(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
848 '<p>Could not start the process.<br>'
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
849 '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
850 ).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
851 self.tr('OK'))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
852
580
45c38566b001 Implemented the plug-in repository reader.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 553
diff changeset
853 self.close()

eric ide

mercurial