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

[or-cvs] r10401: Fix python torctl bug 395: in TorExample.py, accept commands (in torctl/trunk: . python)



Author: nickm
Date: 2007-05-29 16:31:40 -0400 (Tue, 29 May 2007)
New Revision: 10401

Modified:
   torctl/trunk/
   torctl/trunk/python/TorExample.py
Log:
 r13075@catbus:  nickm | 2007-05-29 16:31:30 -0400
 Fix python torctl bug 395: in TorExample.py, accept commands that come after global options.



Property changes on: torctl/trunk
___________________________________________________________________
 svk:merge ticket from /torctl/trunk [r13075] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: torctl/trunk/python/TorExample.py
===================================================================
--- torctl/trunk/python/TorExample.py	2007-05-29 19:54:54 UTC (rev 10400)
+++ torctl/trunk/python/TorExample.py	2007-05-29 20:31:40 UTC (rev 10401)
@@ -70,11 +70,15 @@
         print "No command given."
         print __doc__
         return
-    cmd = sys.argv[1].replace("-","_")
-    del sys.argv[1]
-    fn = globals().get("run_"+cmd)
+    for idx in xrange(1, len(sys.argv)):
+        arg = sys.argv[idx]
+        cmd = arg.replace("-","_")
+        fn = globals().get("run_"+cmd)
+        if fn != None:
+            del sys.argv[idx]
+            break
     if fn is None:
-        print "Unrecognized command:",cmd
+        print "Unrecognized command:",sys.argv[1]
         print __doc__
         return
     try:
@@ -130,6 +134,7 @@
     """
     conn = getConnection(daemon=0)
     events = []
+    print "listening!"
     conn.set_event_handler(DebugEventHandler())
     conn.set_events(sys.argv[1:])