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 <james.r.harris@intel.com>
Change-Id: I5939999c57b8db0916267935d79ccc1a3201748b

Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/453431
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
Jim Harris 2019-05-06 09:22:11 -07:00
parent 1ff8706f1f
commit ac0824b2d8

View File

@ -1810,5 +1810,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)