diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-07-12 08:36:13 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2017-07-12 08:36:14 +0900 |
commit | d3b61d1e80a91482c2fc844810627064b1087280 (patch) | |
tree | 31e43590946ac70b8a14429f488f1e4f01956293 /gi/overrides/Gio.py | |
parent | 385fb5df2f7c3ec197b954e8a8ddac5297fe4043 (diff) | |
download | pygobject2-d3b61d1e80a91482c2fc844810627064b1087280.tar.gz pygobject2-d3b61d1e80a91482c2fc844810627064b1087280.tar.bz2 pygobject2-d3b61d1e80a91482c2fc844810627064b1087280.zip |
Imported Upstream version 2.28.1
Change-Id: Ib2dc5ea9bbd21a07cf091b6a5352485ef15f637a
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
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) |