mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
pyflakes pass.
This commit is contained in:
parent
52a9e2e9a2
commit
fa341c6531
@ -5,7 +5,6 @@
|
||||
|
||||
""" module used to build the django wsgi application """
|
||||
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
@ -16,10 +15,9 @@ except ImportError:
|
||||
from StringIO import StringIO
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.management.base import CommandError
|
||||
from django.core.management.validation import get_validation_errors
|
||||
from django.utils import translation
|
||||
from django.core.servers.basehttp import AdminMediaHandler, WSGIServerException
|
||||
from django.core.servers.basehttp import AdminMediaHandler
|
||||
try:
|
||||
from django.core.servers.basehttp import get_internal_wsgi_application
|
||||
django14 = True
|
||||
|
||||
@ -3,11 +3,9 @@
|
||||
# This file is part of gunicorn released under the MIT license.
|
||||
# See the NOTICE for more information.
|
||||
|
||||
import imp
|
||||
import os
|
||||
import sys
|
||||
|
||||
from gunicorn.config import Config
|
||||
from gunicorn.app.base import Application
|
||||
from gunicorn import util
|
||||
|
||||
@ -27,8 +25,8 @@ def find_settings_module(path):
|
||||
if lvl > 2:
|
||||
break
|
||||
elif os.path.isfile(path):
|
||||
project_path = os.path.dirname(settings_path)
|
||||
settings_name, _ = os.path.splitext(os.path.basename(settings_path))
|
||||
project_path = os.path.dirname(path)
|
||||
settings_name, _ = os.path.splitext(os.path.basename(path))
|
||||
|
||||
return project_path, settings_name
|
||||
|
||||
@ -43,16 +41,17 @@ def make_default_env(cfg):
|
||||
sys.path.insert(0, pythonpath)
|
||||
|
||||
try:
|
||||
settings_modname = os.environ['DJANGO_SETTINGS_MODULE']
|
||||
_ = os.environ['DJANGO_SETTINGS_MODULE']
|
||||
except KeyError:
|
||||
# not settings env set, try to build one.
|
||||
project_path, settings_name = find_settings_module(os.getcwd())
|
||||
|
||||
if not project_path:
|
||||
raise RunTimeError("django project not found")
|
||||
raise RuntimeError("django project not found")
|
||||
|
||||
pythonpath, project_name = os.path.split(project_path)
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = "%s.settings" % project_name
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = "%s.%s" % (project_name,
|
||||
settings_name)
|
||||
if pythonpath not in sys.path:
|
||||
sys.path.insert(0, pythonpath)
|
||||
|
||||
@ -72,7 +71,7 @@ class DjangoApplication(Application):
|
||||
os.path.abspath(args[0]))
|
||||
|
||||
if not project_path:
|
||||
raise RunTimeError("django project not found")
|
||||
raise RuntimeError("django project not found")
|
||||
|
||||
pythonpath, project_name = os.path.split(project_path)
|
||||
self.cfg.set("django_settings", "%s.%s" % (project_name,
|
||||
|
||||
@ -103,7 +103,7 @@ class Logger(object):
|
||||
if os.path.exists(cfg.logconfig):
|
||||
fileConfig(cfg.logconfig)
|
||||
else:
|
||||
raise RuntimeError("Error: log config '%s' not found" % path)
|
||||
raise RuntimeError("Error: log config '%s' not found" % cfg.logconfig)
|
||||
|
||||
|
||||
def critical(self, msg, *args, **kwargs):
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
# See the NOTICE for more information.
|
||||
|
||||
from optparse import make_option
|
||||
import sys
|
||||
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
|
||||
|
||||
@ -11,7 +11,6 @@ def patch_django():
|
||||
"""
|
||||
|
||||
try:
|
||||
from django.db import DEFAULT_DB_ALIAS
|
||||
from django.db.backends import BaseDatabaseWrapper, DatabaseError
|
||||
|
||||
if "validate_thread_sharing" in BaseDatabaseWrapper.__dict__:
|
||||
@ -36,6 +35,6 @@ def patch_django():
|
||||
BaseDatabaseWrapper.__init__ = _init
|
||||
BaseDatabaseWrapper.validate_thread_sharing = _validate_thread_sharing
|
||||
|
||||
except ImportError, e:
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
# See the NOTICE for more information.
|
||||
|
||||
import errno
|
||||
import logging
|
||||
import os
|
||||
import socket
|
||||
import sys
|
||||
|
||||
@ -3,8 +3,6 @@
|
||||
# This file is part of gunicorn released under the MIT license.
|
||||
# See the NOTICE for more information.
|
||||
|
||||
|
||||
import logging
|
||||
import os
|
||||
import signal
|
||||
import sys
|
||||
@ -149,9 +147,9 @@ class Worker(object):
|
||||
elif isinstance(exc, (InvalidHeaderName, InvalidHeader,)):
|
||||
mesg = "<p>Invalid Header '%s'</p>" % str(exc)
|
||||
elif isinstance(exc, LimitRequestLine):
|
||||
msg = "<p>%s</p>" % str(exc)
|
||||
mesg = "<p>%s</p>" % str(exc)
|
||||
elif isinstance(exc, LimitRequestHeaders):
|
||||
msg = "<p>Error parsing headers: '%s'</p>" % str(exc)
|
||||
mesg = "<p>Error parsing headers: '%s'</p>" % str(exc)
|
||||
|
||||
if self.debug:
|
||||
tb = traceback.format_exc()
|
||||
|
||||
@ -24,7 +24,6 @@ from gevent import pywsgi
|
||||
import gunicorn
|
||||
from gunicorn.monkey import patch_django
|
||||
from gunicorn.workers.async import AsyncWorker
|
||||
from gunicorn.workers.base import Worker
|
||||
|
||||
VERSION = "gevent/%s gunicorn/%s" % (gevent.__version__, gunicorn.__version__)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user