diff --git a/gunicorn/app/django_wsgi.py b/gunicorn/app/django_wsgi.py index cc617409..5722978c 100644 --- a/gunicorn/app/django_wsgi.py +++ b/gunicorn/app/django_wsgi.py @@ -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 diff --git a/gunicorn/app/djangoapp.py b/gunicorn/app/djangoapp.py index d4c5853c..1390cc6a 100644 --- a/gunicorn/app/djangoapp.py +++ b/gunicorn/app/djangoapp.py @@ -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, diff --git a/gunicorn/glogging.py b/gunicorn/glogging.py index 6685866f..3fa58f57 100644 --- a/gunicorn/glogging.py +++ b/gunicorn/glogging.py @@ -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): diff --git a/gunicorn/management/commands/run_gunicorn.py b/gunicorn/management/commands/run_gunicorn.py index 19239abd..47ef80c9 100644 --- a/gunicorn/management/commands/run_gunicorn.py +++ b/gunicorn/management/commands/run_gunicorn.py @@ -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 diff --git a/gunicorn/monkey.py b/gunicorn/monkey.py index 9050a8b3..d0e31d50 100644 --- a/gunicorn/monkey.py +++ b/gunicorn/monkey.py @@ -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 diff --git a/gunicorn/sock.py b/gunicorn/sock.py index a31e574a..9f0cc480 100644 --- a/gunicorn/sock.py +++ b/gunicorn/sock.py @@ -4,7 +4,6 @@ # See the NOTICE for more information. import errno -import logging import os import socket import sys diff --git a/gunicorn/workers/base.py b/gunicorn/workers/base.py index 19366826..e8260717 100644 --- a/gunicorn/workers/base.py +++ b/gunicorn/workers/base.py @@ -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 = "
Invalid Header '%s'
" % str(exc) elif isinstance(exc, LimitRequestLine): - msg = "%s
" % str(exc) + mesg = "%s
" % str(exc) elif isinstance(exc, LimitRequestHeaders): - msg = "Error parsing headers: '%s'
" % str(exc) + mesg = "Error parsing headers: '%s'
" % str(exc) if self.debug: tb = traceback.format_exc() diff --git a/gunicorn/workers/ggevent.py b/gunicorn/workers/ggevent.py index 6fc67228..827a66e6 100644 --- a/gunicorn/workers/ggevent.py +++ b/gunicorn/workers/ggevent.py @@ -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__)