Skip to content

Commit 45a6762

Browse files
author
Roland Hedberg
committed
Merge pull request #218 from SpamapS/master
Fix python3 syntax errors
2 parents 4ef4463 + dddfe31 commit 45a6762

File tree

89 files changed

+582
-557
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+582
-557
lines changed

example/idp2/idp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,5 +1065,5 @@ def application(environ, start_response):
10651065
PORT = CONFIG.PORT
10661066

10671067
SRV = make_server(HOST, PORT, application)
1068-
print "IdP listening on %s:%s" % (HOST, PORT)
1068+
print("IdP listening on %s:%s" % (HOST, PORT))
10691069
SRV.serve_forever()

example/idp2/idp_uwsgi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ def application(environ, start_response):
10191019
PORT = CONFIG.PORT
10201020

10211021
SRV = make_server(HOST, PORT, application)
1022-
print "IdP listening on %s:%s" % (HOST, PORT)
1022+
print("IdP listening on %s:%s" % (HOST, PORT))
10231023
SRV.serve_forever()
10241024
else:
10251025
_rot = args.mako_root

example/idp2_repoze/idp.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,10 @@ def verify_request(self, query, binding):
269269
try:
270270
resp_args = IDP.response_args(_authn_req)
271271
_resp = None
272-
except UnknownPrincipal, excp:
272+
except UnknownPrincipal as excp:
273273
_resp = IDP.create_error_response(_authn_req.id,
274274
self.destination, excp)
275-
except UnsupportedBinding, excp:
275+
except UnsupportedBinding as excp:
276276
_resp = IDP.create_error_response(_authn_req.id,
277277
self.destination, excp)
278278

@@ -281,11 +281,11 @@ def verify_request(self, query, binding):
281281
def do(self, query, binding_in, relay_state=""):
282282
try:
283283
resp_args, _resp = self.verify_request(query, binding_in)
284-
except UnknownPrincipal, excp:
284+
except UnknownPrincipal as excp:
285285
logger.error("UnknownPrincipal: %s" % (excp,))
286286
resp = ServiceError("UnknownPrincipal: %s" % (excp,))
287287
return resp(self.environ, self.start_response)
288-
except UnsupportedBinding, excp:
288+
except UnsupportedBinding as excp:
289289
logger.error("UnsupportedBinding: %s" % (excp,))
290290
resp = ServiceError("UnsupportedBinding: %s" % (excp,))
291291
return resp(self.environ, self.start_response)
@@ -305,7 +305,7 @@ def do(self, query, binding_in, relay_state=""):
305305
identity, userid=self.user,
306306
authn=AUTHN_BROKER[self.environ["idp.authn_ref"]], sign_assertion=sign_assertion,
307307
sign_response=False, **resp_args)
308-
except Exception, excp:
308+
except Exception as excp:
309309
logging.error(exception_trace(excp))
310310
resp = ServiceError("Exception: %s" % (excp,))
311311
return resp(self.environ, self.start_response)
@@ -548,7 +548,7 @@ def do(self, request, binding, relay_state=""):
548548
_, body = request.split("\n")
549549
logger.debug("req: '%s'" % body)
550550
req_info = IDP.parse_logout_request(body, binding)
551-
except Exception, exc:
551+
except Exception as exc:
552552
logger.error("Bad request: %s" % exc)
553553
resp = BadRequest("%s" % exc)
554554
return resp(self.environ, self.start_response)
@@ -565,7 +565,7 @@ def do(self, request, binding, relay_state=""):
565565
# remove the authentication
566566
try:
567567
IDP.session_db.remove_authn_statements(msg.name_id)
568-
except KeyError, exc:
568+
except KeyError as exc:
569569
logger.error("ServiceError: %s" % exc)
570570
resp = ServiceError("%s" % exc)
571571
return resp(self.environ, self.start_response)
@@ -574,7 +574,7 @@ def do(self, request, binding, relay_state=""):
574574

