def add(self, has_to_pass, functor, arguments, origin=None): """Add a function to the list of things to poll/evaluate These functions shall either poll, evaluate or both: - poll data and store it in the dictionary or anywhere else where it can be accessed later. Use a unique key into the dictorionary :py:data:`buffers`. - evaluate some previously polled data or whichever system condition and raise an exception to indicate what happened (from the set :exc:`tcfl.tc.pass_e`, :py:exc:`tcfl.tc.blocked_e`, :py:exc:`tcfl.tc.error_e`, :py:exc:`tcfl.tc.failed_e`, :py:exc:`tcfl.tc.skip_e`). Eval functions can check their own timeouts and raise an exception to signal it (normally :py:exc:`tcfl.tc.error_e`) It is also possible that nothing of the interest of this evaluation function happened and thus it will evaluate nothing. :param bool has_to_pass: In order to consider the whole expect sequence a pass, this functor has to declare its evaluation passes by returning anything but `None` or by raising :py:exc:`tcfl.tc.pass_e`. :raises: to stop the :py:meth:`run` loop, raise :py:exc:`tcfl.tc.pass_e`, :py:exc:`tcfl.tc.blocked_e`, :py:exc:`tcfl.tc.error_e` or :py:exc:`tcfl.tc.skip_e`. :returns: ignored """ if not origin: origin = tcfl.origin_get(1) setattr(functor, "origin", origin) if not (functor, arguments, has_to_pass) in self.functors: self.functors.append((functor, arguments, has_to_pass)) if has_to_pass: self.have_to_pass += 1 return True else: return False
def add(self, has_to_pass, functor, arguments, origin = None): """Add a function to the list of things to poll/evaluate These functions shall either poll, evaluate or both: - poll data and store it in the dictionary or anywhere else where it can be accessed later. Use a unique key into the dictorionary :py:data:`buffers`. - evaluate some previously polled data or whichever system condition and raise an exception to indicate what happened (from the set :exc:`tcfl.tc.pass_e`, :py:exc:`tcfl.tc.blocked_e`, :py:exc:`tcfl.tc.error_e`, :py:exc:`tcfl.tc.failed_e`, :py:exc:`tcfl.tc.skip_e`). Eval functions can check their own timeouts and raise an exception to signal it (normally :py:exc:`tcfl.tc.error_e`) It is also possible that nothing of the interest of this evaluation function happened and thus it will evaluate nothing. :param bool has_to_pass: In order to consider the whole expect sequence a pass, this functor has to declare its evaluation passes by returning anything but `None` or by raising :py:exc:`tcfl.tc.pass_e`. :raises: to stop the :py:meth:`run` loop, raise :py:exc:`tcfl.tc.pass_e`, :py:exc:`tcfl.tc.blocked_e`, :py:exc:`tcfl.tc.error_e` or :py:exc:`tcfl.tc.skip_e`. :returns: ignored """ if not origin: origin = tcfl.origin_get(1) setattr(functor, "origin", origin) if not (functor, arguments, has_to_pass) in self.functors: self.functors.append((functor, arguments, has_to_pass)) if has_to_pass: self.have_to_pass += 1 return True else: return False