[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[minion-cvs] Add a shell-like interactive mode for windows



Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv23435/lib/mixminion

Modified Files:
	Main.py 
Log Message:
Add a shell-like interactive mode for windows

Index: Main.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Main.py,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- Main.py	26 Jun 2003 17:43:27 -0000	1.52
+++ Main.py	10 Jul 2003 23:12:03 -0000	1.53
@@ -136,6 +136,8 @@
     "server-stats" :   ( 'mixminion.server.ServerMain', 'printServerStats' ),
     "server-DELKEYS" : ( 'mixminion.server.ServerMain', 'runDELKEYS'),
     "dir":             ( 'mixminion.directory.DirMain', 'main'),
+
+    "shell":           ( 'mixminion.Main',       'commandShell' ),
     
     # XXXX006 Obsolete commands.  Remove in 0.0.6
     "server" :         ( 'mixminion.Main', 'rejectCommand' ),
@@ -204,6 +206,42 @@
     print "NOTE: This software is for testing only.  The user set is too small"
     print "      to be anonymous, and the code is too alpha to be reliable."
 
+def commandShell(cmd,args):
+    import mixminion
+    import shlex
+
+    if "--help" in args:
+        print "Syntax: mixminion shell [options]"
+        sys.exit(0)
+
+    print "Mixminion version %s" % mixminion.__version__
+    print "Type 'help' for information, and 'exit' to quit."
+
+    lexer = shlex.shlex()
+    lexer.whitespace = " \t"
+    lexer.wordchars = "".join(map(chr,range(41,127)))
+    while 1:
+        print
+        print "mixminion>",
+        words = []
+        while 1:
+            word = lexer.get_token()
+            if word not in ['\r','\n']:
+                words.append(word)
+            else:
+                break
+        if not words:
+            continue
+        command = words[0]
+        args = words[1:]
+        if command == 'exit':
+            sys.exit(0)
+        try:
+            #print "calling main with",[sys.argv[0]]+words
+            main([sys.argv[0]]+words)
+        except SystemExit:
+            pass
+
 def main(args):
     "Use <args> to fix path, pick a command and pass it arguments."
     # Specifically, args[0] is used to fix sys.path so we can import
@@ -213,7 +251,7 @@
     correctPath(args[0])
 
     # Check whether we have a recognized command.
-    if len(args) == 1 or not _COMMANDS.has_key(args[1]):
+    if len(args) == 1  or not _COMMANDS.has_key(args[1]):
         printUsage()
         sys.exit(1)