diff --git a/tornado_m2crypto/m2iostream.py b/tornado_m2crypto/m2iostream.py index 5eadf6b..ca66289 100644 --- a/tornado_m2crypto/m2iostream.py +++ b/tornado_m2crypto/m2iostream.py @@ -50,7 +50,7 @@ class getToken(tornado.web.RequestHandler): def get(self): - print self.request.get_ssl_certificate().as_text() + print(self.request.get_ssl_certificate().as_text()) self.write("hello\n\n") application = tornado.web.Application([ @@ -94,8 +94,6 @@ def get(self): from M2Crypto import m2, SSL, Err - - _client_m2_ssl_defaults = SSL.Context() # Do I need to add the pruposes ? # _client_m2_ssl_defaults.set_options(m2.X509_PURPOSE_SSL_CLIENT) @@ -297,7 +295,7 @@ def read_from_fd(self, buf): # implementation of recv_into, or work out why it # sometimes gets a None returned anyway, it's probably # a race between the handshake and the first read? - #print "Nothing to read? %s"%repr(e) + # print("Nothing to read?", repr(e)) return None except SSL.SSLError as e: diff --git a/tornado_m2crypto/test/client_test.py b/tornado_m2crypto/test/client_test.py index 6d7b89a..608674b 100644 --- a/tornado_m2crypto/test/client_test.py +++ b/tornado_m2crypto/test/client_test.py @@ -1,3 +1,7 @@ +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + import requests #CERT='test.crt' #KEY='test.key' @@ -13,14 +17,14 @@ #CERT= os.path.realpath(CERTDIR + 'MrBoinc/proxy.pem') #KEY= os.path.realpath(CERTDIR + 'MrBoinc/proxy.pem') -print (CERT,KEY) +print(CERT, KEY) import sys SERVER = 'https://localhost:12345' -print requests.get('https://localhost:12345', cert = (CERT,KEY), verify = False) +print(requests.get('https://localhost:12345', cert = (CERT,KEY), verify = False)) sys.exit(0) # THIS IS FOR LATER POTENTIALLY @@ -52,6 +56,6 @@ def proxy_manager_for(self, *args, **kwargs): s = requests.Session() s.mount(SERVER, DESAdapter()) -print s.get(SERVER, cert = (CERT,KEY), verify = False) +print(s.get(SERVER, cert = (CERT,KEY), verify = False)) #requests.get('https://localhost:12345', cert = (CERT,KEY), verify = False) diff --git a/tornado_m2crypto/test/m2io_dirac.py b/tornado_m2crypto/test/m2io_dirac.py index 7401704..504ef1e 100644 --- a/tornado_m2crypto/test/m2io_dirac.py +++ b/tornado_m2crypto/test/m2io_dirac.py @@ -1,4 +1,8 @@ #!/usr/bin/env python +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + # Simple HTTPS test server # Run with: tox -e m2io_https # Client: curl -k -v https://localhost:12345 @@ -48,12 +52,12 @@ class getToken(tornado.web.RequestHandler): def get(self): # pemCert = self.request.connection.stream.socket.get_peer_cert().as_pem() #False = dictionnaire, True=Binaire - # print "CERT !! %s"%pemCert + # print("CERT !!", pemCert) # diracCert = X509Certificate() - # print "LOADING %s"%diracCert.loadFromString(pemCert) - # print "DIRAC CERT !! %s"%diracCert.getSubjectDN() + # print("LOADING %s", diracCert.loadFromString(pemCert)) + # print("DIRAC CERT !!", diracCert.getSubjectDN()) chainAsText =self.request.get_ssl_certificate().as_pem() - print "First in the list %s"%chainAsText + print("First in the list" % chainAsText) diracChain = X509Chain() cert_chain = self.request.get_ssl_certificate_chain() for cert in cert_chain: @@ -61,7 +65,7 @@ def get(self): # diracCert.loadFromString(cert.as_pem()) # diracCertList.append(diracCert) chainAsText += cert.as_pem() - print "one more %s"%cert.get_subject() + print("one more" % cert.get_subject()) diracChain.loadChainFromString(chainAsText) from pprint import pprint diff --git a/tornado_m2crypto/test/m2io_https.py b/tornado_m2crypto/test/m2io_https.py index a826f8d..3204250 100644 --- a/tornado_m2crypto/test/m2io_https.py +++ b/tornado_m2crypto/test/m2io_https.py @@ -1,4 +1,8 @@ #!/usr/bin/env python +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + # Simple HTTPS test server # Run with: tox -e m2io_https # Client: curl -k -v https://localhost:12345 @@ -16,7 +20,7 @@ 'ca_certs': CERTDIR + 'ca/ca.cert.pem', } -print SSL_OPTS +print(SSL_OPTS) #SSL_OPTS = { # # 'certfile': '/tmp/hostcert/hostcert.pem', @@ -47,12 +51,12 @@ class getToken(tornado.web.RequestHandler): def get(self): - print self.request.get_ssl_certificate().as_text() #False = dictionnaire, True=Binaire - print ("CHRIS %s"%type(self.request.connection.stream)) - print "CHRIS %s"%len(self.request.get_ssl_certificate_chain()) + print(self.request.get_ssl_certificate().as_text()) #False = dictionnaire, True=Binaire + print("CHRIS", type(self.request.connection.stream)) + print("CHRIS", len(self.request.get_ssl_certificate_chain())) for c in self.request.connection.stream.socket.get_peer_cert_chain(): - print ('++++++++++++++++++++++') - print c.as_text() + print('++++++++++++++++++++++') + print(c.as_text()) self.write("hello\n\n") application = tornado.web.Application([ diff --git a/tornado_m2crypto/test/m2iostream_test.py b/tornado_m2crypto/test/m2iostream_test.py index 9ec7e1e..965c4e6 100644 --- a/tornado_m2crypto/test/m2iostream_test.py +++ b/tornado_m2crypto/test/m2iostream_test.py @@ -1,4 +1,7 @@ -from __future__ import absolute_import, division, print_function +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function + from tornado.concurrent import Future from tornado import gen from tornado import netutil diff --git a/tornado_m2crypto/test/runtests.py b/tornado_m2crypto/test/runtests.py index 584ae9c..c6ed15c 100644 --- a/tornado_m2crypto/test/runtests.py +++ b/tornado_m2crypto/test/runtests.py @@ -1,3 +1,6 @@ +from __future__ import absolute_import +from __future__ import division +from __future__ import print_function import tornado.test.runtests as original_runtests @@ -13,7 +16,7 @@ -print tornado.iostream +print(tornado.iostream) tornado.iostream.SSLIOStream.configure('tornado_m2crypto.m2iostream.M2IOStream') @@ -35,7 +38,7 @@ # M2_TEST_MODULES.append('m2iostream_test.TestIOStreamM2') -print "RUNNING %s"%M2_TEST_MODULES +print("RUNNING %s" % M2_TEST_MODULES)