Example #1
0
 def __collect_and_remove_plugins(
         self,
         filter: Callable[[RegularPlugin], bool],
         specific: Optional[RegularPlugin] = None) -> SingleOperationResult:
     result = SingleOperationResult()
     plugin_list = self.get_regular_plugins() if specific is None else [
         specific
     ]
     for plugin in plugin_list:
         if filter(plugin):
             result.record(plugin, self.__unload_plugin(plugin))
     return result
Example #2
0
 def __reload_ready_plugins(
         self,
         filter: Callable[[RegularPlugin], bool],
         specific: Optional[RegularPlugin] = None) -> SingleOperationResult:
     result = SingleOperationResult()
     plugin_list = self.get_regular_plugins() if specific is None else [
         specific
     ]
     for plugin in plugin_list:
         if plugin.in_states({PluginState.READY}) and filter(plugin):
             result.record(plugin, self.__reload_plugin(plugin))
     return result
Example #3
0
 def check_plugin_dependencies(self) -> SingleOperationResult:
     result = SingleOperationResult()
     walker = DependencyWalker(self)
     for item in walker.walk():
         plugin = self.plugins.get(item.plugin_id)  # should be not None
         result.record(plugin, item.success)
         if not item.success:
             self.logger.error(
                 self.mcdr_server.tr(
                     'plugin_manager.check_plugin_dependencies.item_failed',
                     plugin, item.reason))
             self.__unload_plugin(plugin)
     self.logger.debug(self.mcdr_server.tr(
         'plugin_manager.check_plugin_dependencies.topo_order'),
                       option=DebugOption.PLUGIN)
     for plugin in result.success_list:
         self.logger.debug('- {}'.format(plugin), option=DebugOption.PLUGIN)
     # the success list order matches the dependency topo order
     return result