From 02b29614e7a209cc8e93d88c80e799cb359279ff Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Wed, 1 May 2019 08:22:59 -0700 Subject: [PATCH] scripts/rpc.py: add call_rpc_func() This makes no functional change to the script, but it prepares for an upcoming change allowing callers to pipe a newline delimited list of rpc calls. Signed-off-by: Jim Harris Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/452769 (master) (cherry picked from commit 6895f0f27e7f6fd77da936aa3b2d342a8c2dff9b) Change-Id: I695ca61510f9edd336713e88d134e42c1d78a1b4 Signed-off-by: Tomasz Zawadzki Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457219 Tested-by: SPDK CI Jenkins Reviewed-by: Paul Luse Reviewed-by: Darek Stojaczyk --- scripts/rpc.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/rpc.py b/scripts/rpc.py index f1532769c..65521da34 100755 --- a/scripts/rpc.py +++ b/scripts/rpc.py @@ -1792,13 +1792,14 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse p.add_argument('-n', '--max', help="""Maximum number of notifications to return in response""", type=int) p.set_defaults(func=get_notifications) - args = parser.parse_args() - - with rpc.client.JSONRPCClient(args.server_addr, args.port, args.timeout, log_level=getattr(logging, args.verbose.upper())) as client: + def call_rpc_func(args): try: - args.client = client args.func(args) except JSONRPCException as ex: print("Exception:") print(ex.message) exit(1) + + args = parser.parse_args() + args.client = rpc.client.JSONRPCClient(args.server_addr, args.port, args.timeout, log_level=getattr(logging, args.verbose.upper())) + call_rpc_func(args)