spdkcli: Fix: catch exceptions for spdkcli commands.

Fixes: #582

Change-Id: Ief6f4a52f410ff3dc06c9c1551c2c6d464cac598
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/442323
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
Pawel Kaminski 2019-01-28 09:28:36 -05:00 committed by Darek Stojaczyk
parent 6a427c7481
commit 223810e95b

View File

@ -3,7 +3,7 @@ import sys
import argparse import argparse
import configshell_fb import configshell_fb
from os import getuid from os import getuid
from configshell_fb import ConfigShell, shell from configshell_fb import ConfigShell, shell, ExecutionError
from spdkcli import UIRoot from spdkcli import UIRoot
from pyparsing import (alphanums, Optional, Suppress, Word, Regex, from pyparsing import (alphanums, Optional, Suppress, Word, Regex,
removeQuotes, dblQuotedString, OneOrMore) removeQuotes, dblQuotedString, OneOrMore)
@ -49,12 +49,20 @@ def main():
pass pass
if len(args.commands) > 0: if len(args.commands) > 0:
spdk_shell.run_cmdline(" ".join(args.commands)) try:
spdk_shell.run_cmdline(" ".join(args.commands))
except Exception as e:
sys.stderr.write("%s\n" % e)
sys.exit(1)
sys.exit(0) sys.exit(0)
spdk_shell.con.display("SPDK CLI v0.1") spdk_shell.con.display("SPDK CLI v0.1")
spdk_shell.con.display("") spdk_shell.con.display("")
spdk_shell.run_interactive() while not spdk_shell._exit:
try:
spdk_shell.run_interactive()
except ExecutionError as e:
spdk_shell.log.error("%s" % e)
if __name__ == "__main__": if __name__ == "__main__":