adapt bits for py3 (#19613)

This commit is contained in:
Frédéric Péters 2020-04-18 15:39:34 +02:00
parent eab3baded6
commit 83c9a56a67
10 changed files with 19 additions and 17 deletions

View File

@ -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())

2
debian/settings.py vendored
View File

@ -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

View File

@ -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

View File

@ -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,):

View File

@ -13,18 +13,19 @@
#
# 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/>.
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__)

View File

@ -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

View File

@ -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())

View File

@ -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

View File

@ -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):

View File

@ -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 =