18 |
18 |
19 from PyQt6.QtCore import QFile, QIODevice, QObject, QUrl, pyqtSignal |
19 from PyQt6.QtCore import QFile, QIODevice, QObject, QUrl, pyqtSignal |
20 from PyQt6.QtGui import QPixmap |
20 from PyQt6.QtGui import QPixmap |
21 from PyQt6.QtNetwork import QNetworkAccessManager, QNetworkReply, QNetworkRequest |
21 from PyQt6.QtNetwork import QNetworkAccessManager, QNetworkReply, QNetworkRequest |
22 |
22 |
23 from eric7 import Globals, Preferences, Utilities |
23 from eric7 import Globals, Preferences |
24 from eric7.EricGui import EricPixmapCache |
24 from eric7.EricGui import EricPixmapCache |
25 from eric7.EricNetwork.EricNetworkProxyFactory import proxyAuthenticationRequired |
25 from eric7.EricNetwork.EricNetworkProxyFactory import proxyAuthenticationRequired |
26 from eric7.EricWidgets import EricMessageBox |
26 from eric7.EricWidgets import EricMessageBox |
27 from eric7.EricWidgets.EricApplication import ericApp |
27 from eric7.EricWidgets.EricApplication import ericApp |
28 from eric7.EricXML.PluginRepositoryReader import PluginRepositoryReader |
28 from eric7.EricXML.PluginRepositoryReader import PluginRepositoryReader |
29 from eric7.Globals import getConfig |
29 from eric7.Globals import getConfig |
|
30 from eric7.SystemUtilities import FileSystemUtilities, PythonUtilities |
30 |
31 |
31 try: |
32 try: |
32 from eric7.EricNetwork.EricSslErrorHandler import ( |
33 from eric7.EricNetwork.EricSslErrorHandler import ( |
33 EricSslErrorHandler, |
34 EricSslErrorHandler, |
34 EricSslErrorState, |
35 EricSslErrorState, |
116 self.__inactivePluginsKey = "PluginManager/InactivePlugins" |
117 self.__inactivePluginsKey = "PluginManager/InactivePlugins" |
117 |
118 |
118 self.pluginDirs = { |
119 self.pluginDirs = { |
119 "eric7": os.path.join(getConfig("ericDir"), "Plugins"), |
120 "eric7": os.path.join(getConfig("ericDir"), "Plugins"), |
120 "global": os.path.join( |
121 "global": os.path.join( |
121 Utilities.getPythonLibraryDirectory(), "eric7plugins" |
122 PythonUtilities.getPythonLibraryDirectory(), "eric7plugins" |
122 ), |
123 ), |
123 "user": os.path.join(Utilities.getConfigDir(), "eric7plugins"), |
124 "user": os.path.join(Globals.getConfigDir(), "eric7plugins"), |
124 } |
125 } |
125 self.__priorityOrder = ["eric7", "global", "user"] |
126 self.__priorityOrder = ["eric7", "global", "user"] |
126 |
127 |
127 self.__defaultDownloadDir = os.path.join(Utilities.getConfigDir(), "Downloads") |
128 self.__defaultDownloadDir = os.path.join(Globals.getConfigDir(), "Downloads") |
128 |
129 |
129 self.__activePlugins = {} |
130 self.__activePlugins = {} |
130 self.__inactivePlugins = {} |
131 self.__inactivePlugins = {} |
131 self.__onDemandActivePlugins = {} |
132 self.__onDemandActivePlugins = {} |
132 self.__onDemandInactivePlugins = {} |
133 self.__onDemandInactivePlugins = {} |
155 self.__loadPlugins() |
156 self.__loadPlugins() |
156 |
157 |
157 self.__checkPluginsDownloadDirectory() |
158 self.__checkPluginsDownloadDirectory() |
158 |
159 |
159 self.pluginRepositoryFile = os.path.join( |
160 self.pluginRepositoryFile = os.path.join( |
160 Utilities.getConfigDir(), "PluginRepository" |
161 Globals.getConfigDir(), "PluginRepository" |
161 ) |
162 ) |
162 |
163 |
163 # attributes for the network objects |
164 # attributes for the network objects |
164 self.__networkManager = QNetworkAccessManager(self) |
165 self.__networkManager = QNetworkAccessManager(self) |
165 self.__networkManager.proxyAuthenticationRequired.connect( |
166 self.__networkManager.proxyAuthenticationRequired.connect( |
203 |
204 |
204 @return tuple of a flag indicating existence of any of the plugin |
205 @return tuple of a flag indicating existence of any of the plugin |
205 directories (boolean) and a message (string) |
206 directories (boolean) and a message (string) |
206 """ |
207 """ |
207 if self.__develPluginFile: |
208 if self.__develPluginFile: |
208 path = Utilities.splitPath(self.__develPluginFile)[0] |
209 path = FileSystemUtilities.splitPath(self.__develPluginFile)[0] |
209 fname = os.path.join(path, "__init__.py") |
210 fname = os.path.join(path, "__init__.py") |
210 if not os.path.exists(fname): |
211 if not os.path.exists(fname): |
211 try: |
212 try: |
212 with open(fname, "w"): |
213 with open(fname, "w"): |
213 pass |
214 pass |
312 if self.pluginDirs[key] not in sys.path: |
313 if self.pluginDirs[key] not in sys.path: |
313 sys.path.insert(2, self.pluginDirs[key]) |
314 sys.path.insert(2, self.pluginDirs[key]) |
314 EricPixmapCache.addSearchPath(self.pluginDirs[key]) |
315 EricPixmapCache.addSearchPath(self.pluginDirs[key]) |
315 |
316 |
316 if self.__develPluginFile: |
317 if self.__develPluginFile: |
317 path = Utilities.splitPath(self.__develPluginFile)[0] |
318 path = FileSystemUtilities.splitPath(self.__develPluginFile)[0] |
318 if path not in sys.path: |
319 if path not in sys.path: |
319 sys.path.insert(2, path) |
320 sys.path.insert(2, path) |
320 EricPixmapCache.addSearchPath(path) |
321 EricPixmapCache.addSearchPath(path) |
321 |
322 |
322 def __loadPlugins(self): |
323 def __loadPlugins(self): |
323 """ |
324 """ |
324 Private method to load the plugins found. |
325 Private method to load the plugins found. |
325 """ |
326 """ |
326 develPluginName = "" |
327 develPluginName = "" |
327 if self.__develPluginFile: |
328 if self.__develPluginFile: |
328 develPluginPath, develPluginName = Utilities.splitPath( |
329 develPluginPath, develPluginName = FileSystemUtilities.splitPath( |
329 self.__develPluginFile |
330 self.__develPluginFile |
330 ) |
331 ) |
331 if self.isValidPluginName(develPluginName): |
332 if self.isValidPluginName(develPluginName): |
332 develPluginName = develPluginName[:-3] |
333 develPluginName = develPluginName[:-3] |
333 |
334 |