server: use lambda functions with _invoke_method
Use lambda functions with _invoke_method to avoid method name lookup
and enable additional state.
Change-Id: If0b702c4d890d0173883f7b144c2ca8dc9d590ee
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Resolves: openbmc/phosphor-objmgr#14
diff --git a/obmc/mapper/server.py b/obmc/mapper/server.py
index d4d4a33..1575526 100644
--- a/obmc/mapper/server.py
+++ b/obmc/mapper/server.py
@@ -54,15 +54,14 @@
raise
@staticmethod
- def _invoke_method(path, iface, method, *args):
+ def _invoke_method(path, iface, method):
obj = _FindInterfaces._get_object(path)
if not obj:
return None
iface = dbus.Interface(obj, iface)
try:
- f = getattr(iface, method)
- return f(*args)
+ return method(iface)
except dbus.exceptions.DBusException, e:
if e.get_dbus_name() in [
obmc.dbuslib.enums.DBUS_UNKNOWN_SERVICE,
@@ -78,14 +77,14 @@
return _FindInterfaces._invoke_method(
path,
dbus.INTROSPECTABLE_IFACE,
- 'Introspect')
+ lambda x: x.Introspect())
@staticmethod
def _get_managed_objects(om):
return _FindInterfaces._invoke_method(
om,
dbus.BUS_DAEMON_IFACE + '.ObjectManager',
- 'GetManagedObjects')
+ lambda x: x.GetManagedObjects())
@staticmethod
def _to_path(elements):