Browse Source

Use readline if supported on the system, otherwise stdin.


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1441 e5f2f494-b856-4b98-b285-d166d9295462
Shane Kerr 15 years ago
parent
commit
9f5008fd32
1 changed files with 8 additions and 2 deletions
  1. 8 2
      src/bin/bindctl/bindcmd.py

+ 8 - 2
src/bin/bindctl/bindcmd.py

@@ -14,7 +14,6 @@
 # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
 import sys
-import readline
 from cmd import Cmd
 from bindctl.exception import *
 from bindctl.moduleinfo import *
@@ -38,6 +37,13 @@ try:
 except ImportError:
     from bindctl.mycollections import OrderedDict
 
+# if we have readline support, use that, otherwise use normal stdio
+try:
+    import readline
+    my_readline = readline.get_line_buffer
+except ImportError:
+    my_readline = sys.stding.readline
+
 
 CONST_BINDCTL_HELP = """BindCtl, version 0.1
 usage: <module name> <command name> [param1 = value1 [, param2 = value2]]
@@ -320,7 +326,7 @@ class BindCmdInterpreter(Cmd):
         if 0 == state:
             text = text.strip()
             hints = []
-            cur_line = readline.get_line_buffer()            
+            cur_line = my_readline()
             try:
                 cmd = BindCmdParse(cur_line)
                 if not cmd.params and text: