From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from tama50.ecl.ntt.co.jp (tama50.ecl.ntt.co.jp [129.60.39.147]) by dpdk.org (Postfix) with ESMTP id 4CB6B5B3E for ; Thu, 18 Oct 2018 13:27:46 +0200 (CEST) Received: from vc2.ecl.ntt.co.jp (vc2.ecl.ntt.co.jp [129.60.86.154]) by tama50.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id w9IBRk7s020323; Thu, 18 Oct 2018 20:27:46 +0900 Received: from vc2.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id 05C25639489; Thu, 18 Oct 2018 20:27:46 +0900 (JST) Received: from localhost.localdomain (unknown [129.60.13.51]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id EB846639462; Thu, 18 Oct 2018 20:27:45 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp Date: Thu, 18 Oct 2018 20:27:33 +0900 Message-Id: <20181018112737.77626-2-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20181018112737.77626-1-ogawa.yasufumi@lab.ntt.co.jp> References: <20181018112737.77626-1-ogawa.yasufumi@lab.ntt.co.jp> X-TM-AS-MML: disable Subject: [spp] [PATCH 1/5] controller: change name of plugins directory 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: Thu, 18 Oct 2018 11:27:47 -0000 From: Yasufumi Ogawa 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 --- 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