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

[or-cvs] Print usage on failure



Update of /home/or/cvsroot/control/python
In directory moria:/tmp/cvs-serv1690

Modified Files:
	TorExample.py 
Log Message:
Print usage on failure

Index: TorExample.py
===================================================================
RCS file: /home/or/cvsroot/control/python/TorExample.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- TorExample.py	17 Jul 2005 23:08:42 -0000	1.10
+++ TorExample.py	12 Nov 2005 21:41:00 -0000	1.11
@@ -3,22 +3,14 @@
 # Copyright 2005 Nick Mathewson -- See LICENSE for licensing information.
 #$Id$
 
-import socket
-import sys
-from TorCtl import *
-
-"""
-Tor Control Client Example
-A very basic demonstration of using the TorCtl module to communicate and control
-a Tor server.
-
+"""\
 Usage:
   TorExample.py <parameters> <command list>
 
 Parameters:
   --host <hostname>:<port#>  defaults to "localhost:9100"
   --verbose | -v             turn on verbose messages
-  
+
 Commands:
   set_config <config key>=<config value> [<config key>=<config value> ...]
   get_config <config key> [<config key> ...]
@@ -26,11 +18,14 @@
   listen     <event name>
   signal     <signal name>
   auth_demo  <auth token>
-  
+
 For example, to listen for any error messages do:
 
-  python TorExample listen ERR
-"""
+  python TorExample listen ERR"""
+
+import socket
+import sys
+from TorCtl import *
 
 def getConnection(daemon=1):
     """
@@ -72,13 +67,15 @@
     and looking for that named item in the python globals() list.
     """
     if len(sys.argv)<2:
-        print "No command given. Finished."
+        print "No command given."
+        print __doc__
         return
     cmd = sys.argv[1].replace("-","_")
     del sys.argv[1]
     fn = globals().get("run_"+cmd)
     if fn is None:
         print "Unrecognized command:",cmd
+        print __doc__
         return
     try:
         fn()