diff options
| author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2016-07-25 12:36:42 -0400 |
|---|---|---|
| committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2016-07-25 12:36:42 -0400 |
| commit | 9df742072de4ead29e821914427956acc2ff5618 (patch) | |
| tree | a860e8f5010c9da830aa2e5bc501eb41f52f688f /obmc/dbuslib | |
| parent | 3a6dcc142105d9a187d5fb44771aee59aa166a89 (diff) | |
| download | pyphosphor-9df742072de4ead29e821914427956acc2ff5618.tar.gz pyphosphor-9df742072de4ead29e821914427956acc2ff5618.zip | |
Remove find_dbus_interfaces
Waffling yet again on where this should be located. Move back
to the mapper to discourage other applications from introspection
and encourage use of the mapper.
Change-Id: I78dc815baeb46d6b2d155d02318fba230d7420d2
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'obmc/dbuslib')
| -rw-r--r-- | obmc/dbuslib/introspection.py | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/obmc/dbuslib/introspection.py b/obmc/dbuslib/introspection.py index 805197d..9ec9c05 100644 --- a/obmc/dbuslib/introspection.py +++ b/obmc/dbuslib/introspection.py @@ -16,7 +16,6 @@ import xml.etree.ElementTree as ET import dbus -import obmc.dbuslib.enums class IntrospectionNodeParser: @@ -135,105 +134,3 @@ class IntrospectionParser: items.update(callback(path + k, parser)) return items - - -def find_dbus_interfaces(conn, service, path, match): - class _FindInterfaces(object): - def __init__(self): - self.results = {} - - @staticmethod - def _get_object(path): - try: - return conn.get_object(service, path, introspect=False) - except dbus.exceptions.DBusException, e: - if e.get_dbus_name() in [ - obmc.dbuslib.enums.DBUS_UNKNOWN_SERVICE, - obmc.dbuslib.enums.DBUS_NO_REPLY]: - print "Warning: Introspection failure: " \ - "service `%s` is not running" % (service) - return None - raise - - @staticmethod - def _invoke_method(path, iface, method, *args): - obj = _FindInterfaces._get_object(path) - if not obj: - return None - - iface = dbus.Interface(obj, iface) - try: - f = getattr(iface, method) - return f(*args) - except dbus.exceptions.DBusException, e: - if e.get_dbus_name() in [ - obmc.dbuslib.enums.DBUS_UNKNOWN_SERVICE, - obmc.dbuslib.enums.DBUS_NO_REPLY]: - print "Warning: Introspection failure: " \ - "service `%s` did not reply to "\ - "method call on %s" % (service, path) - return None - raise - - @staticmethod - def _introspect(path): - return _FindInterfaces._invoke_method( - path, - dbus.INTROSPECTABLE_IFACE, - 'Introspect') - - @staticmethod - def _get_managed_objects(om): - return _FindInterfaces._invoke_method( - om, - dbus.BUS_DAEMON_IFACE + '.ObjectManager', - 'GetManagedObjects') - - @staticmethod - def _to_path(elements): - return '/' + '/'.join(elements) - - @staticmethod - def _to_path_elements(path): - return filter(bool, path.split('/')) - - def __call__(self, path): - self.results = {} - self._find_interfaces(path) - return self.results - - @staticmethod - def _match(iface): - return iface == dbus.BUS_DAEMON_IFACE + '.ObjectManager' \ - or match(iface) - - def _find_interfaces(self, path): - path_elements = self._to_path_elements(path) - path = self._to_path(path_elements) - data = self._introspect(path) - if data is None: - return - - root = ET.fromstring(data) - ifaces = filter( - self._match, - [x.attrib.get('name') for x in root.findall('interface')]) - self.results[path] = ifaces - - if dbus.BUS_DAEMON_IFACE + '.ObjectManager' in ifaces: - objs = self._get_managed_objects(path) - for k, v in objs.iteritems(): - self.results[k] = v - else: - children = filter( - bool, - [x.attrib.get('name') for x in root.findall('node')]) - children = [ - self._to_path( - path_elements + self._to_path_elements(x)) - for x in sorted(children)] - for child in children: - if child not in self.results: - self._find_interfaces(child) - - return _FindInterfaces()(path) |

