def on_method_call(self,
connection,
sender,
object_path,
interface_name,
method_name,
parameters,
invocation):
args = list(parameters.unpack())
for i, sig in enumerate(self.method_inargs[method_name]):
if sig is "h":
msg = invocation.get_message()
fd_list = msg.get_unix_fd_list()
args[i] = fd_list.get(args[i])
try:
result = getattr(self, method_name)(*args)
# out_args is atleast (signature1).
# We therefore always wrap the result as a tuple.
# Refer to https://bugzilla.gnome.org/show_bug.cgi?id=765603
result = (result,)
out_args = self.method_outargs[method_name]
if out_args != "()":
variant = GLib.Variant(out_args, result)
invocation.return_value(variant)
else:
invocation.return_value(None)
except:
pass
评论列表
文章目录