Commit 8bc9798d authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

rpc.py: add new kv to existing params dict



When we get an error when calling an RPC, client.py
makes extensive use of the ** operator to add
the method and req_id to the params dict variable.

This doens't work with Python 2.  We don't really
support Python 2, but there are at least some folks
out there who make their own mods to get rpc.py
to work with it.  We can very easily implement this in
a way that is Python 2 friendly, so let's do that
to make it a tiny bit easier for those folks.

Incidentally, I do think the changes here also make
this part of the code a bit easier to read and
understand.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I1846c80e21032ffba67128bee946b041a61d0621

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/476632


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarAlexey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent cd433e7e
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -158,8 +158,9 @@ class JSONRPCClient(object):
                raise e

        if 'error' in response:
            msg = "\n".join(["request:", "%s" % json.dumps({**{"method": method, "req_id": req_id},
                                                            **params}, indent=2),
            params["method"] = method
            params["req_id"] = req_id
            msg = "\n".join(["request:", "%s" % json.dumps(params, indent=2),
                             "Got JSON-RPC error response",
                             "response:",
                             json.dumps(response['error'], indent=2)])