From: ogawa.yasufumi@lab.ntt.co.jp
To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp
Subject: [spp] [PATCH 1/5] controller: change name of plugins directory
Date: Thu, 18 Oct 2018 20:27:33 +0900 [thread overview]
Message-ID: <20181018112737.77626-2-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <20181018112737.77626-1-ogawa.yasufumi@lab.ntt.co.jp>
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
Refactor directory name of command plugins from 'command' to 'plugins'
because commands of not plugin are moved to 'commands' directory and
the name of plugins is ambiguous from 'command'.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/controller/{command => plugins}/__init__.py | 0
src/controller/{command => plugins}/hello.py | 0
src/controller/shell.py | 15 +++++++--------
3 files changed, 7 insertions(+), 8 deletions(-)
rename src/controller/{command => plugins}/__init__.py (100%)
rename src/controller/{command => plugins}/hello.py (100%)
diff --git a/src/controller/command/__init__.py b/src/controller/plugins/__init__.py
similarity index 100%
rename from src/controller/command/__init__.py
rename to src/controller/plugins/__init__.py
diff --git a/src/controller/command/hello.py b/src/controller/plugins/hello.py
similarity index 100%
rename from src/controller/command/hello.py
rename to src/controller/plugins/hello.py
diff --git a/src/controller/shell.py b/src/controller/shell.py
index ec5f481..28ae86e 100644
--- a/src/controller/shell.py
+++ b/src/controller/shell.py
@@ -30,7 +30,7 @@ class Shell(cmd.Cmd, object):
HIST_EXCEPT = ['bye', 'exit', 'history', 'redo']
- PLUGIN_DIR = 'command'
+ PLUGIN_DIR = 'plugins'
topo_size = '60%'
# setup history file
@@ -669,24 +669,23 @@ class Shell(cmd.Cmd, object):
def do_load_cmd(self, args):
"""Load command plugin.
- Path of plugin file is 'spp/src/controller/command'.
+ Path of plugin file is 'spp/src/controller/plugins'.
- spp > load hello
+ spp > load_cmd hello
"""
args = re.sub(',', ' ', args)
args = re.sub(r'\s+', ' ', args)
list_args = args.split(' ')
- libdir = 'command'
+ libdir = self.PLUGIN_DIR
mod_name = list_args[0]
method_name = 'do_%s' % mod_name
- loaded = '%s.%s' % (libdir, mod_name)
- exec('import %s' % loaded)
- do_cmd = '%s.%s' % (loaded, method_name)
+ exec('from .%s import %s' % (libdir, mod_name))
+ do_cmd = '%s.%s' % (mod_name, method_name)
exec('Shell.%s = %s' % (method_name, do_cmd))
- print("Module '%s' loaded." % loaded)
+ print("Module '%s' loaded." % mod_name)
def complete_load_cmd(self, text, line, begidx, endidx):
"""Complete command plugins
--
2.13.1
next prev parent reply other threads:[~2018-10-18 11:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-18 11:27 [spp] [PATCH 0/5] Refactor SPP controller ogawa.yasufumi
2018-10-18 11:27 ` ogawa.yasufumi [this message]
2018-10-18 11:27 ` [spp] [PATCH 2/5] controller: exit controller if spp-ctl not running ogawa.yasufumi
2018-10-18 11:27 ` [spp] [PATCH 3/5] controller: move spp_history to home directory ogawa.yasufumi
2018-10-18 11:27 ` [spp] [PATCH 4/5] controller: move PORT_TYPES to spp_common ogawa.yasufumi
2018-10-18 11:27 ` [spp] [PATCH 5/5] controller: remove SECONDARY_LIST ogawa.yasufumi
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=20181018112737.77626-2-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).