Polish up examples (somewhat)
- Mention them in the docs (arguably a bit hamfistedly).
- Make the README an RST.
- Make them pass flake8 and add flake8 to tox.ini
They should all be rewritten and made Python 3-friendly but that's out
of scope here.
diff --git a/examples/proxy.py b/examples/proxy.py
index b1c4253..3be26f9 100644
--- a/examples/proxy.py
+++ b/examples/proxy.py
@@ -8,15 +8,20 @@
#
# $Id: proxy.py,v 1.2 2004/07/22 12:01:25 martin Exp $
-import sys, socket, string
+import sys
+import socket
+import string
+
from OpenSSL import SSL
+
def usage(exit_code=0):
print "Usage: %s server[:port] proxy[:port]" % sys.argv[0]
print " Connects SSL to the specified server (port 443 by default)"
print " using the specified proxy (port 8080 by default)"
sys.exit(exit_code)
+
def main():
# Command-line processing
if len(sys.argv) != 3:
@@ -26,12 +31,13 @@
run(split_host(server, 443), split_host(proxy, 8080))
+
def split_host(hostname, default_port=80):
a = string.split(hostname, ':', 1)
if len(a) == 1:
a.append(default_port)
return a[0], int(a[1])
-
+
# Connects to the server, through the proxy
def run(server, proxy):
@@ -66,5 +72,6 @@
print buff,
+
if __name__ == '__main__':
main()