29 except ImportError: |
29 except ImportError: |
30 SSL_AVAILABLE = False |
30 SSL_AVAILABLE = False |
31 |
31 |
32 from .PluginExceptions import PluginPathError, PluginModulesError, \ |
32 from .PluginExceptions import PluginPathError, PluginModulesError, \ |
33 PluginLoadError, PluginActivationError, PluginModuleFormatError, \ |
33 PluginLoadError, PluginActivationError, PluginModuleFormatError, \ |
34 PluginClassFormatError |
34 PluginClassFormatError, PluginPy2IncompatibleError |
35 |
35 |
36 import UI.PixmapCache |
36 import UI.PixmapCache |
37 |
37 |
38 import Utilities |
38 import Utilities |
39 import Preferences |
39 import Preferences |
340 if not hasattr(module, "autoactivate"): |
340 if not hasattr(module, "autoactivate"): |
341 module.error = self.tr( |
341 module.error = self.tr( |
342 "Module is missing the 'autoactivate' attribute.") |
342 "Module is missing the 'autoactivate' attribute.") |
343 self.__failedModules[name] = module |
343 self.__failedModules[name] = module |
344 raise PluginLoadError(name) |
344 raise PluginLoadError(name) |
|
345 if sys.version_info[0] < 3: |
|
346 if not hasattr(module, "python2Compatible"): |
|
347 module.error = self.tr( |
|
348 "Module is missing the Python2 compatibility flag." |
|
349 " Please update.") |
|
350 compatible = False |
|
351 elif getattr(module, "python2Compatible"): |
|
352 module.error = self.tr( |
|
353 "Module is not Python2 compatible.") |
|
354 compatible = False |
|
355 else: |
|
356 compatible = True |
|
357 if not compatible: |
|
358 self.__failedModules[name] = module |
|
359 raise PluginPy2IncompatibleError(name) |
345 if getattr(module, "autoactivate"): |
360 if getattr(module, "autoactivate"): |
346 self.__inactiveModules[name] = module |
361 self.__inactiveModules[name] = module |
347 else: |
362 else: |
348 if not hasattr(module, "pluginType") or \ |
363 if not hasattr(module, "pluginType") or \ |
349 not hasattr(module, "pluginTypename"): |
364 not hasattr(module, "pluginTypename"): |
358 module.eric5PluginModuleFilename = fname |
373 module.eric5PluginModuleFilename = fname |
359 self.__modulesCount += 1 |
374 self.__modulesCount += 1 |
360 if reload_: |
375 if reload_: |
361 imp.reload(module) |
376 imp.reload(module) |
362 except PluginLoadError: |
377 except PluginLoadError: |
363 print("Error loading plugin module:", name) |
378 print("Error loading plug-in module:", name) |
|
379 except PluginPy2IncompatibleError: |
|
380 print("Error loading plug-in module:", name) |
|
381 print("Th plug-in is not Python2 compatible.") |
364 except Exception as err: |
382 except Exception as err: |
365 module = imp.new_module(name) |
383 module = imp.new_module(name) |
366 module.error = self.tr( |
384 module.error = self.tr( |
367 "Module failed to load. Error: {0}").format(str(err)) |
385 "Module failed to load. Error: {0}").format(str(err)) |
368 self.__failedModules[name] = module |
386 self.__failedModules[name] = module |
369 print("Error loading plugin module:", name) |
387 print("Error loading plug-in module:", name) |
370 print(str(err)) |
388 print(str(err)) |
371 |
389 |
372 def unloadPlugin(self, name): |
390 def unloadPlugin(self, name): |
373 """ |
391 """ |
374 Public method to unload a plugin module. |
392 Public method to unload a plugin module. |