PluginManager/PluginManager.py

branch
maintenance
changeset 6646
51eefa621de4
parent 6645
ad476851d7e0
equal deleted inserted replaced
6603:77189681b787 6646:51eefa621de4
1 # -*- coding: utf-8 -*- 1 # -*- coding: utf-8 -*-
2 2
3 # Copyright (c) 2007 - 2018 Detlev Offenbach <detlev@die-offenbachs.de> 3 # Copyright (c) 2007 - 2019 Detlev Offenbach <detlev@die-offenbachs.de>
4 # 4 #
5 5
6 """ 6 """
7 Module implementing the Plugin Manager. 7 Module implementing the Plugin Manager.
8 """ 8 """
34 PluginLoadError, PluginActivationError, PluginModuleFormatError, \ 34 PluginLoadError, PluginActivationError, PluginModuleFormatError, \
35 PluginClassFormatError, PluginPy2IncompatibleError 35 PluginClassFormatError, PluginPy2IncompatibleError
36 36
37 import UI.PixmapCache 37 import UI.PixmapCache
38 38
39 import Globals
39 import Utilities 40 import Utilities
40 import Preferences 41 import Preferences
41 42
42 from eric6config import getConfig 43 from eric6config import getConfig
43 44
334 self.loadPlugin(pluginName, self.pluginDirs["eric6"]) 335 self.loadPlugin(pluginName, self.pluginDirs["eric6"])
335 336
336 if develPluginName: 337 if develPluginName:
337 self.loadPlugin(develPluginName, develPluginPath) 338 self.loadPlugin(develPluginName, develPluginPath)
338 self.__develPluginName = develPluginName 339 self.__develPluginName = develPluginName
340
341 def loadDocumentationSetPlugins(self):
342 """
343 Public method to load just the documentation sets plugins.
344
345 @exception PluginModulesError raised to indicate the absence of
346 plug-in modules
347 """
348 if not self.__pluginModulesExist():
349 raise PluginModulesError
350
351 self.__insertPluginsPaths()
352
353 for pluginName in self.__foundGlobalModules:
354 # user and core plug-ins have priority
355 if pluginName not in self.__foundUserModules and \
356 pluginName not in self.__foundCoreModules and \
357 pluginName.startswith("PluginDocumentationSets"):
358 self.loadPlugin(pluginName, self.pluginDirs["global"])
359
360 for pluginName in self.__foundUserModules:
361 # core plug-ins have priority
362 if pluginName not in self.__foundCoreModules and \
363 pluginName.startswith("PluginDocumentationSets"):
364 self.loadPlugin(pluginName, self.pluginDirs["user"])
365
366 for pluginName in self.__foundCoreModules:
367 # plug-in under development has priority
368 if pluginName.startswith("PluginDocumentationSets"):
369 self.loadPlugin(pluginName, self.pluginDirs["eric6"])
339 370
340 def loadPlugin(self, name, directory, reload_=False): 371 def loadPlugin(self, name, directory, reload_=False):
341 """ 372 """
342 Public method to load a plugin module. 373 Public method to load a plugin module.
343 374
1301 if pluginDetails is None: 1332 if pluginDetails is None:
1302 if not Preferences.getPluginManager("CheckInstalledOnly"): 1333 if not Preferences.getPluginManager("CheckInstalledOnly"):
1303 self.__updateAvailable = True 1334 self.__updateAvailable = True
1304 return 1335 return
1305 1336
1306 if version.count(".") >= 3: 1337 versionTuple = Globals.versionToTuple(version)[:3]
1307 # cope for extended version numbers by ignoring 1338 pluginVersionTuple = Globals.versionToTuple(
1308 # the extension 1339 pluginDetails["version"])[:3]
1309 checkVersion = ".".join(version.split(".", 3)[:3]) 1340
1310 else: 1341 if pluginVersionTuple < versionTuple:
1311 checkVersion = version
1312 if pluginDetails["version"] < checkVersion:
1313 self.__updateAvailable = True 1342 self.__updateAvailable = True
1314 return 1343 return
1315 1344
1316 if not Preferences.getPluginManager("CheckInstalledOnly"): 1345 if not Preferences.getPluginManager("CheckInstalledOnly"):
1317 # Check against downloaded plugin archives 1346 # Check against downloaded plugin archives
1318 # 1. Check, if the archive file exists 1347 # 1. Check, if the archive file exists
1319 if not os.path.exists(archive): 1348 if not os.path.exists(archive):
1320 self.__updateAvailable = True 1349 if pluginDetails["moduleName"] != pluginName:
1350 self.__updateAvailable = True
1321 return 1351 return
1322 1352
1323 # 2. Check, if the archive is a valid zip file 1353 # 2. Check, if the archive is a valid zip file
1324 if not zipfile.is_zipfile(archive): 1354 if not zipfile.is_zipfile(archive):
1325 self.__updateAvailable = True 1355 self.__updateAvailable = True
1328 # 3. Check the version of the archive file 1358 # 3. Check the version of the archive file
1329 zipFile = zipfile.ZipFile(archive, "r") 1359 zipFile = zipfile.ZipFile(archive, "r")
1330 try: 1360 try:
1331 aversion = zipFile.read("VERSION").decode("utf-8") 1361 aversion = zipFile.read("VERSION").decode("utf-8")
1332 except KeyError: 1362 except KeyError:
1333 aversion = "" 1363 aversion = "0.0.0"
1334 zipFile.close() 1364 zipFile.close()
1335 1365
1336 if aversion != version: 1366 aversionTuple = Globals.versionToTuple(aversion)[:3]
1367 if aversionTuple != versionTuple:
1337 self.__updateAvailable = True 1368 self.__updateAvailable = True
1338 1369
1339 def __sslErrors(self, reply, errors): 1370 def __sslErrors(self, reply, errors):
1340 """ 1371 """
1341 Private slot to handle SSL errors. 1372 Private slot to handle SSL errors.

eric ide

mercurial