From 223810e95b2477a8053d6144527ba32e09b7f611 Mon Sep 17 00:00:00 2001 From: Pawel Kaminski Date: Mon, 28 Jan 2019 09:28:36 -0500 Subject: [PATCH] spdkcli: Fix: catch exceptions for spdkcli commands. Fixes: #582 Change-Id: Ief6f4a52f410ff3dc06c9c1551c2c6d464cac598 Signed-off-by: Pawel Kaminski Reviewed-on: https://review.gerrithub.io/c/442323 Tested-by: SPDK CI Jenkins Reviewed-by: Pawel Wodkowski Reviewed-by: Karol Latecki Reviewed-by: Ben Walker Reviewed-by: Darek Stojaczyk --- scripts/spdkcli.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/spdkcli.py b/scripts/spdkcli.py index 71d8857fe..82343a5cd 100755 --- a/scripts/spdkcli.py +++ b/scripts/spdkcli.py @@ -3,7 +3,7 @@ import sys import argparse import configshell_fb from os import getuid -from configshell_fb import ConfigShell, shell +from configshell_fb import ConfigShell, shell, ExecutionError from spdkcli import UIRoot from pyparsing import (alphanums, Optional, Suppress, Word, Regex, removeQuotes, dblQuotedString, OneOrMore) @@ -49,12 +49,20 @@ def main(): pass 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) spdk_shell.con.display("SPDK CLI v0.1") 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__":