0001-python3-use-__future__.print_function-31140.patch
merge-coverage.py | ||
---|---|---|
1 | 1 |
#!/usr/bin/python |
2 |
from __future__ import print_function |
|
3 | ||
2 | 4 |
import sys |
3 | 5 |
import os |
4 | 6 |
import xml.etree.ElementTree as ET |
... | ... | |
59 | 61 |
xmlfiles.append (fullname) |
60 | 62 | |
61 | 63 |
if not xmlfiles: |
62 |
print 'No xml files found!'
|
|
64 |
print('No xml files found!')
|
|
63 | 65 |
sys.exit (1) |
64 | 66 | |
65 | 67 |
else: |
merge-junit-results.py | ||
---|---|---|
3 | 3 |
# Corey Goldberg, Dec 2012 |
4 | 4 |
# |
5 | 5 | |
6 |
from __future__ import print_function |
|
7 | ||
6 | 8 |
import os |
7 | 9 |
import sys |
8 | 10 |
import xml.etree.ElementTree as ET |
... | ... | |
55 | 57 | |
56 | 58 |
def usage(): |
57 | 59 |
this_file = os.path.basename(__file__) |
58 |
print 'Usage: %s results1.xml results2.xml' % this_file
|
|
60 |
print('Usage: %s results1.xml results2.xml' % this_file)
|
|
59 | 61 | |
60 | 62 | |
61 | 63 |
if __name__ == '__main__': |
src/authentic2/auth2_auth/auth2_ssl/README | ||
---|---|---|
37 | 37 |
try: |
38 | 38 |
import lasso |
39 | 39 |
except: |
40 |
print >> sys.stderr, "Unable to import Lasso."
|
|
40 |
print("Unable to import Lasso.", file=sys.stderr)
|
|
41 | 41 | |
42 | 42 |
apache_configuration= os.path.dirname(__file__) |
43 | 43 |
project = os.path.dirname(apache_configuration) |
... | ... | |
46 | 46 |
import authentic2.settings |
47 | 47 |
os.environ['DJANGO_SETTINGS_MODULE'] = 'authentic2.settings' |
48 | 48 |
except: |
49 |
print >> sys.stderr, "Unable to import settings."
|
|
49 |
print("Unable to import settings.", file=sys.stderr)
|
|
50 | 50 | |
51 | 51 |
import django.core.handlers.wsgi |
52 | 52 |
application = django.core.handlers.wsgi.WSGIHandler() |
src/authentic2/custom_user/management/commands/changepassword.py | ||
---|---|---|
1 |
from __future__ import unicode_literals |
|
1 |
from __future__ import unicode_literals, print_function
|
|
2 | 2 | |
3 | 3 |
import getpass |
4 | 4 | |
... | ... | |
42 | 42 |
raise CommandError("user '%s' does not exist" % username) |
43 | 43 |
except MultipleObjectsReturned: |
44 | 44 |
while True: |
45 |
print 'Select an user:'
|
|
45 |
print('Select a user:')
|
|
46 | 46 |
for i, user in enumerate(qs): |
47 |
print '%d.' % (i+1), user
|
|
48 |
print '> ',
|
|
47 |
print('%d.' % (i+1), user)
|
|
48 |
print('> ', end=' ')
|
|
49 | 49 |
try: |
50 | 50 |
j = input() |
51 | 51 |
except SyntaxError: |
52 |
print 'Please enter an integer'
|
|
52 |
print('Please enter an integer')
|
|
53 | 53 |
continue |
54 | 54 |
if not isinstance(uid, int): |
55 |
print 'Please enter an integer'
|
|
55 |
print('Please enter an integer')
|
|
56 | 56 |
continue |
57 | 57 |
try: |
58 | 58 |
u = qs[j-1] |
59 | 59 |
break |
60 | 60 |
except IndexError: |
61 |
print 'Please enter an integer between 1 and %d' % qs.count()
|
|
61 |
print('Please enter an integer between 1 and %d' % qs.count())
|
|
62 | 62 |
continue |
63 | 63 | |
64 | 64 |
self.stdout.write("Changing password for user '%s'\n" % u) |
src/authentic2/management/commands/clean-unused-accounts.py | ||
---|---|---|
1 |
from __future__ import print_function |
|
2 | ||
1 | 3 |
import logging |
2 | 4 |
import datetime |
3 | 5 | |
... | ... | |
16 | 18 |
for line in table: |
17 | 19 |
line = u"| " + u" | ".join(u"{0:>{1}}".format(x, col_width[i]) |
18 | 20 |
for i, x in enumerate(line)) + u" |" |
19 |
print line
|
|
21 |
print(line)
|
|
20 | 22 | |
21 | 23 |
class Command(BaseCommand): |
22 | 24 |
help = '''Clean unused accounts''' |
src/authentic2/management/commands/slapd-shell.py | ||
---|---|---|
1 |
from __future__ import print_function |
|
2 | ||
1 | 3 |
import logging |
2 | 4 |
import sys |
3 | 5 |
from StringIO import StringIO |
... | ... | |
38 | 40 |
if attrs['filter'] != '(objectClass=*)': |
39 | 41 |
m = re.match(r'\((\w*)=(.*)\)', attrs['filter']) |
40 | 42 |
if not m: |
41 |
print 'RESULT'
|
|
42 |
print 'code: 1'
|
|
43 |
print 'info: invalid filter'
|
|
44 |
|
|
43 |
print('RESULT')
|
|
44 |
print('code: 1')
|
|
45 |
print('info: invalid filter')
|
|
46 |
print()
|
|
45 | 47 |
return |
46 | 48 |
for user_attribute, ldap_attribute in MAPPING.iteritems(): |
47 | 49 |
if ldap_attribute == m.group(1): |
48 | 50 |
break |
49 | 51 |
else: |
50 |
print 'RESULT'
|
|
51 |
print 'code: 1'
|
|
52 |
print 'info: unknown attribute in filter'
|
|
53 |
|
|
52 |
print('RESULT')
|
|
53 |
print('code: 1')
|
|
54 |
print('info: unknown attribute in filter')
|
|
55 |
print()
|
|
54 | 56 |
return |
55 | 57 |
value = m.group(2) |
56 | 58 |
if value.endswith('*') and value.startswith('*'): |
... | ... | |
74 | 76 |
dn = 'uid=%s,%s' % (escape_dn_chars(o['uid'][0]), attrs['suffix']) |
75 | 77 |
self.logger.debug(u'sending entry %s %s', dn, o) |
76 | 78 |
ldif_writer.unparse(dn, o) |
77 |
print out.getvalue(),
|
|
79 |
print(out.getvalue())
|
|
78 | 80 |
out.close() |
79 |
print 'RESULT'
|
|
80 |
print 'code: 0'
|
|
81 |
print 'info: RockNRoll'
|
|
82 |
|
|
81 |
print('RESULT')
|
|
82 |
print('code: 0')
|
|
83 |
print('info: RockNRoll')
|
|
84 |
print()
|
|
83 | 85 | |
84 | 86 |
def handle(self, *args, **options): |
85 | 87 |
self.logger = logging.getLogger(__name__) |
src/authentic2/saml/management/commands/sync-metadata.py | ||
---|---|---|
1 |
from __future__ import print_function |
|
2 | ||
1 | 3 |
import sys |
2 | 4 |
import xml.etree.ElementTree as etree |
3 | 5 |
import os |
... | ... | |
127 | 129 |
attribute, created = SAMLAttribute.objects.get_or_create( |
128 | 130 |
defaults=defaults, **kwargs) |
129 | 131 |
if created and verbosity > 1: |
130 |
print _('Created new attribute %(name)s for %(provider)s') % \
|
|
131 |
{'name': oid, 'provider': provider} |
|
132 |
print(_('Created new attribute %(name)s for %(provider)s') % \
|
|
133 |
{'name': oid, 'provider': provider})
|
|
132 | 134 |
pks.append(attribute.pk) |
133 | 135 |
except SAMLAttribute.MultipleObjectsReturned: |
134 | 136 |
pks.extend(SAMLAttribute.objects.filter(**kwargs).values_list('pk', flat=True)) |
... | ... | |
159 | 161 |
sp = check_support_saml2(tree.find(SP_SSO_DESCRIPTOR_TN)) |
160 | 162 |
if options.get('delete'): |
161 | 163 |
LibertyProvider.objects.filter(entity_id=entity_id).delete() |
162 |
print 'Deleted', entity_id
|
|
164 |
print('Deleted', entity_id)
|
|
163 | 165 |
return |
164 | 166 |
if sp: |
165 | 167 |
# build an unique slug |
... | ... | |
177 | 179 |
what = 'Creating' |
178 | 180 |
else: |
179 | 181 |
what = 'Updating' |
180 |
print '%(what)s %(name)s, %(id)s' % {
|
|
181 |
'what': what, 'name': name.encode('utf8'), 'id': entity_id} |
|
182 |
print('%(what)s %(name)s, %(id)s' % {
|
|
183 |
'what': what, 'name': name.encode('utf8'), 'id': entity_id})
|
|
182 | 184 |
provider.name = name[:128] |
183 | 185 |
provider.metadata = etree.tostring(tree, encoding='utf-8').decode('utf-8').strip() |
184 | 186 |
provider.protocol_conformance = 3 |
... | ... | |
199 | 201 |
kwargs, defaults = build_saml_attribute_kwargs(provider, name) |
200 | 202 |
if not kwargs: |
201 | 203 |
if verbosity > 1: |
202 |
print >>sys.stderr, _('Unable to find an LDAP definition for attribute %(name)s on %(provider)s') % \
|
|
203 |
{'name': name, 'provider': provider} |
|
204 |
print(_('Unable to find an LDAP definition for attribute %(name)s on %(provider)s') % \
|
|
205 |
{'name': name, 'provider': provider}, file=sys.stderr)
|
|
204 | 206 |
continue |
205 | 207 |
# create object with default attribute mapping to the same name |
206 | 208 |
# as the attribute if no SAMLAttribute model already exists, |
... | ... | |
209 | 211 |
attribute, created = SAMLAttribute.objects.get_or_create( |
210 | 212 |
defaults=defaults, **kwargs) |
211 | 213 |
if created and verbosity > 1: |
212 |
print (_('Created new attribute %(name)s for %(provider)s')
|
|
214 |
print(_('Created new attribute %(name)s for %(provider)s') |
|
213 | 215 |
% {'name': name, 'provider': provider}) |
214 | 216 |
pks.append(attribute.pk) |
215 | 217 |
except SAMLAttribute.MultipleObjectsReturned: |
... | ... | |
331 | 333 |
try: |
332 | 334 |
sp_policy = SPOptionsIdPPolicy.objects.get(name=sp_policy_name) |
333 | 335 |
if verbosity > 1: |
334 |
print 'Service providers are set with the following SAML2 \
|
|
335 |
options policy: %s' % sp_policy |
|
336 |
print('Service providers are set with the following SAML2 \
|
|
337 |
options policy: %s' % sp_policy)
|
|
336 | 338 |
except: |
337 | 339 |
if verbosity > 0: |
338 |
print >>sys.stderr, _('SAML2 service provider options ' |
|
339 |
'policy with name %s not found') % sp_policy_name |
|
340 |
print(_('SAML2 service provider options ' |
|
341 |
'policy with name %s not found') % sp_policy_name, |
|
342 |
file=sys.stderr) |
|
340 | 343 |
raise CommandError() |
341 | 344 |
else: |
342 | 345 |
if verbosity > 1: |
343 |
print 'No SAML2 service provider options policy provided'
|
|
346 |
print('No SAML2 service provider options policy provided')
|
|
344 | 347 |
loaded = [] |
345 | 348 |
if doc.getroot().tag == ENTITY_DESCRIPTOR_TN: |
346 | 349 |
entity_descriptors = [doc.getroot()] |
... | ... | |
357 | 360 |
if not options['ignore-errors']: |
358 | 361 |
raise |
359 | 362 |
if verbosity > 0: |
360 |
print >>sys.stderr, (_('Failed to load entity descriptor for %s') |
|
361 |
% entity_descriptor.get(ENTITY_ID)) |
|
363 |
print((_('Failed to load entity descriptor for %s') |
|
364 |
% entity_descriptor.get(ENTITY_ID)), |
|
365 |
file=sys.stderr) |
|
362 | 366 |
raise CommandError() |
363 | 367 |
if options['source']: |
364 | 368 |
if options['delete']: |
365 |
print 'Finally delete all providers for source: %s...' % source
|
|
369 |
print('Finally delete all providers for source: %s...' % source)
|
|
366 | 370 |
LibertyProvider.objects.filter(federation_source=source).delete() |
367 | 371 |
else: |
368 | 372 |
to_delete = [] |
... | ... | |
371 | 375 |
to_delete.append(provider) |
372 | 376 |
for provider in to_delete: |
373 | 377 |
if verbosity > 1: |
374 |
print _('Deleted obsolete provider %s') % provider.entity_id
|
|
378 |
print(_('Deleted obsolete provider %s') % provider.entity_id)
|
|
375 | 379 |
provider.delete() |
376 | 380 |
else: |
377 | 381 |
raise CommandError('%s is not a SAMLv2 metadata file' % metadata_file) |
378 | 382 |
if not options.get('delete'): |
379 | 383 |
if verbosity > 1: |
380 |
print 'Loaded', options.get('count', 0), 'providers' |
|
384 |
print('Loaded', options.get('count', 0), 'providers') |
src/authentic2/saml/saml11utils.py | ||
---|---|---|
1 |
from __future__ import print_function |
|
2 | ||
1 | 3 |
import xml.etree.ElementTree as etree |
2 | 4 |
from authentic2.compat_lasso import lasso |
3 | 5 |
from authentic2.saml import x509utils |
... | ... | |
205 | 207 |
'SingleSignOn': (('sso',), sso_protocol_profiles), |
206 | 208 |
}, options) |
207 | 209 |
root = meta.root_element() |
208 |
print etree.tostring(root) |
|
210 |
print(etree.tostring(root)) |
src/authentic2/saml/saml2utils.py | ||
---|---|---|
1 |
from __future__ import print_function |
|
2 | ||
1 | 3 |
import xml.etree.ElementTree as etree |
2 | 4 |
import collections |
3 | 5 |
from authentic2.compat_lasso import lasso |
... | ... | |
435 | 437 |
[ lasso.SAML2_METADATA_BINDING_POST ], 'acs'),), |
436 | 438 |
options) |
437 | 439 |
root = meta.root_element() |
438 |
print etree.tostring(root) |
|
440 |
print(etree.tostring(root)) |
src/authentic2/saml/shibboleth/afp_parser.py | ||
---|---|---|
1 |
from __future__ import print_function |
|
2 | ||
1 | 3 |
import xml.etree.ElementTree as ET |
2 | 4 | |
3 | 5 |
from utils import FancyTreeBuilder |
... | ... | |
65 | 67 |
import sys |
66 | 68 | |
67 | 69 |
for key, values in parse_attribute_filters_file(sys.argv[1]).iteritems(): |
68 |
print '-', key, ':'
|
|
70 |
print('-', key, ':')
|
|
69 | 71 |
for value in values: |
70 |
print ' *', value |
|
72 |
print(' *', value) |
src/authentic2_auth_oidc/management/commands/oidc-register-issuer.py | ||
---|---|---|
1 |
from __future__ import print_function |
|
2 | ||
1 | 3 |
import json |
2 | 4 |
import pprint |
3 | 5 | |
... | ... | |
117 | 119 |
OIDCClaimMapping.objects.filter(provider=provider, claim__in=delete_claims) |
118 | 120 |
if options.get('show'): |
119 | 121 |
for field in OIDCProvider._meta.fields: |
120 |
print unicode(field.verbose_name), ':',
|
|
122 |
print(field.verbose_name, ':')
|
|
121 | 123 |
value = getattr(provider, field.name) |
122 | 124 |
if isinstance(value, dict): |
123 | 125 |
|
124 | 126 |
pprint.pprint(value) |
125 | 127 |
elif hasattr(provider, str('get_' + field.attname + '_display')): |
126 |
print getattr(provider, 'get_' + field.attname + '_display')(), '(%s)' % value
|
|
128 |
print(getattr(provider, 'get_' + field.attname + '_display')(), '(%s)' % value)
|
|
127 | 129 |
else: |
128 |
print value
|
|
129 |
print 'Mappings:'
|
|
130 |
print(value)
|
|
131 |
print('Mappings:')
|
|
130 | 132 |
for claim_mapping in provider.claim_mappings.all(): |
131 |
print '-', claim_mapping
|
|
133 |
print('-', claim_mapping)
|
|
132 | 134 |
src/authentic2_provisionning_ldap/management/commands/provision.py | ||
---|---|---|
1 |
from __future__ import print_function |
|
2 | ||
1 | 3 |
try: |
2 | 4 |
import ldap |
3 | 5 |
from ldap.dn import str2dn, dn2str |
... | ... | |
154 | 156 |
if not fake: |
155 | 157 |
conn.modify(dn, modlist) |
156 | 158 |
if verbosity > 1: |
157 |
print '- Replace %s values for %s' % (dn, ', '.join(ldap_attributes.keys()))
|
|
159 |
print('- Replace %s values for %s' % (dn, ', '.join(ldap_attributes.keys())))
|
|
158 | 160 |
else: |
159 | 161 |
if not fake: |
160 | 162 |
conn.add(dn, ldap.modlist.addModlist(ldap_attributes)) |
161 | 163 |
if verbosity > 1: |
162 |
print '- Add %s with values for %s' % (dn, ', '.join(ldap_attributes.keys()))
|
|
164 |
print('- Add %s with values for %s' % (dn, ', '.join(ldap_attributes.keys())))
|
|
163 | 165 |
# wait for results |
164 | 166 |
if not fake: |
165 | 167 |
for x in ldap_users: |
... | ... | |
174 | 176 |
todelete.add(dn) |
175 | 177 |
if delete: |
176 | 178 |
if verbosity > 1: |
177 |
print '- Deleting:', ', '.join(todelete)
|
|
179 |
print('- Deleting:', ', '.join(todelete))
|
|
178 | 180 |
if not fake: |
179 | 181 |
for dn in todelete: |
180 | 182 |
conn.delete(dn) |
src/django_rbac/management/commands/cleanup_rbac.py | ||
---|---|---|
1 |
from __future__ import print_function |
|
2 | ||
1 | 3 |
from django.core.management.base import BaseCommand |
2 | 4 | |
3 | 5 | |
... | ... | |
11 | 13 |
Permission = get_permission_model() |
12 | 14 |
count = Permission.objects.cleanup() |
13 | 15 |
if count: |
14 |
print 'Deleted %d permissions.' % count
|
|
16 |
print('Deleted %d permissions.' % count)
|
|
15 | 17 | |
16 | 18 |
Role = get_role_model() |
17 | 19 | |
18 | 20 |
count = 0 |
19 | 21 |
count = Role.objects.cleanup() |
20 | 22 |
if count: |
21 |
print 'Deleted %d roles.' % count |
|
23 |
print('Deleted %d roles.' % count) |
tests/test_api.py | ||
---|---|---|
1 | 1 |
# -*- coding: utf-8 -*- |
2 |
from __future__ import print_function |
|
2 | 3 | |
3 | 4 |
import json |
4 | 5 |
import pytest |
... | ... | |
775 | 776 | |
776 | 777 |
assert len(mailoutbox) == 1 |
777 | 778 |
mail = mailoutbox[0] |
778 |
print mail.to
|
|
779 |
print mail.body
|
|
779 |
print(mail.to)
|
|
780 |
print(mail.body)
|
|
780 | 781 | |
781 | 782 |
assert mail.to[0] == new_email |
782 | 783 |
assert 'http://testserver/accounts/change-email/verify/' in mail.body |
tests/test_crypto.py | ||
---|---|---|
1 |
from __future__ import print_function |
|
2 | ||
1 | 3 |
import random |
2 | 4 |
import uuid |
3 | 5 |
import time |
... | ... | |
43 | 45 |
crypted2 = crypto.aes_base64url_deterministic_encrypt(key, raw, salt, |
44 | 46 |
hash_name=hash_name, count=count) |
45 | 47 |
assert crypted1 == crypted2 |
46 |
print 'Crypted', hash_name, count, len(crypted1), crypted1
|
|
48 |
print('Crypted', hash_name, count, len(crypted1), crypted1)
|
|
47 | 49 | |
48 | 50 |
t = time.time() |
49 | 51 |
for i in range(100): |
50 | 52 |
crypted1 = crypto.aes_base64url_deterministic_encrypt(key, raw, salt, |
51 | 53 |
hash_name=hash_name, |
52 | 54 |
count=count) |
53 |
print 'Encryption time:', hash_name, count, (time.time() - t) / 100.0
|
|
55 |
print('Encryption time:', hash_name, count, (time.time() - t) / 100.0)
|
|
54 | 56 | |
55 | 57 |
t = time.time() |
56 | 58 |
for i in range(1000): |
57 | 59 |
assert crypto.aes_base64url_deterministic_decrypt(key, crypted1, salt, |
58 | 60 |
max_count=count) == raw |
59 |
print 'Decryption time:', hash_name, count, (time.time() - t) / 1000.0 |
|
61 |
print('Decryption time:', hash_name, count, (time.time() - t) / 1000.0) |
|
60 |
- |