diff options
Diffstat (limited to 'gi/overrides/Gio.py')
-rw-r--r-- | gi/overrides/Gio.py | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/gi/overrides/Gio.py b/gi/overrides/Gio.py index 20343a2..20adf0c 100644 --- a/gi/overrides/Gio.py +++ b/gi/overrides/Gio.py @@ -23,6 +23,8 @@ from ..importer import modules from gi.repository import GLib +import sys + Gio = modules['Gio']._introspection_module __all__ = [] @@ -109,7 +111,8 @@ class _DBusProxyMethodCall: (result_callback, error_callback, real_user_data) = user_data try: ret = obj.call_finish(result) - except Exception as e: + except Exception: + etype, e = sys.exc_info()[:2] # return exception as value if error_callback: error_callback(obj, e, real_user_data) @@ -119,7 +122,17 @@ class _DBusProxyMethodCall: result_callback(obj, self._unpack_result(ret), real_user_data) - def __call__(self, signature, *args, **kwargs): + def __call__(self, *args, **kwargs): + # the first positional argument is the signature, unless we are calling + # a method without arguments; then signature is implied to be '()'. + if args: + signature = args[0] + args = args[1:] + if not isinstance(signature, str): + raise TypeError('first argument must be the method signature string: %r' % signature) + else: + signature = '()' + arg_variant = GLib.Variant(signature, tuple(args)) if 'result_handler' in kwargs: @@ -163,6 +176,10 @@ class DBusProxy(Gio.DBusProxy): proxy = Gio.DBusProxy.new_sync(...) result = proxy.MyMethod('(is)', 42, 'hello') + The exception are methods which take no arguments, like + proxy.MyMethod('()'). For these you can omit the signature and just write + proxy.MyMethod(). + Optional keyword arguments: - timeout: timeout for the call in milliseconds (default to D-Bus timeout) |