convert py2 -> py3

This commit is contained in:
Ryan Petrello
2018-10-22 12:58:42 -04:00
parent f132ce9b64
commit f223df303f
202 changed files with 1137 additions and 2046 deletions

View File

@@ -40,7 +40,7 @@ def IS_TESTING(argv=None):
if "pytest" in sys.modules:
import mock
from unittest import mock
with mock.patch('__main__.__builtins__.dir', return_value=[]):
import ldap
else:

View File

@@ -19,7 +19,7 @@ import mimetypes
from split_settings.tools import optional, include
# Load default settings.
from defaults import * # NOQA
from .defaults import * # NOQA
# don't use memcache when running tests
if "pytest" in sys.modules:

View File

@@ -12,39 +12,9 @@
# MISC PROJECT SETTINGS
###############################################################################
import os
import urllib
import urllib.parse
import sys
def patch_broken_pipe_error():
"""Monkey Patch BaseServer.handle_error to not write
a stacktrace to stderr on broken pipe.
http://stackoverflow.com/a/22618740/362702"""
import sys
from SocketServer import BaseServer
from wsgiref import handlers
handle_error = BaseServer.handle_error
log_exception = handlers.BaseHandler.log_exception
def is_broken_pipe_error():
type, err, tb = sys.exc_info()
return "Connection reset by peer" in repr(err)
def my_handle_error(self, request, client_address):
if not is_broken_pipe_error():
handle_error(self, request, client_address)
def my_log_exception(self, exc_info):
if not is_broken_pipe_error():
log_exception(self, exc_info)
BaseServer.handle_error = my_handle_error
handlers.BaseHandler.log_exception = my_log_exception
patch_broken_pipe_error()
ADMINS = (
# ('Your Name', 'your_email@domain.com'),
)
@@ -83,7 +53,7 @@ if "pytest" in sys.modules:
BROKER_URL = "amqp://{}:{}@{}/{}".format(os.environ.get("RABBITMQ_USER"),
os.environ.get("RABBITMQ_PASS"),
os.environ.get("RABBITMQ_HOST"),
urllib.quote(os.environ.get("RABBITMQ_VHOST", "/"), safe=''))
urllib.parse.quote(os.environ.get("RABBITMQ_VHOST", "/"), safe=''))
CHANNEL_LAYERS = {
'default': {'BACKEND': 'asgi_amqp.AMQPChannelLayer',
@@ -236,7 +206,7 @@ LOGGING['handlers']['management_playbooks'] = {'class': 'logging.NullHandler'}
try:
path = os.path.expanduser(os.path.expandvars('~/.ssh/id_rsa'))
TEST_SSH_KEY_DATA = file(path, 'rb').read()
TEST_SSH_KEY_DATA = open(path, 'rb').read()
except IOError:
TEST_SSH_KEY_DATA = ''

View File

@@ -14,7 +14,7 @@ import traceback
from split_settings.tools import optional, include
# Load default settings.
from defaults import * # NOQA
from .defaults import * # NOQA
DEBUG = False
TEMPLATE_DEBUG = DEBUG
@@ -95,7 +95,7 @@ except IOError:
try:
e = None
open(settings_file)
except IOError as e:
except IOError:
pass
if e and e.errno == errno.EACCES:
SECRET_KEY = 'permission-denied'