From e7d024784eb2fd4f561c6213d55faac9126792af Mon Sep 17 00:00:00 2001 From: Goffi Date: Wed, 13 Jan 2016 18:44:32 +0100 Subject: [PATCH] =?UTF-8?q?bridge=20(D-Bus):=20fixed=20handling=20of=20pro?= =?UTF-8?q?file=20in=20kwargs:=20=20=20=20=20kwargs=20are=20not=20handled?= =?UTF-8?q?=20by=20python=20D-Bus=20(i.e.=20they=20are=20not=20sent=20thro?= =?UTF-8?q?ugh=20D-Bus).=20The=20"profile"=20and=20"profile=5Fkey"=20kwarg?= =?UTF-8?q?s=20are=20often=20used=20through=20S=C3=A0T=20with=20the=20brid?= =?UTF-8?q?ge,=20this=20was=20working=20so=20far=20because=20they=20were?= =?UTF-8?q?=20used=20for=20core=20methods=20(which=20have=20a=20signature?= =?UTF-8?q?=20in=20DBus.py=20handling=20profile),=20or=20in=20Libervia=20b?= =?UTF-8?q?rowser=20who=20ignore=20profile=20argument.=20=20=20=20=20But?= =?UTF-8?q?=20if=20the=20profile=20or=20profile=5Fkey=20was=20used=20as=20?= =?UTF-8?q?a=20keyword=20for=20plugin=20method=20outside=20of=20Libervia?= =?UTF-8?q?=20browser,=20they=20were=20ignored,=20this=20commit=20fix=20th?= =?UTF-8?q?is=20by=20adding=20them=20to=20the=20args=20list.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontends/src/bridge/DBus.py | 12 +++++++++++- .../bridge_constructor/dbus_frontend_template.py | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/frontends/src/bridge/DBus.py b/frontends/src/bridge/DBus.py index f33077d9..ab9467ad 100644 --- a/frontends/src/bridge/DBus.py +++ b/frontends/src/bridge/DBus.py @@ -100,15 +100,25 @@ class DBusBridgeFrontend(BridgeFrontend): # - or if the last two arguments are callable async = False + args = list(args) if kwargs: if 'callback' in kwargs: async = True _callback = kwargs.pop('callback') _errback = kwargs.pop('errback', lambda failure: log.error(unicode(failure))) + try: + args.append(kwargs.pop('profile')) + except KeyError: + try: + args.append(kwargs.pop('profile_key')) + except KeyError: + pass + # at this point, kwargs should be empty + if kwargs: + log.warnings(u"unexpected keyword arguments, they will be ignored: {}".format(kwargs)) elif len(args) >= 2 and callable(args[-1]) and callable(args[-2]): async = True - args = list(args) _errback = args.pop() _callback = args.pop() diff --git a/src/bridge/bridge_constructor/dbus_frontend_template.py b/src/bridge/bridge_constructor/dbus_frontend_template.py index de3dfc1f..4567cd33 100644 --- a/src/bridge/bridge_constructor/dbus_frontend_template.py +++ b/src/bridge/bridge_constructor/dbus_frontend_template.py @@ -100,15 +100,25 @@ class DBusBridgeFrontend(BridgeFrontend): # - or if the last two arguments are callable async = False + args = list(args) if kwargs: if 'callback' in kwargs: async = True _callback = kwargs.pop('callback') _errback = kwargs.pop('errback', lambda failure: log.error(unicode(failure))) + try: + args.append(kwargs.pop('profile')) + except KeyError: + try: + args.append(kwargs.pop('profile_key')) + except KeyError: + pass + # at this point, kwargs should be empty + if kwargs: + log.warnings(u"unexpected keyword arguments, they will be ignored: {}".format(kwargs)) elif len(args) >= 2 and callable(args[-1]) and callable(args[-2]): async = True - args = list(args) _errback = args.pop() _callback = args.pop()