X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fbindings%2Fpython%2Fbt2%2Fbt2%2Fcomponent.py;h=b8026cc28aa67527424d67e0a1c2ad7b007c6c4d;hb=d24d56638469189904fb6ddbb3c725817b3e9417;hp=b2edd34e49e4515a63a7d234e75671ff01fce4dd;hpb=9cf25bf277fee373465b13e2f4f11cc62cff0bd3;p=babeltrace.git diff --git a/src/bindings/python/bt2/bt2/component.py b/src/bindings/python/bt2/bt2/component.py index b2edd34e..b8026cc2 100644 --- a/src/bindings/python/bt2/bt2/component.py +++ b/src/bindings/python/bt2/bt2/component.py @@ -95,17 +95,6 @@ class _GenericSinkComponentClass(_GenericComponentClass): _as_component_class_ptr = staticmethod(native_bt.component_class_sink_as_component_class) -def _handle_component_status(status, gen_error_msg): - if status == native_bt.SELF_COMPONENT_STATUS_END: - raise bt2.Stop - elif status == native_bt.SELF_COMPONENT_STATUS_AGAIN: - raise bt2.TryAgain - elif status == native_bt.SELF_COMPONENT_STATUS_REFUSE_PORT_CONNECTION: - raise bt2.PortConnectionRefused - elif status < 0: - raise bt2.Error(gen_error_msg) - - class _PortIterator(collections.abc.Iterator): def __init__(self, comp_ports): self._comp_ports = comp_ports @@ -447,13 +436,13 @@ class _UserComponentType(type): if _UserSourceComponent in bases: _UserComponentType._set_iterator_class(cls, iter_cls) - cc_ptr = native_bt.py3_component_class_source_create(cls, + cc_ptr = native_bt.bt2_component_class_source_create(cls, comp_cls_name, comp_cls_descr, comp_cls_help) elif _UserFilterComponent in bases: _UserComponentType._set_iterator_class(cls, iter_cls) - cc_ptr = native_bt.py3_component_class_filter_create(cls, + cc_ptr = native_bt.bt2_component_class_filter_create(cls, comp_cls_name, comp_cls_descr, comp_cls_help) @@ -461,7 +450,7 @@ class _UserComponentType(type): if not hasattr(cls, '_consume'): raise bt2.IncompleteUserClass("cannot create component class '{}': missing a _consume() method".format(class_name)) - cc_ptr = native_bt.py3_component_class_sink_create(cls, + cc_ptr = native_bt.bt2_component_class_sink_create(cls, comp_cls_name, comp_cls_descr, comp_cls_help) @@ -602,27 +591,6 @@ class _UserComponent(metaclass=_UserComponentType): def _finalize(self): pass - def _accept_port_connection(self, port, other_port): - return True - - def _accept_port_connection_from_native(self, self_port_ptr, self_port_type, other_port_ptr): - port = bt2.port._create_self_from_ptr_and_get_ref( - self_port_ptr, self_port_type) - - if self_port_type == native_bt.PORT_TYPE_OUTPUT: - other_port_type = native_bt.PORT_TYPE_INPUT - else: - other_port_type = native_bt.PORT_TYPE_OUTPUT - - other_port = bt2.port._create_from_ptr_and_get_ref( - other_port_ptr, other_port_type) - res = self._accept_port_connection(port, other_port_ptr) - - if type(res) is not bool: - raise TypeError("'{}' is not a 'bool' object") - - return res - def _port_connected(self, port, other_port): pass @@ -717,8 +685,8 @@ class _UserSourceComponent(_UserComponent, _SourceComponent): utils._check_str(name) fn = native_bt.self_component_source_add_output_port comp_status, self_port_ptr = fn(self._ptr, name, user_data) - _handle_component_status(comp_status, - 'cannot add output port to source component object') + utils._handle_func_status(comp_status, + 'cannot add output port to source component object') assert self_port_ptr is not None return bt2.port._UserComponentOutputPort._create_from_ptr(self_port_ptr) @@ -755,8 +723,8 @@ class _UserFilterComponent(_UserComponent, _FilterComponent): utils._check_str(name) fn = native_bt.self_component_filter_add_output_port comp_status, self_port_ptr = fn(self._ptr, name, user_data) - _handle_component_status(comp_status, - 'cannot add output port to filter component object') + utils._handle_func_status(comp_status, + 'cannot add output port to filter component object') assert self_port_ptr return bt2.port._UserComponentOutputPort._create_from_ptr(self_port_ptr) @@ -764,8 +732,8 @@ class _UserFilterComponent(_UserComponent, _FilterComponent): utils._check_str(name) fn = native_bt.self_component_filter_add_input_port comp_status, self_port_ptr = fn(self._ptr, name, user_data) - _handle_component_status(comp_status, - 'cannot add input port to filter component object') + utils._handle_func_status(comp_status, + 'cannot add input port to filter component object') assert self_port_ptr return bt2.port._UserComponentInputPort._create_from_ptr(self_port_ptr) @@ -790,7 +758,7 @@ class _UserSinkComponent(_UserComponent, _SinkComponent): utils._check_str(name) fn = native_bt.self_component_sink_add_input_port comp_status, self_port_ptr = fn(self._ptr, name, user_data) - _handle_component_status(comp_status, - 'cannot add input port to sink component object') + utils._handle_func_status(comp_status, + 'cannot add input port to sink component object') assert self_port_ptr return bt2.port._UserComponentInputPort._create_from_ptr(self_port_ptr)