py3ize obviously non-compatible code (#32866)
This commit is contained in:
parent
0077218685
commit
2746d095c5
17
setup.py
17
setup.py
|
@ -15,6 +15,8 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
|
@ -50,10 +52,10 @@ class compile_translations(Command):
|
||||||
call_command('compilemessages')
|
call_command('compilemessages')
|
||||||
os.chdir(curdir)
|
os.chdir(curdir)
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print
|
print()
|
||||||
sys.stderr.write('!!! Please install Django >= 1.4 to build translations')
|
sys.stderr.write('!!! Please install Django >= 1.4 to build translations')
|
||||||
print
|
print()
|
||||||
print
|
print()
|
||||||
os.chdir(curdir)
|
os.chdir(curdir)
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,7 +66,7 @@ class build(_build):
|
||||||
class eo_sdist(sdist):
|
class eo_sdist(sdist):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
print "creating VERSION file"
|
print("creating VERSION file")
|
||||||
if os.path.exists('VERSION'):
|
if os.path.exists('VERSION'):
|
||||||
os.remove('VERSION')
|
os.remove('VERSION')
|
||||||
version = get_version()
|
version = get_version()
|
||||||
|
@ -72,7 +74,7 @@ class eo_sdist(sdist):
|
||||||
version_file.write(version)
|
version_file.write(version)
|
||||||
version_file.close()
|
version_file.close()
|
||||||
sdist.run(self)
|
sdist.run(self)
|
||||||
print "removing VERSION file"
|
print("removing VERSION file")
|
||||||
if os.path.exists('VERSION'):
|
if os.path.exists('VERSION'):
|
||||||
os.remove('VERSION')
|
os.remove('VERSION')
|
||||||
|
|
||||||
|
@ -108,9 +110,8 @@ def get_version():
|
||||||
['git', 'rev-list', 'HEAD']).splitlines())
|
['git', 'rev-list', 'HEAD']).splitlines())
|
||||||
return '0.0'
|
return '0.0'
|
||||||
|
|
||||||
README = file(os.path.join(
|
with open(os.path.join(os.path.dirname(__file__), 'README')) as fd:
|
||||||
os.path.dirname(__file__),
|
README = fd.read()
|
||||||
'README')).read()
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='authentic2-auth-fc',
|
name='authentic2-auth-fc',
|
||||||
|
|
|
@ -40,7 +40,7 @@ def build_logout_url(request, next_url=None):
|
||||||
"""
|
"""
|
||||||
if not next_url:
|
if not next_url:
|
||||||
next_url = resolve_url(settings.LOGIN_REDIRECT_URL)
|
next_url = resolve_url(settings.LOGIN_REDIRECT_URL)
|
||||||
state = unicode(uuid.uuid4())
|
state = str(uuid.uuid4())
|
||||||
states = request.session.setdefault('fc_states', {})
|
states = request.session.setdefault('fc_states', {})
|
||||||
request.session.modified = True
|
request.session.modified = True
|
||||||
states[state] = {
|
states[state] = {
|
||||||
|
@ -93,7 +93,7 @@ def mapping_to_value(mapping, user_info):
|
||||||
if mapping['compute'] == 'today':
|
if mapping['compute'] == 'today':
|
||||||
value = datetime.date.today()
|
value = datetime.date.today()
|
||||||
elif mapping['compute'] == 'random':
|
elif mapping['compute'] == 'random':
|
||||||
value = unicode(uuid.uuid4())
|
value = str(uuid.uuid4())
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
@ -151,8 +151,8 @@ def apply_user_info_mappings(user, user_info):
|
||||||
save_user = False
|
save_user = False
|
||||||
tags = set()
|
tags = set()
|
||||||
for attribute, mapping in mappings.iteritems():
|
for attribute, mapping in mappings.iteritems():
|
||||||
# normalize mapping to dictionaries
|
# normalize mapping to dictionaries: if string, convert into a simple reference
|
||||||
if isinstance(mapping, basestring):
|
if hasattr(mapping, 'format'):
|
||||||
mapping = {'ref': mapping}
|
mapping = {'ref': mapping}
|
||||||
try:
|
try:
|
||||||
value = mapping_to_value(mapping, user_info)
|
value = mapping_to_value(mapping, user_info)
|
||||||
|
|
|
@ -72,7 +72,7 @@ def ask_authorization(request, scopes, logger):
|
||||||
if not isinstance(scopes, (list, tuple)):
|
if not isinstance(scopes, (list, tuple)):
|
||||||
scopes = [scopes]
|
scopes = [scopes]
|
||||||
redirect_uri = request.build_absolute_uri()
|
redirect_uri = request.build_absolute_uri()
|
||||||
state = unicode(uuid.uuid4())
|
state = str(uuid.uuid4())
|
||||||
states = request.session.setdefault('fc_states', {})
|
states = request.session.setdefault('fc_states', {})
|
||||||
states[state] = {
|
states[state] = {
|
||||||
'redirect_uri': redirect_uri,
|
'redirect_uri': redirect_uri,
|
||||||
|
@ -274,7 +274,8 @@ class FcOAuthSessionViewMixin(LoggerMixin):
|
||||||
messages.warning(request, _('Unable to connect to FranceConnect.'))
|
messages.warning(request, _('Unable to connect to FranceConnect.'))
|
||||||
return self.redirect(request)
|
return self.redirect(request)
|
||||||
key = app_settings.client_secret
|
key = app_settings.client_secret
|
||||||
if isinstance(key, unicode):
|
# duck-type unicode/Py3 strings
|
||||||
|
if hasattr(key, 'isdecimal'):
|
||||||
key = key.encode('utf-8')
|
key = key.encode('utf-8')
|
||||||
self.id_token, error = models.parse_id_token(
|
self.id_token, error = models.parse_id_token(
|
||||||
self.token['id_token'], client_id=app_settings.client_id, client_secret=key)
|
self.token['id_token'], client_id=app_settings.client_id, client_secret=key)
|
||||||
|
|
Reference in New Issue