159 if SSL_AVAILABLE: |
159 if SSL_AVAILABLE: |
160 self.__sslErrorHandler = E5SslErrorHandler(self) |
160 self.__sslErrorHandler = E5SslErrorHandler(self) |
161 self.__networkManager.sslErrors.connect(self.__sslErrors) |
161 self.__networkManager.sslErrors.connect(self.__sslErrors) |
162 self.__replies = [] |
162 self.__replies = [] |
163 |
163 |
164 try: |
164 with contextlib.suppress(AttributeError): |
165 self.__ui.onlineStateChanged.connect(self.__onlineStateChanged) |
165 self.__ui.onlineStateChanged.connect(self.__onlineStateChanged) |
166 except AttributeError: |
|
167 # it was not called from eric |
|
168 pass |
|
169 |
166 |
170 def finalizeSetup(self): |
167 def finalizeSetup(self): |
171 """ |
168 """ |
172 Public method to finalize the setup of the plugin manager. |
169 Public method to finalize the setup of the plugin manager. |
173 """ |
170 """ |
427 module.eric6PluginModuleFilename = fname |
424 module.eric6PluginModuleFilename = fname |
428 self.__modulesCount += 1 |
425 self.__modulesCount += 1 |
429 if reload_: |
426 if reload_: |
430 importlib.reload(module) |
427 importlib.reload(module) |
431 self.initOnDemandPlugin(name) |
428 self.initOnDemandPlugin(name) |
432 try: |
429 with contextlib.suppress(KeyError, AttributeError): |
433 pluginObject = self.__onDemandInactivePlugins[name] |
430 pluginObject = self.__onDemandInactivePlugins[name] |
434 pluginObject.initToolbar( |
431 pluginObject.initToolbar( |
435 self.__ui, e5App().getObject("ToolbarManager")) |
432 self.__ui, e5App().getObject("ToolbarManager")) |
436 except (KeyError, AttributeError): |
|
437 pass |
|
438 except PluginLoadError: |
433 except PluginLoadError: |
439 print("Error loading plug-in module:", name) |
434 print("Error loading plug-in module:", name) |
440 except Exception as err: |
435 except Exception as err: |
441 module = types.ModuleType(name) |
436 module = types.ModuleType(name) |
442 module.error = self.tr( |
437 module.error = self.tr( |
458 |
453 |
459 if name in self.__activeModules: |
454 if name in self.__activeModules: |
460 self.deactivatePlugin(name) |
455 self.deactivatePlugin(name) |
461 |
456 |
462 if name in self.__inactiveModules: |
457 if name in self.__inactiveModules: |
463 try: |
458 with contextlib.suppress(KeyError): |
464 pluginObject = self.__inactivePlugins[name] |
459 pluginObject = self.__inactivePlugins[name] |
465 try: |
460 with contextlib.suppress(AttributeError): |
466 pluginObject.prepareUnload() |
461 pluginObject.prepareUnload() |
467 except AttributeError: |
|
468 pass |
|
469 del self.__inactivePlugins[name] |
462 del self.__inactivePlugins[name] |
470 except KeyError: |
|
471 pass |
|
472 del self.__inactiveModules[name] |
463 del self.__inactiveModules[name] |
473 elif name in self.__onDemandInactiveModules: |
464 elif name in self.__onDemandInactiveModules: |
474 try: |
465 with contextlib.suppress(KeyError): |
475 pluginObject = self.__onDemandInactivePlugins[name] |
466 pluginObject = self.__onDemandInactivePlugins[name] |
476 try: |
467 with contextlib.suppress(AttributeError): |
477 pluginObject.prepareUnload() |
468 pluginObject.prepareUnload() |
478 except AttributeError: |
|
479 pass |
|
480 del self.__onDemandInactivePlugins[name] |
469 del self.__onDemandInactivePlugins[name] |
481 except KeyError: |
|
482 pass |
|
483 del self.__onDemandInactiveModules[name] |
470 del self.__onDemandInactiveModules[name] |
484 elif name in self.__failedModules: |
471 elif name in self.__failedModules: |
485 del self.__failedModules[name] |
472 del self.__failedModules[name] |
486 |
473 |
487 self.__modulesCount -= 1 |
474 self.__modulesCount -= 1 |
560 @param toolbarManager reference to the toolbar manager object |
547 @param toolbarManager reference to the toolbar manager object |
561 (E5ToolBarManager) |
548 (E5ToolBarManager) |
562 """ |
549 """ |
563 self.initOnDemandPlugins() |
550 self.initOnDemandPlugins() |
564 for pluginObject in self.__onDemandInactivePlugins.values(): |
551 for pluginObject in self.__onDemandInactivePlugins.values(): |
565 try: |
552 with contextlib.suppress(AttributeError): |
566 pluginObject.initToolbar(self.__ui, toolbarManager) |
553 pluginObject.initToolbar(self.__ui, toolbarManager) |
567 except AttributeError: |
|
568 # ignore it |
|
569 pass |
|
570 |
554 |
571 def activatePlugins(self): |
555 def activatePlugins(self): |
572 """ |
556 """ |
573 Public method to activate all plugins having the "autoactivate" |
557 Public method to activate all plugins having the "autoactivate" |
574 attribute set to True. |
558 attribute set to True. |