X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fbindings%2Fpython%2Fbt2%2Fbt2%2Fplugin.py;h=620bd76ad4156a27e9335433dacdd7ddb7721f67;hb=85906b6b4c37140f8bdd4a6861ecbc82fc62f816;hp=2d0d8b057303afa44d1e8cb0a832ac429c4b11c3;hpb=578e048b5debf169e286e5b5cc747b5d6c16886d;p=babeltrace.git diff --git a/src/bindings/python/bt2/bt2/plugin.py b/src/bindings/python/bt2/bt2/plugin.py index 2d0d8b05..620bd76a 100644 --- a/src/bindings/python/bt2/bt2/plugin.py +++ b/src/bindings/python/bt2/bt2/plugin.py @@ -27,29 +27,37 @@ import os.path import bt2 -def find_plugins(path, recurse=True): +def find_plugins(path, recurse=True, fail_on_load_error=False): utils._check_str(path) utils._check_bool(recurse) + utils._check_bool(fail_on_load_error) plugin_set_ptr = None if os.path.isfile(path): - plugin_set_ptr = native_bt.plugin_find_all_from_file(path) + status, plugin_set_ptr = native_bt.bt2_plugin_find_all_from_file(path, fail_on_load_error) elif os.path.isdir(path): - plugin_set_ptr = native_bt.plugin_find_all_from_dir(path, int(recurse)) + status, plugin_set_ptr = native_bt.bt2_plugin_find_all_from_dir(path, int(recurse), int(fail_on_load_error)) + else: + raise bt2.Error("invalid path: '{}'".format(path)) - if plugin_set_ptr is None: + if status == native_bt.__BT_FUNC_STATUS_NOT_FOUND: return + utils._handle_func_status(status, 'failed to find plugins') + assert plugin_set_ptr is not None return _PluginSet._create_from_ptr(plugin_set_ptr) -def find_plugin(name): +def find_plugin(name, fail_on_load_error=False): utils._check_str(name) - ptr = native_bt.plugin_find(name) + utils._check_bool(fail_on_load_error) + status, ptr = native_bt.bt2_plugin_find(name, int(fail_on_load_error)) - if ptr is None: + if status == native_bt.__BT_FUNC_STATUS_NOT_FOUND: return + utils._handle_func_status(status, 'failed to find plugin') + assert ptr is not None return _Plugin._create_from_ptr(ptr) @@ -123,7 +131,7 @@ class _PluginComponentClassesIterator(collections.abc.Iterator): comp_cls_type = self._plugin_comp_cls._comp_cls_type comp_cls_pycls = bt2.component._COMP_CLS_TYPE_TO_GENERIC_COMP_CLS_PYCLS[comp_cls_type] - comp_cls_ptr = comp_cls_pycls._as_component_class_ptr(comp_cls_ptr) + comp_cls_ptr = comp_cls_pycls._bt_as_component_class_ptr(comp_cls_ptr) name = native_bt.component_class_get_name(comp_cls_ptr) assert name is not None return name @@ -198,7 +206,7 @@ class _Plugin(object._SharedObject): @property def version(self): - status, major, minor, patch, extra = native_bt.plugin_get_version_wrapper(self._ptr) + status, major, minor, patch, extra = native_bt.bt2_plugin_get_version(self._ptr) if status == native_bt.PROPERTY_AVAILABILITY_NOT_AVAILABLE: return