Пример #1
0
 def update_activation_configuration(
         self,
         new_config,
         deactivate_other_evaluators,
         add_missing_elements,
         tentacles_path=constants.TENTACLES_PATH):
     something_changed = False
     loaders.ensure_tentacles_metadata(tentacles_path)
     for element_name, activated in new_config.items():
         try:
             element_type = loaders.get_tentacle_classes(
             )[element_name].tentacle_root_type
             if element_name in self.tentacles_activation[element_type]:
                 current_activation = self.tentacles_activation[
                     element_type][element_name]
                 if current_activation != activated:
                     self.logger.info(
                         f"Tentacles configuration updated: {element_name} "
                         f"{'activated' if activated else 'deactivated'}")
                     self.tentacles_activation[element_type][
                         element_name] = activated
                     something_changed = True
             elif add_missing_elements:
                 self.tentacles_activation[element_type][
                     element_name] = activated
                 something_changed = True
         except KeyError:
             # tentacle missing in loaded metadata: can't be used
             self.logger.error(
                 f"Impossible to change activation of {element_name}: this Tentacle class is not "
                 f"in loaded tentacles metadata dict.")
     if deactivate_other_evaluators:
         something_changed = self._deactivate_other_evaluators(
             new_config) or something_changed
     return something_changed
Пример #2
0
 def is_tentacle_activated(self,
                           tentacle_class_name,
                           tentacles_path=constants.TENTACLES_PATH):
     loaders.ensure_tentacles_metadata(tentacles_path)
     tentacle_type = loaders.get_tentacle_classes(
     )[tentacle_class_name].tentacle_root_type
     return self.tentacles_activation[tentacle_type][tentacle_class_name]
Пример #3
0
 def read_config(self, tentacles_path=constants.TENTACLES_PATH):
     try:
         self._from_dict(configuration.read_config(self.config_path))
     except Exception as e:
         self.logger.error(f"Error when reading tentacles global configuration file ({e}), "
                           "resetting this file with default values. This will not change "
                           "any specific tentacle configuration.")
         loaders.ensure_tentacles_metadata(tentacles_path)
         self._update_tentacles_setup_config(loaders.get_tentacle_classes().values())
         self.save_config()
Пример #4
0
 def from_activated_tentacles_classes(self, *tentacles_classes, tentacles_path=constants.TENTACLES_PATH):
     loaders.ensure_tentacles_metadata(tentacles_path)
     tentacle_by_class_name = loaders.get_tentacle_classes()
     for tentacle_class in tentacles_classes:
         tentacle_name = tentacle_class.get_name()
         tentacle = tentacle_by_class_name[tentacle_name]
         try:
             self.tentacles_activation[tentacle.tentacle_root_type][tentacle_name] = True
         except KeyError:
             self.tentacles_activation[tentacle.tentacle_root_type] = {tentacle_name: True}