575575
try:
576576
hinfo = IDP.apply_binding(binding, "%s" % resp, "", relay_state)
577-
except Exception, exc:
577+
except Exception as exc:
578578
logger.error("ServiceError: %s" % exc)
579579
resp = ServiceError("%s" % exc)
580580
return resp(self.environ, self.start_response)
@@ -986,7 +986,7 @@ def application(environ, start_response):
986986
PORT = 8088
987987

988988
SRV = make_server(HOST, PORT, application)
989-
print "IdP listening on %s:%s" % (HOST, PORT)
989+
print("IdP listening on %s:%s" % (HOST, PORT))
990990
SRV.serve_forever()
991991
else:
992992
_rot = args.mako_root

example/sp-repoze/sp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,5 +293,5 @@ def application(environ, start_response):
293293

294294
from wsgiref.simple_server import make_server
295295
srv = make_server(HOST, PORT, app_with_auth)
296-
print "SP listening on %s:%s" % (HOST, PORT)
296+
print("SP listening on %s:%s" % (HOST, PORT))
297297
srv.serve_forever()

example/sp-wsgi/sp.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
from __future__ import print_function
23
import logging
34
import re
45
import argparse
@@ -353,18 +354,18 @@ def do(self, response, binding, relay_state="", mtype="response"):
353354
try:
354355
self.response = self.sp.parse_authn_request_response(
355356
response, binding, self.outstanding_queries, self.cache.outstanding_certs)
356-
except UnknownPrincipal, excp:
357+
except UnknownPrincipal as excp:
357358
logger.error("UnknownPrincipal: %s" % (excp,))
358359
resp = ServiceError("UnknownPrincipal: %s" % (excp,))
359360
return resp(self.environ, self.start_response)
360-
except UnsupportedBinding, excp:
361+
except UnsupportedBinding as excp:
361362
logger.error("UnsupportedBinding: %s" % (excp,))
362363
resp = ServiceError("UnsupportedBinding: %s" % (excp,))
363364
return resp(self.environ, self.start_response)
364-
except VerificationError, err:
365+
except VerificationError as err:
365366
resp = ServiceError("Verification error: %s" % (err,))
366367
return resp(self.environ, self.start_response)
367-
except Exception, err:
368+
except Exception as err:
368369
resp = ServiceError("Other error: %s" % (err,))
369370
return resp(self.environ, self.start_response)
370371

@@ -580,7 +581,7 @@ def redirect_to_auth(self, _cli, entity_id, came_from):
580581
if cert is not None:
581582
self.cache.outstanding_certs[_sid] = cert
582583

583-
except Exception, exc:
584+
except Exception as exc:
584585
logger.exception(exc)
585586
resp = ServiceError(
586587
"Failed to construct the AuthnRequest: %s" % exc)
@@ -784,14 +785,14 @@ def application(environ, start_response):
784785
if re.match(".*static/.*", path):
785786
return handle_static(environ, start_response, path)
786787
return not_found(environ, start_response)
787-
except StatusError, err:
788+
except StatusError as err:
788789
logging.error("StatusError: %s" % err)
789790
resp = BadRequest("%s" % err)
790791
return resp(environ, start_response)
791-
except Exception, err:
792+
except Exception as err:
792793
#_err = exception_trace("RUN", err)
793794
#logging.error(exception_trace("RUN", _err))
794-
print >> sys.stderr, err
795+
print(err, file=sys.stderr)
795796
resp = ServiceError("%s" % err)
796797
return resp(environ, start_response)
797798

@@ -850,7 +851,7 @@ def application(environ, start_response):
850851
SERVER_KEY, CERT_CHAIN)
851852
_https = " using SSL/TLS"
852853
logger.info("Server starting")
853-
print "SP listening on %s:%s%s" % (HOST, PORT, _https)
854+
print("SP listening on %s:%s%s" % (HOST, PORT, _https))
854855
try:
855856
SRV.start()
856857
except KeyboardInterrupt:

