From: ogawa.yasufumi@lab.ntt.co.jp
To: ferruh.yigit@intel.com, spp@dpdk.org
Cc: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
Subject: [spp] [PATCH 2/2] controller: change formatter for sec to common
Date: Tue, 6 Mar 2018 20:16:17 +0900 [thread overview]
Message-ID: <20180306111617.67133-3-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <20180306111617.67133-1-ogawa.yasufumi@lab.ntt.co.jp>
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
Change formatter method clean_sec_cmd() to be used from primary and
secondary commonly. Method name is also changed to clean_cmd().
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/controller/shell.py | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/controller/shell.py b/src/controller/shell.py
index 86598d3..91b78f1 100644
--- a/src/controller/shell.py
+++ b/src/controller/shell.py
@@ -163,7 +163,7 @@ class Shell(cmd.Cmd, object):
return valid
- def clean_sec_cmd(self, cmdstr):
+ def clean_cmd(self, cmdstr):
"""remove unwanted spaces to avoid invalid command error"""
tmparg = re.sub(r'\s+', " ", cmdstr)
@@ -226,11 +226,17 @@ class Shell(cmd.Cmd, object):
spp > pri;clear
"""
- if command and command in self.PRI_CMDS:
+ # Remove unwanted spaces and first char ';'
+ command = self.clean_cmd(command)[1:]
+
+ if logger is not None:
+ logger.info("Receive pri command: '%s'" % command)
+
+ if command and (command in self.PRI_CMDS):
result, message = self.command_primary(command)
self.response(result, message)
else:
- message = "primary invalid command"
+ message = "Invalid pri command: '%s'" % command
print(message)
self.response(self.CMD_ERROR, message)
@@ -258,7 +264,7 @@ class Shell(cmd.Cmd, object):
"""
# remove unwanted spaces to avoid invalid command error
- tmparg = self.clean_sec_cmd(arg)
+ tmparg = self.clean_cmd(arg)
cmds = tmparg.split(';')
if len(cmds) < 2:
message = "error"
@@ -282,7 +288,7 @@ class Shell(cmd.Cmd, object):
"""Completion for secondary process commands"""
try:
- cleaned_line = self.clean_sec_cmd(line)
+ cleaned_line = self.clean_cmd(line)
if len(cleaned_line.split()) == 1:
completions = [str(i)+";" for i in spp_common.SECONDARY_LIST]
elif len(cleaned_line.split()) == 2:
--
2.13.1
next prev parent reply other threads:[~2018-03-06 11:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-06 11:16 [spp] [PATCH 0/2] Misc update for SPP controller ogawa.yasufumi
2018-03-06 11:16 ` [spp] [PATCH 1/2] controller: fix bug ogawa.yasufumi
2018-03-06 11:16 ` ogawa.yasufumi [this message]
2018-03-27 23:47 ` [spp] [PATCH 0/2] Misc update for SPP controller Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180306111617.67133-3-ogawa.yasufumi@lab.ntt.co.jp \
--to=ogawa.yasufumi@lab.ntt.co.jp \
--cc=ferruh.yigit@intel.com \
--cc=spp@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).