From 2f05fbb6d1d27b24563e308d7ea14049e212f1d9 Mon Sep 17 00:00:00 2001 From: Karol Latecki Date: Wed, 16 Oct 2019 12:41:28 +0200 Subject: [PATCH] spdkcli: fix pylint warnings Fix Python code for warning produced by pylint. - C1801: Do not use `len(SEQUENCE)` to determine if a sequence is empty (len-as-condition) - W0611: Unused import * (unused-import) - C0411: standard import should be placed before X (wrong-import-order) - C0411: third party import X should be placed before X (wrong-import-order) - C0412: Imports from package X are not grouped (ungrouped-imports) - W0212: Access to a protected member _exit of a client class (protected-access) Change-Id: I2c0e8379f962eb2957b428617836867b2e725aeb Signed-off-by: Karol Latecki Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/471482 Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Jim Harris --- scripts/spdkcli.py | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/scripts/spdkcli.py b/scripts/spdkcli.py index 0a802ac5b..bc85649e0 100755 --- a/scripts/spdkcli.py +++ b/scripts/spdkcli.py @@ -1,14 +1,11 @@ #!/usr/bin/env python3 import sys import argparse -import configshell_fb -from os import getuid -from rpc.client import JSONRPCException from configshell_fb import ConfigShell, shell, ExecutionError -from spdkcli import UIRoot -import rpc.client from pyparsing import (alphanums, Optional, Suppress, Word, Regex, removeQuotes, dblQuotedString, OneOrMore) +from rpc.client import JSONRPCException, JSONRPCClient +from spdkcli import UIRoot def add_quotes_to_shell(spdk_shell): @@ -49,7 +46,7 @@ def main(): args = parser.parse_args() try: - client = rpc.client.JSONRPCClient(args.server_addr, port=args.port) + client = JSONRPCClient(args.server_addr, port=args.port) except JSONRPCException as e: spdk_shell.log.error("%s. SPDK not running?" % e) sys.exit(1) @@ -62,7 +59,7 @@ def main(): except BaseException: pass - if len(args.commands) > 0: + if args.commands: try: spdk_shell.interactive = False spdk_shell.run_cmdline(" ".join(args.commands)) @@ -73,14 +70,13 @@ def main(): spdk_shell.con.display("SPDK CLI v0.1") spdk_shell.con.display("") - while not spdk_shell._exit: - try: - spdk_shell.run_interactive() - except (JSONRPCException, ExecutionError) as e: - spdk_shell.log.error("%s" % e) - except BrokenPipeError as e: - spdk_shell.log.error("Lost connection with SPDK: %s" % e) - break + + try: + spdk_shell.run_interactive() + except (JSONRPCException, ExecutionError) as e: + spdk_shell.log.error("%s" % e) + except BrokenPipeError as e: + spdk_shell.log.error("Lost connection with SPDK: %s" % e) if __name__ == "__main__":