Skip to content

Commit

Permalink
Merge pull request #2 from chrisburr/fix-py3-prints
Browse files Browse the repository at this point in the history
Fix print statements for Python 3
  • Loading branch information
chrisburr authored Oct 27, 2020
2 parents 9fc856e + db330ca commit 7cc2e60
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 21 deletions.
6 changes: 2 additions & 4 deletions tornado_m2crypto/m2iostream.py
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
10 changes: 7 additions & 3 deletions tornado_m2crypto/test/client_test.py
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -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)
14 changes: 9 additions & 5 deletions tornado_m2crypto/test/m2io_dirac.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -48,20 +52,20 @@
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:
# diracCert = X509Certificate()
# 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
Expand Down
16 changes: 10 additions & 6 deletions tornado_m2crypto/test/m2io_https.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -16,7 +20,7 @@
'ca_certs': CERTDIR + 'ca/ca.cert.pem',
}

print SSL_OPTS
print(SSL_OPTS)
#SSL_OPTS = {
#
# 'certfile': '/tmp/hostcert/hostcert.pem',
Expand Down Expand Up @@ -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([
Expand Down
5 changes: 4 additions & 1 deletion tornado_m2crypto/test/m2iostream_test.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 5 additions & 2 deletions tornado_m2crypto/test/runtests.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -13,7 +16,7 @@



print tornado.iostream
print(tornado.iostream)
tornado.iostream.SSLIOStream.configure('tornado_m2crypto.m2iostream.M2IOStream')


Expand All @@ -35,7 +38,7 @@
# M2_TEST_MODULES.append('m2iostream_test.TestIOStreamM2')


print "RUNNING %s"%M2_TEST_MODULES
print("RUNNING %s" % M2_TEST_MODULES)



Expand Down

0 comments on commit 7cc2e60

Please sign in to comment.