Soft Patch Panel
 help / color / mirror / Atom feed
From: ogawa.yasufumi@lab.ntt.co.jp
To: spp@dpdk.org
Cc: ferruh.yigit@intel.com, sy.jong.choi@intel.com,
	Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
Subject: [spp] [PATCH 2/5] Remove unwanted spaces from the sec command
Date: Wed, 19 Jul 2017 03:57:26 +0900	[thread overview]
Message-ID: <20170718185729.76668-2-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <20170718185729.76668-1-ogawa.yasufumi@lab.ntt.co.jp>

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

spp controller returns invalid command error if "sec n;..." contains
unwanted space chars.
Remove unwanted spaces from the command to avoid error.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/spp.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/spp.py b/src/spp.py
index 01aed23..c383820 100755
--- a/src/spp.py
+++ b/src/spp.py
@@ -10,6 +10,8 @@ import getopt
 import select
 import socket
 import sys
+import re
+#import pdb; pdb.set_trace()
 
 class GrowingList(list):
     """GrowingList"""
@@ -309,7 +311,10 @@ class Shell(cmd.Cmd):
     def do_sec(self, arg):
         """Send command to secondary process"""
 
-        cmds = arg.split(';')
+        # remove unwanted space to avoid invalid command error
+        tmparg = re.sub(r'\s+', " ", arg)
+        tmparg = re.sub(r'\s?;\s?', ";", tmparg)
+        cmds = tmparg.split(';')
         if len(cmds) < 2:
             print ("error")
         elif str.isdigit(cmds[0]):
@@ -370,6 +375,7 @@ class Shell(cmd.Cmd):
             self.close()
             return True
 
+
 def main(argv):
     """main"""
 
@@ -381,6 +387,7 @@ def main(argv):
     except getopt.GetoptError:
         print ('spp.py -p <primary__port_number> -s <secondary_port_number>')
         sys.exit(2)
+
     for opt, arg in opts:
         if opt in ("-h", "--help"):
             print ('spp.py -p <primary__port_number> -s <secondary_port_number>')
@@ -429,5 +436,6 @@ def main(argv):
     secondary_sock.shutdown(socket.SHUT_RDWR)
     secondary_sock.close()
 
+
 if __name__ == "__main__":
     main(sys.argv[1:])
-- 
2.13.1

  reply	other threads:[~2017-07-18 18:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-18 18:57 [spp] [PATCH 1/5] Add SO_REUSEADDR option ogawa.yasufumi
2017-07-18 18:57 ` ogawa.yasufumi [this message]
2017-07-18 18:57 ` [spp] [PATCH 3/5] Add management port ogawa.yasufumi
2017-07-18 18:57 ` [spp] [PATCH 4/5] Correct sec command completion ogawa.yasufumi
2017-07-18 18:57 ` [spp] [PATCH 5/5] Add completion for bye command ogawa.yasufumi
2017-08-04 15:57 ` [spp] [PATCH 1/5] Add SO_REUSEADDR option 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=20170718185729.76668-2-ogawa.yasufumi@lab.ntt.co.jp \
    --to=ogawa.yasufumi@lab.ntt.co.jp \
    --cc=ferruh.yigit@intel.com \
    --cc=spp@dpdk.org \
    --cc=sy.jong.choi@intel.com \
    /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).