From 70a6e3ac22a536ec2a97ef6d41c74fd5ad637629 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Wed, 9 Feb 2022 17:50:28 +0000 Subject: [PATCH] rpc.py: ignore lines starting with # on stdin rpc.py users can pipe RPC calls through stdin, which reduces overhead compared to calling rpc.py separately for each RPC. It is common to put these RPC calls in a file, and then pipe that file to rpc.py. To allow commenting out RPC calls when doing debugging, have rpc.py ignore any lines which begin with '#', allowing users to comment out RPC calls (or even add comments explaining the RPC calls) with a '#' character. Signed-off-by: Jim Harris Change-Id: I8d9c6ac95dd5864c16e4d69ba80f81799068e808 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11506 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Reviewed-by: Dong Yi Reviewed-by: Aleksey Marchuk Reviewed-by: Changpeng Liu Tested-by: SPDK CI Jenkins --- scripts/rpc.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/rpc.py b/scripts/rpc.py index 6dd3e74a34..6a1de8b1ee 100755 --- a/scripts/rpc.py +++ b/scripts/rpc.py @@ -2863,7 +2863,11 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse if not rpc_call.strip(): continue executed_rpc = "\n".join([executed_rpc, rpc_call]) - args = parser.parse_args(shlex.split(rpc_call)) + rpc_args = shlex.split(rpc_call) + if rpc_args[0][0] == '#': + # Ignore lines starting with # - treat them as comments + continue + args = parser.parse_args(rpc_args) args.client = client try: call_rpc_func(args)