From f8c1f991f0ef127220852a83f2c829baf79a8a47 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Mon, 6 May 2019 09:22:11 -0700 Subject: [PATCH] rpc.py: detect stdin pipe If user calls rpc.py with no parameters, it currently hangs, waiting for input. It should print help in this case instead. Signed-off-by: Jim Harris Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453431 (master) (cherry picked from commit ac0824b2d85611932f2bbffeb74a6942a8a2702f) Change-Id: I5939999c57b8db0916267935d79ccc1a3201748b Signed-off-by: Tomasz Zawadzki Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/457221 Tested-by: SPDK CI Jenkins Reviewed-by: Paul Luse Reviewed-by: Darek Stojaczyk --- scripts/rpc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/rpc.py b/scripts/rpc.py index 6a1d0a8e2b..9ee9a6989e 100755 --- a/scripts/rpc.py +++ b/scripts/rpc.py @@ -1812,5 +1812,9 @@ Format: 'user:u1 secret:s1 muser:mu1 msecret:ms1,user:u2 secret:s2 muser:mu2 mse args.client = rpc.client.JSONRPCClient(args.server_addr, args.port, args.timeout, log_level=getattr(logging, args.verbose.upper())) if hasattr(args, 'func'): call_rpc_func(args) + elif sys.stdin.isatty(): + # No arguments and no data piped through stdin + parser.print_help() + exit(1) else: execute_script(parser, args.client, sys.stdin)