Parcourir la source

1. Rename run_bindctl to bindctl.
2. Rename file name "bindctl.py" to 'bindcmd.py'.
3. Rename file name "command.py" to 'cmdparse.py'.

git-svn-id: svn://bind10.isc.org/svn/bind10/branches/parkinglot@528 e5f2f494-b856-4b98-b285-d166d9295462

Likun Zhang il y a 15 ans
Parent
commit
11510aca9c

+ 2 - 2
configure.ac

@@ -146,7 +146,7 @@ AC_OUTPUT([src/bin/bind-cfgd/bind-cfgd
            src/bin/cmd-ctrld/cmd-ctrld
            src/bin/bind10/bind10
            src/bin/bind10/bind10_test
-           src/bin/bindctl/run_bindctl
+           src/bin/bindctl/bindctl
            src/bin/msgq/msgq
            src/bin/msgq/msgq_test
            src/bin/parkinglot/config.h
@@ -154,7 +154,7 @@ AC_OUTPUT([src/bin/bind-cfgd/bind-cfgd
            chmod +x src/bin/bind-cfgd/bind-cfgd
            chmod +x src/bin/cmd-ctrld/cmd-ctrld
            chmod +x src/bin/bind10/bind10
-           chmod +x src/bin/bindctl/run_bindctl
+           chmod +x src/bin/bindctl/bindctl
            chmod +x src/bin/msgq/msgq
            chmod +x src/bin/msgq/msgq_test
           ])

+ 1 - 1
src/bin/bindctl/Makefile.am

@@ -1,2 +1,2 @@
-bin_SCRIPTS = run_bindctl run_bindctl.py
+bin_SCRIPTS = bindctl bindctl.py
 man_MANS = bindctl.1

+ 12 - 0
src/bin/bindctl/bindctl.in

@@ -0,0 +1,12 @@
+#! /bin/sh
+
+PYTHON_EXEC=${PYTHON_EXEC:-@PYTHON@}
+export PYTHON_EXEC
+
+BINDCTL_PATH=@abs_top_srcdir@/src/bin/bindctl
+
+PYTHONPATH=@abs_top_srcdir@/src/lib/cc/python:@abs_top_srcdir@/src/lib/bindctl/
+export PYTHONPATH
+
+cd ${BINDCTL_PATH}
+exec ${PYTHON_EXEC} -O bindctl.py $*

+ 4 - 4
src/bin/bindctl/run_bindctl.py

@@ -1,10 +1,10 @@
 from moduleinfo  import *
-from bindctl import *
+from bindcmd import *
 import ISC
 import pprint
 
 
-def prepare_config_commands(bindctl):
+def prepare_config_commands(tool):
     module = ModuleInfo(name = "config", desc = "Configuration commands")
     cmd = CommandInfo(name = "show", desc = "Show configuration", need_inst_param = False)
     param = ParamInfo(name = "identifier", type = "string", optional=True)
@@ -48,7 +48,7 @@ def prepare_config_commands(bindctl):
     cmd.add_param(param)
     module.add_command(cmd)
 
-    bindctl.add_module_info(module)
+    tool.add_module_info(module)
     
 def prepare_boss_command(tool):
     # Prepare the command 'shutdown' for Boss, this is one 'hardcode' exception.
@@ -62,7 +62,7 @@ def prepare_boss_command(tool):
 
 if __name__ == '__main__':
     try:
-        tool = BindCtl("localhost:8080")
+        tool = BindCmdInterpreter("localhost:8080")
         prepare_config_commands(tool)
         prepare_boss_command(tool)
         tool.run()

+ 0 - 10
src/bin/bindctl/run_bindctl.in

@@ -1,10 +0,0 @@
-#! /bin/sh
-
-PYTHON_EXEC=${PYTHON_EXEC:-@PYTHON@}
-BINDCTL_PATH=.
-
-PYTHONPATH=../../lib/cc/python:../../lib/bindctl/
-export PYTHONPATH
-
-cd ${BINDCTL_PATH}
-exec ${PYTHON_EXEC} -O run_bindctl.py $*

+ 4 - 4
src/lib/bindctl/bindctl.py

@@ -3,7 +3,7 @@ import readline
 from cmd import Cmd
 from exception import *
 from moduleinfo import *
-from command import BindCtlCmd
+from cmdparse import BindCmdParse
 from xml.dom import minidom
 import ISC
 import ISC.CC.data
@@ -31,7 +31,7 @@ Type \"<module_name> <command_name> help\" for help on the specific command.
 
 CONST_COMMAND_NODE = "command"
 
-class BindCtl(Cmd):
+class BindCmdInterpreter(Cmd):
     """simple bindctl example."""    
 
     def __init__(self, server_port = 'localhost:8080'):
@@ -249,7 +249,7 @@ class BindCtl(Cmd):
             hints = []
             cur_line = readline.get_line_buffer()            
             try:
-                cmd = BindCtlCmd(cur_line)
+                cmd = BindCmdParse(cur_line)
                 if not cmd.params and text:
                     hints = self._get_command_startswith(cmd.module, text)
                 else:                       
@@ -325,7 +325,7 @@ class BindCtl(Cmd):
 
     def _parse_cmd(self, line):
         try:
-            cmd = BindCtlCmd(line)
+            cmd = BindCmdParse(line)
             self.validate_cmd(cmd)
             self._handle_cmd(cmd)
         except BindCtlException as e:

+ 1 - 1
src/lib/bindctl/command.py

@@ -18,7 +18,7 @@ PARAM_PATTERN = re.compile(param_name_str + param_value_str + next_params_str)
 # Used for module and command name
 NAME_PATTERN = re.compile("^\s*(?P<name>[\w]+)(?P<blank>\s*)(?P<others>.*)$")
 
-class BindCtlCmd:
+class BindCmdParse:
     """ This class will parse the command line usr input into three part
     module name, command, parameters
     the first two parts are strings and parameter is one hash, 

+ 20 - 20
src/lib/bindctl/unittest_bindctl.py

@@ -1,6 +1,6 @@
 import unittest
-import command
-import bindctl
+import cmdparse
+import bindcmd
 from moduleinfo import *
 from exception import *    
 try:
@@ -11,11 +11,11 @@ except ImportError:
 class TestCmdLex(unittest.TestCase):
     
     def my_assert_raise(self, exception_type, cmd_line):
-        self.assertRaises(exception_type, command.BindCtlCmd, cmd_line)
+        self.assertRaises(exception_type, cmdparse.BindCmdParse, cmd_line)
 
 
     def testCommandWithoutParameter(self):
-        cmd = command.BindCtlCmd("zone add")
+        cmd = cmdparse.BindCmdParse("zone add")
         assert cmd.module == "zone"
         assert cmd.command == "add"
         self.assertEqual(len(cmd.params), 0)
@@ -27,7 +27,7 @@ class TestCmdLex(unittest.TestCase):
                  "zone add zone_name = 'cnnic.cn\", file ='cnnic.cn.file' master=1.1.1.1, " }
         
         for cmd_line in lines:
-            cmd = command.BindCtlCmd(cmd_line)
+            cmd = cmdparse.BindCmdParse(cmd_line)
             assert cmd.module == "zone"
             assert cmd.command == "add"
             assert cmd.params["zone_name"] == "cnnic.cn"
@@ -36,15 +36,15 @@ class TestCmdLex(unittest.TestCase):
             
             
     def testCommandWithListParam(self):
-            cmd = command.BindCtlCmd("zone set zone_name='cnnic.cn', master='1.1.1.1, 2.2.2.2'")
+            cmd = cmdparse.BindCmdParse("zone set zone_name='cnnic.cn', master='1.1.1.1, 2.2.2.2'")
             assert cmd.params["master"] == '1.1.1.1, 2.2.2.2'            
         
         
     def testCommandWithHelpParam(self):
-        cmd = command.BindCtlCmd("zone add help")
+        cmd = cmdparse.BindCmdParse("zone add help")
         assert cmd.params["help"] == "help"
         
-        cmd = command.BindCtlCmd("zone add help *&)&)*&&$#$^%")
+        cmd = cmdparse.BindCmdParse("zone add help *&)&)*&&$#$^%")
         assert cmd.params["help"] == "help"
         self.assertEqual(len(cmd.params), 1)
         
@@ -82,10 +82,10 @@ class TestCmdLex(unittest.TestCase):
 
 class TestCmdSyntax(unittest.TestCase):
     
-    def _create_bindctl(self):
-        """Create one bindctl"""
+    def _create_bindcmd(self):
+        """Create one bindcmd"""
         
-        tool = bindctl.BindCtl()        
+        tool = bindcmd.BindCmdInterpreter()        
         zone_file_param = ParamInfo(name = "zone_file")
         load_cmd = CommandInfo(name = "load")
         load_cmd.add_param(zone_file_param)
@@ -108,17 +108,17 @@ class TestCmdSyntax(unittest.TestCase):
         
         
     def setUp(self):
-        self.bindctl = self._create_bindctl()
+        self.bindcmd = self._create_bindcmd()
         
         
     def no_assert_raise(self, cmd_line):
-        cmd = command.BindCtlCmd(cmd_line)
-        self.bindctl.validate_cmd(cmd) 
+        cmd = cmdparse.BindCmdParse(cmd_line)
+        self.bindcmd.validate_cmd(cmd) 
         
         
     def my_assert_raise(self, exception_type, cmd_line):
-        cmd = command.BindCtlCmd(cmd_line)
-        self.assertRaises(exception_type, self.bindctl.validate_cmd, cmd)  
+        cmd = cmdparse.BindCmdParse(cmd_line)
+        self.assertRaises(exception_type, self.bindcmd.validate_cmd, cmd)  
         
         
     def testValidateSuccess(self):
@@ -156,12 +156,12 @@ class TestNameSequence(unittest.TestCase):
     Test if the module/command/parameters is saved in the order creation
     """
     
-    def _create_bindctl(self):
-        """Create one bindctl"""     
+    def _create_bindcmd(self):
+        """Create one bindcmd"""     
         
         self._cmd = CommandInfo(name = "load")
         self.module = ModuleInfo(name = "zone")
-        self.tool = bindctl.BindCtl()        
+        self.tool = bindcmd.BindCmdInterpreter()        
         for random_str in self.random_names:
             self._cmd.add_param(ParamInfo(name = random_str))
             self.module.add_command(CommandInfo(name = random_str))
@@ -169,7 +169,7 @@ class TestNameSequence(unittest.TestCase):
         
     def setUp(self):
         self.random_names = ['1erdfeDDWsd', '3fe', '2009erd', 'Fe231', 'tere142', 'rei8WD']
-        self._create_bindctl()
+        self._create_bindcmd()
         
     def testSequence(self):        
         param_names = self._cmd.get_param_names()