Exemplo n.º 1
0
 def __init__(self, workflow, **kwargs):
     self.name = kwargs.get("name")
     self.view_group = kwargs.get("view_group")
     self._demanded = set()
     self._id = str(uuid.uuid4())
     self._links_from = {}
     self._links_to = {}
     super(Unit, self).__init__(**kwargs)
     validate_kwargs(self, **kwargs)
     self.verify_interface(IUnit)
     self._gate_block = Bool(False)
     self._gate_skip = Bool(False)
     self._ignores_gate = Bool(kwargs.get("ignore_gate", False))
     self._run_calls = 0
     self._remembers_gates = True
     timings = get(root.common.timings, None)
     if timings is not None and isinstance(timings, set):
         timings = self.__class__.__name__ in timings
     else:
         timings = False
     self._timings = kwargs.get("timings", timings)
     assert isinstance(self._timings, bool)
     self.workflow = workflow
     self.add_method_to_storage("initialize")
     self.add_method_to_storage("run")
     self.add_method_to_storage("stop")
     if hasattr(self, "generate_data_for_master"):
         self.add_method_to_storage("generate_data_for_master")
     if hasattr(self, "apply_data_from_master"):
         self.add_method_to_storage("apply_data_from_master")
     if hasattr(self, "generate_data_for_slave"):
         self.add_method_to_storage("generate_data_for_slave")
     if hasattr(self, "apply_data_from_slave"):
         self.add_method_to_storage("apply_data_from_slave")
Exemplo n.º 2
0
 def wrapped_check_attrs(*args, **kwargs):
     validate_kwargs(self, **kwargs)
     for attr in sorted(attrs):
         val = getattr(self, attr, None)
         if val is None:
             raise AttributeError("Attribute %s of unit %s is not "
                                  "linked" % (attr, repr(self)))
     return fn(*args, **kwargs)