RuntimeError:无法获取值

时间:2015-06-20 19:09:31

标签: python python-3.x

我在一个对象上调用inspect.getmembers,但我得到的是:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 2, in aligned_members
  File "/usr/lib/python3.4/inspect.py", line 289, in getmembers
    value = getattr(object, key)
RuntimeError: unable to get the value

我的代码是:

import gi
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst, Gtk

GObject.threads_init()
Gst.init(None)

elem = Gst.ElementFactory.make('playbin')
inspect.getmembers(elem)

这是来自gstreamer库的元素对象,dir显示:

['__class__', '__copy__', '__deepcopy__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__gdoc__', '__ge__', '__getattribute__', '__gpointer__', '__grefcount__', '__gsignals__', '__gt__', '__gtype__', '__hash__', '__info__', '__init__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_force_floating', '_gst_reserved', '_ref', '_ref_sink', '_unref', '_unsupported_data_method', '_unsupported_method', 'abort_state', 'add', 'add_control_binding', 'add_pad', 'auto_clock', 'base_time', 'bin', 'bind_property', 'bind_property_full', 'bus', 'chain', 'change_state', 'check_uniqueness', 'child_added', 'child_bus', 'child_removed', 'children', 'children_cookie', 'clock', 'clock_dirty', 'clock_provider', 'compat_control', 'connect', 'connect_after', 'connect_object', 'connect_object_after', 'continue_state', 'control_bindings', 'control_rate', 'create_all_pads', 'current_state', 'default_deep_notify', 'default_error', 'delay', 'disconnect', 'disconnect_by_func', 'do_add_element', 'do_change_state', 'do_deep_notify', 'do_do_latency', 'do_element_added', 'do_element_removed', 'do_get_state', 'do_handle_message', 'do_no_more_pads', 'do_pad_added', 'do_pad_removed', 'do_post_message', 'do_provide_clock', 'do_query', 'do_release_pad', 'do_remove_element', 'do_send_event', 'do_set_bus', 'do_set_clock', 'do_set_context', 'do_set_state', 'do_state_changed', 'element', 'emit', 'emit_stop_by_name', 'event_get_type', 'event_parse_command', 'event_parse_key_event', 'event_parse_mouse_button_event', 'event_parse_mouse_move_event', 'expose', 'find_unlinked_pad', 'fixed_clock', 'flags', 'force_floating', 'freeze_notify', 'g_type_instance', 'get_auto_flush_bus', 'get_balance_type', 'get_base_time', 'get_bus', 'get_by_interface', 'get_by_name', 'get_by_name_recurse_up', 'get_child_by_index', 'get_child_by_name', 'get_children_count', 'get_clock', 'get_compatible_pad', 'get_compatible_pad_template', 'get_control_binding', 'get_control_rate', 'get_data', 'get_delay', 'get_factory', 'get_g_value_array', 'get_name', 'get_parent', 'get_path_string', 'get_properties', 'get_property', 'get_qdata', 'get_request_pad', 'get_start_time', 'get_state', 'get_static_pad', 'get_value', 'get_value_array', 'got_window_handle', 'handle_events', 'handler_block', 'handler_block_by_func', 'handler_disconnect', 'handler_is_connected', 'handler_unblock', 'handler_unblock_by_func', 'has_active_control_bindings', 'has_ancestor', 'interface_find_property', 'interface_install_property', 'interface_list_properties', 'is_floating', 'is_locked_state', 'iterate_all_by_interface', 'iterate_elements', 'iterate_pads', 'iterate_recurse', 'iterate_sink_pads', 'iterate_sinks', 'iterate_sorted', 'iterate_sources', 'iterate_src_pads', 'last_return', 'last_sync', 'link', 'link_filtered', 'link_pads', 'link_pads_filtered', 'link_pads_full', 'lock', 'lookup', 'lost_state', 'make_from_uri', 'message_full', 'message_get_type', 'message_new_angles_changed', 'message_new_commands_changed', 'message_new_mouse_over', 'message_parse_angles_changed', 'message_parse_mouse_over', 'messages', 'name', 'new', 'next_state', 'no_more_pads', 'notify', 'notify_by_pspec', 'numchildren', 'numpads', 'numsinkpads', 'numsrcpads', 'object', 'pads', 'pads_cookie', 'parent', 'pending_state', 'polling', 'post_message', 'prepare_window_handle', 'priv', 'props', 'provide_clock', 'provided_clock', 'qdata', 'query', 'query_convert', 'query_duration', 'query_get_type', 'query_new_angles', 'query_new_commands', 'query_parse_angles', 'query_parse_commands_length', 'query_parse_commands_nth', 'query_position', 'query_set_angles', 'query_set_commandsv', 'recalculate_latency', 'ref', 'ref_count', 'ref_sink', 'register', 'release_request_pad', 'remove', 'remove_control_binding', 'remove_pad', 'replace', 'replace_data', 'replace_qdata', 'request_pad', 'run_dispose', 'seek', 'seek_simple', 'send_command', 'send_event', 'send_key_event', 'send_mouse_event', 'set_auto_flush_bus', 'set_base_time', 'set_bus', 'set_clock', 'set_context', 'set_control_binding_disabled', 'set_control_bindings_disabled', 'set_control_rate', 'set_data', 'set_delay', 'set_locked_state', 'set_name', 'set_parent', 'set_properties', 'set_property', 'set_render_rectangle', 'set_start_time', 'set_state', 'set_value', 'set_window_handle', 'sinkpads', 'srcpads', 'start_time', 'state_change_return_get_name', 'state_cond', 'state_cookie', 'state_dirty', 'state_get_name', 'state_lock', 'steal_data', 'steal_qdata', 'stop_emission', 'stop_emission_by_name', 'stream_time', 'suggest_next_sync', 'sync_state_with_parent', 'sync_values', 'target_state', 'thaw_notify', 'unlink', 'unlink_pads', 'unparent', 'unref', 'use_clock', 'value_changed', 'watch_closure', 'weak_ref'] 

问题是: 如何获取任何对象的信息(方法,注释..etc),因为有许多文档没有很好地记录,我想在运行时检查它们。是否有一个好的模块或方式&#39;这样做?

我正在使用Python 3

0 个答案:

没有答案