diff --git a/debian/debian_config.py b/debian/debian_config.py index e149f82..43ffd36 100644 --- a/debian/debian_config.py +++ b/debian/debian_config.py @@ -1,4 +1,4 @@ -# This file is sourced by "execfile" from mandayejs.settings +# This file is sourced by "exec" from mandayejs.settings import os @@ -7,14 +7,14 @@ PROJECT_NAME = 'mandayejs' # # hobotization (multitenant) # -execfile('/usr/lib/hobo/debian_config_common.py') +exec(open('/usr/lib/hobo/debian_config_common.py').read()) TENANT_SETTINGS_LOADERS = ('hobo.multitenant.settings_loaders.MandayeJS',) + TENANT_SETTINGS_LOADERS # # local settings # -execfile(os.path.join(ETC_DIR, 'settings.py')) +exec(open(os.path.join(ETC_DIR, 'settings.py')).read()) # run additional settings snippets -execfile('/usr/lib/hobo/debian_config_settings_d.py') +exec(open('/usr/lib/hobo/debian_config_settings_d.py').read()) diff --git a/debian/settings.py b/debian/settings.py index 41dd9be..98ba05e 100644 --- a/debian/settings.py +++ b/debian/settings.py @@ -9,7 +9,7 @@ # WARNING! Quick-start development settings unsuitable for production! # See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ -# This file is sourced by "execfile" from /usr/lib/mandayejs/debian_config.py +# This file is sourced by "exec" from /usr/lib/mandayejs/debian_config.py # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False diff --git a/mandayejs/applications/__init__.py b/mandayejs/applications/__init__.py index 5337485..5fc02d5 100644 --- a/mandayejs/applications/__init__.py +++ b/mandayejs/applications/__init__.py @@ -134,6 +134,7 @@ class Test(AppSettings): SITE_AUTH_CHECKER = 'js/test/auth.checker.js' SITE_AUTH_COOKIE_KEYS = ['test'] SITE_FORCE_REDIRECT_URL = '/whatever' + SITE_FORM_SUBMIT_ELEMENT = None # Duonet App Settings diff --git a/mandayejs/mandaye/models.py b/mandayejs/mandaye/models.py index 0afca18..1a79788 100644 --- a/mandayejs/mandaye/models.py +++ b/mandayejs/mandaye/models.py @@ -22,6 +22,7 @@ from Crypto import Random from django.db import models from django.conf import settings from django.utils.translation import ugettext_lazy as _ +from django.utils.encoding import force_bytes from jsonfield import JSONField @@ -48,7 +49,7 @@ class UserCredentials(models.Model): def _get_cipher(self, iv): """Return cipher object """ - secret = sha256(settings.SECRET_KEY).digest() + secret = sha256(force_bytes(settings.SECRET_KEY)).digest() return AES.new(secret, AES.MODE_CFB, iv) def encrypt(self,): diff --git a/mandayejs/mandaye/utils.py b/mandayejs/mandaye/utils.py index 9d51f7a..8695f3b 100644 --- a/mandayejs/mandaye/utils.py +++ b/mandayejs/mandaye/utils.py @@ -13,18 +13,19 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . + import os import re import json import subprocess import logging import multiprocessing -import urlparse from django.conf import settings +from django.http import SimpleCookie from django.shortcuts import resolve_url +from django.utils.six.moves.urllib import parse as urlparse -from Cookie import SimpleCookie logger = logging.getLogger(__name__) diff --git a/mandayejs/mandaye/views.py b/mandayejs/mandaye/views.py index 9555222..9cd268d 100644 --- a/mandayejs/mandaye/views.py +++ b/mandayejs/mandaye/views.py @@ -17,7 +17,6 @@ from __future__ import absolute_import import logging -import urlparse from django.contrib.auth.models import User from django.contrib.auth.decorators import login_required @@ -29,6 +28,7 @@ from django.shortcuts import render, resolve_url from django.template import RequestContext from django.views.generic.base import TemplateView from django.views.decorators.csrf import csrf_exempt +from django.utils.six.moves.urllib import parse as urlparse from django.utils.translation import ugettext_lazy as _ from django.template import Template diff --git a/mandayejs/settings.py b/mandayejs/settings.py index fe9638d..181f9ac 100644 --- a/mandayejs/settings.py +++ b/mandayejs/settings.py @@ -199,4 +199,4 @@ os.environ['QT_QPA_FONTDIR'] = '/usr/share/fonts' local_settings_file = os.environ.get('MANDAYEJS_SETTINGS_FILE', os.path.join(os.path.dirname(__file__), 'local_settings.py')) if os.path.exists(local_settings_file): - execfile(local_settings_file) + exec(open(local_settings_file).read()) diff --git a/tests/test_api.py b/tests/test_api.py index 63a68d5..e8a386c 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -27,13 +27,13 @@ def test_api_get(client, url): def test_signed_api_get(client_service, url_signed): response = client_service.get(url_signed.url) if url_signed.orig == 'testserver': - status_code = 200 + status_codes = (200,) else: - status_code = 403 + status_codes = (401, 403) - assert response.status_code == status_code + assert response.status_code in status_codes - if status_code == 200: + if response.status_code == 200: assert {'login': '', 'password': ''} == response.data diff --git a/tests/test_archimed.py b/tests/test_archimed.py index d28a4dd..8074cf1 100644 --- a/tests/test_archimed.py +++ b/tests/test_archimed.py @@ -13,7 +13,7 @@ pytestmark = pytest.mark.django_db def get_base_dir(filename): - return file(os.path.join(os.path.dirname(__file__), 'data', filename)).read() + return open(os.path.join(os.path.dirname(__file__), 'data', filename)).read() class MokcedRequestsResponse(mock.Mock): diff --git a/tox.ini b/tox.ini index 29a5a1a..5f98a88 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,8 @@ [tox] -envlist = coverage-django111-pylint +envlist = py2-coverage-django111-pylint,py3-django111 toxworkdir = {env:TMPDIR:/tmp}/tox-{env:USER}/mandayejs/ [testenv] -basepython = python2 usedevelop = coverage: True setenv =