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/sni/server.py b/examples/sni/server.py
index 8738416..e0c159a 100644
--- a/examples/sni/server.py
+++ b/examples/sni/server.py
@@ -1,16 +1,13 @@
# Copyright (C) Jean-Paul Calderone
# See LICENSE for details.
-if __name__ == '__main__':
- import server
- raise SystemExit(server.main())
-
from sys import stdout
from socket import SOL_SOCKET, SO_REUSEADDR, socket
from OpenSSL.crypto import FILETYPE_PEM, load_privatekey, load_certificate
from OpenSSL.SSL import TLSv1_METHOD, Context, Connection
+
def load(domain):
crt = open(domain + ".crt")
key = open(domain + ".key")
@@ -49,7 +46,7 @@
certificates = {
"example.invalid": load("example.invalid"),
"another.invalid": load("another.invalid"),
- }
+}
def pick_certificate(connection):
@@ -62,3 +59,7 @@
new_context.use_privatekey(key)
new_context.use_certificate(cert)
connection.set_context(new_context)
+
+
+if __name__ == '__main__':
+ raise SystemExit(main())