[or-cvs] in the python controller example, don"t traceback if the co...

arma at seul.org arma at seul.org
Wed Jul 13 00:09:10 UTC 2005


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

Modified Files:
	TorExample.py 
Log Message:
in the python controller example, don't traceback if the control
port is not listening.


Index: TorExample.py
===================================================================
RCS file: /home/or/cvsroot/control/python/TorExample.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- TorExample.py	11 Jul 2005 20:06:24 -0000	1.5
+++ TorExample.py	13 Jul 2005 00:09:08 -0000	1.6
@@ -23,7 +23,11 @@
 
     host,port = parseHostAndPort(hostport)
     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-    s.connect((host,port))
+    try:
+        s.connect((host,port))
+    except socket.error, e:
+        print "Connection failed: %s. Is the ControlPort enabled?"%e
+        sys.exit(1)
     conn = get_connection(s)
     if verbose and hasattr(conn, "debug"):
         conn.debug(sys.stdout)



More information about the tor-commits mailing list