From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mogw0439.ocn.ad.jp (mogw0439.ocn.ad.jp [118.23.109.22]) by dpdk.org (Postfix) with ESMTP id 582612BD3 for ; Tue, 6 Mar 2018 12:16:35 +0100 (CET) Received: from mf-smf-ucb026c1 (mf-smf-ucb026c1.ocn.ad.jp [153.153.66.166]) by mogw0439.ocn.ad.jp (Postfix) with ESMTP id C8A494202B0; Tue, 6 Mar 2018 20:16:33 +0900 (JST) Received: from ntt.pod01.mv-mta-ucb020 ([153.149.142.83]) by mf-smf-ucb026c1 with ESMTP id tAa3efUcdPEygtAa9eKPTZ; Tue, 06 Mar 2018 20:16:33 +0900 Received: from smtp.ocn.ne.jp ([153.149.227.135]) by ntt.pod01.mv-mta-ucb020 with id JbGZ1x0082vuoep01bGZfw; Tue, 06 Mar 2018 11:16:33 +0000 Received: from localhost.localdomain (sp1-66-103-93.msc.spmode.ne.jp [1.66.103.93]) by smtp.ocn.ne.jp (Postfix) with ESMTPA; Tue, 6 Mar 2018 20:16:33 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: ferruh.yigit@intel.com, spp@dpdk.org Cc: Yasufumi Ogawa Date: Tue, 6 Mar 2018 20:16:17 +0900 Message-Id: <20180306111617.67133-3-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20180306111617.67133-1-ogawa.yasufumi@lab.ntt.co.jp> References: <20180306111617.67133-1-ogawa.yasufumi@lab.ntt.co.jp> Subject: [spp] [PATCH 2/2] controller: change formatter for sec to common X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Mar 2018 11:16:36 -0000 From: Yasufumi Ogawa 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 --- 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