mirror of
https://github.com/ansible/awx.git
synced 2026-05-12 20:07:37 -02:30
convert py2 -> py3
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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 = ''
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user