blob: ce28d9897dc691478ff67ebaab565f83e39b4571 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
import logging
def save_args(callable, *xargs, **xkwargs):
def __call(*args, **kwargs):
kw = dict()
kw.update(kwargs)
kw.update(xkwargs)
return callable(*(xargs+args), **kw)
return __call
def ignore(*args):
logging.debug("Unhandled asynchronous dbus call response with arguments: %s", str(args))
def logError(error):
logging.error("Unhandled asynchronous dbus call error: %s", error)
def remote_call(callable, args, return_cb=None, error_cb=None, block=False):
reply_cb = return_cb or ignore
errhandler_cb = error_cb or logError
if block:
return reply_cb(callable(*args))
else:
callable(*args, reply_handler=reply_cb, error_handler=errhandler_cb)
|