mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
test first with args if any then use the default. While I'm here remove
caps that was hurting my eyes.
This commit is contained in:
parent
f2274ca23b
commit
b0250cbb5e
@ -181,24 +181,27 @@ def run_django():
|
|||||||
def get_app(parser, opts, args):
|
def get_app(parser, opts, args):
|
||||||
import django.core.handlers.wsgi
|
import django.core.handlers.wsgi
|
||||||
|
|
||||||
PROJECT_PATH = os.getcwd()
|
project_path = os.getcwd()
|
||||||
settings_path = os.path.join(PROJECT_PATH, "settings.py")
|
|
||||||
if not os.path.isfile(settings_path) and not args:
|
if args:
|
||||||
settings_notfound(settings_path)
|
|
||||||
else:
|
|
||||||
settings_path = os.path.abspath(os.path.normpath(args[0]))
|
settings_path = os.path.abspath(os.path.normpath(args[0]))
|
||||||
if not os.path.isfile(settings_path):
|
if not os.path.isfile(settings_path):
|
||||||
settings_notfound(settings_path)
|
settings_notfound(settings_path)
|
||||||
else:
|
else:
|
||||||
PROJECT_PATH = os.path.dirname(settings_path)
|
project_path = os.path.dirname(settings_path)
|
||||||
|
else:
|
||||||
|
settings_path = os.path.join(project_path, "settings.py")
|
||||||
|
if not os.path.isfile(settings_path):
|
||||||
|
settings_notfound(settings_path)
|
||||||
|
|
||||||
|
|
||||||
PROJECT_NAME = os.path.split(PROJECT_PATH)[-1]
|
project_name = os.path.split(project_path)[-1]
|
||||||
|
|
||||||
sys.path.insert(0, PROJECT_PATH)
|
sys.path.insert(0, project_path)
|
||||||
sys.path.append(os.path.join(PROJECT_PATH, os.pardir))
|
sys.path.append(os.path.join(project_path, os.pardir))
|
||||||
|
|
||||||
# set environ
|
# set environ
|
||||||
os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings' % PROJECT_NAME
|
os.environ['DJANGO_SETTINGS_MODULE'] = '%s.settings' % project_name
|
||||||
|
|
||||||
# django wsgi app
|
# django wsgi app
|
||||||
return django.core.handlers.wsgi.WSGIHandler()
|
return django.core.handlers.wsgi.WSGIHandler()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user