script/filter_testcase_ids.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
import json, sys
88
jdata = json.load(sys.stdin)
99
for k in jdata:
10-
print k["id"]
10+
print(k["id"])

script/utility/filter_testcase_ids.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
import json, sys
88
jdata = json.load(sys.stdin)
99
for k in jdata:
10-
print k["id"]
10+
print(k["id"])

script/utility/run_list_of_tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55

66
for line in fileinput.input():
77
cmd = "./run_oper.sh " + line.rstrip()
8-
print "executing " + cmd
8+
print("executing " + cmd)
99
call(cmd, shell=True)
1010

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ def run_tests(self):
3131
'pytz',
3232
'pyOpenSSL',
3333
'python-dateutil',
34-
'argparse'
34+
'argparse',
35+
'six'
3536
]
3637

3738
tests_require = [

src/idp_test/__init__.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
from importlib import import_module
23
import json
34
import os
@@ -250,7 +251,7 @@ def output_log(self, memhndlr, hndlr2):
250251
"""
251252
"""
252253

253-
print >> sys.stderr, 80 * ":"
254+
print(80 * ":", file=sys.stderr)
254255
hndlr2.setFormatter(formatter_2)
255256
memhndlr.setTarget(hndlr2)
256257
memhndlr.flush()
@@ -288,8 +289,8 @@ def run(self):
288289

289290
try:
290291
self.setup()
291-
except (AttributeError, ToOld), err:
292-
print >> sys.stdout, "Configuration Error: %s" % err
292+
except (AttributeError, ToOld) as err:
293+
print("Configuration Error: %s" % err, file=sys.stderr)
293294

294295
self.client = Saml2Client(self.sp_config)
295296
conv = None
@@ -323,17 +324,17 @@ def run(self):
323324
self.test_log = conv.test_output
324325
tsum = self.test_summation(self.args.oper)
325326
err = None
326-
except CheckError, err:
327+
except CheckError as err:
327328
self.test_log = conv.test_output
328329
tsum = self.test_summation(self.args.oper)
329-
except FatalError, err:
330+
except FatalError as err:
330331
if conv:
331332
self.test_log = conv.test_output
332333
self.test_log.append(exception_trace("RUN", err))
333334
else:
334335
self.test_log = exception_trace("RUN", err)
335336
tsum = self.test_summation(self.args.oper)
336-
except Exception, err:
337+
except Exception as err:
337338
if conv:
338339
self.test_log = conv.test_output
339340
self.test_log.append(exception_trace("RUN", err))
@@ -344,7 +345,7 @@ def run(self):
344345
if pp:
345346
pp.pprint(tsum)
346347
else:
347-
print >> sys.stdout, json.dumps(tsum)
348+
print(json.dumps(tsum), file=sys.stdout)
348349

349350
if tsum["status"] > 1 or self.args.debug or err:
350351
self.output_log(memoryhandler, streamhandler)
@@ -391,21 +392,21 @@ def list_operations(self):
391392

392393
lista.append(item)
393394

394-
print json.dumps(lista)
395+
print(json.dumps(lista))
395396

396397
def _get_operation(self, operation):
397398
return self.operations.OPERATIONS[operation]
398399

399400
def make_meta(self):
400401
self.sp_configure(True)
401-
print entity_descriptor(self.sp_config)
402+
print(entity_descriptor(self.sp_config))
402403

403404
def list_conf_id(self):
404405
sys.path.insert(0, ".")
405406
mod = import_module("config")
406407
_res = dict([(key, cnf["description"]) for key, cnf in
407408
mod.CONFIG.items()])
408-
print json.dumps(_res)
409+
print(json.dumps(_res))
409410

410411
def verify_metadata(self):
411412
self.json_config = self.json_config_file()
@@ -421,4 +422,4 @@ def verify_metadata(self):
421422
chk = CheckSaml2IntMetaData()
422423
output = []
423424
res = chk(env, output)
424-
print >> sys.stdout, res
425+
print(res, file=sys.stdout)

0 commit comments

Comments
 (0)