mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
put back configuration file without py extension and deprecate it
this change put back (and fix it) support of configuration files without ython extension and warn about its usage.
This commit is contained in:
parent
9538358511
commit
9a3e008eca
@ -3,6 +3,7 @@
|
|||||||
# This file is part of gunicorn released under the MIT license.
|
# This file is part of gunicorn released under the MIT license.
|
||||||
# See the NOTICE for more information.
|
# See the NOTICE for more information.
|
||||||
import importlib.util
|
import importlib.util
|
||||||
|
import importlib.machinery
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
@ -94,9 +95,17 @@ class Application(BaseApplication):
|
|||||||
if not os.path.exists(filename):
|
if not os.path.exists(filename):
|
||||||
raise RuntimeError("%r doesn't exist" % filename)
|
raise RuntimeError("%r doesn't exist" % filename)
|
||||||
|
|
||||||
|
ext = os.path.splitext(filename)[1]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
module_name = '__config__'
|
module_name = '__config__'
|
||||||
spec = importlib.util.spec_from_file_location(module_name, filename)
|
if ext in [".py", ".pyc"]:
|
||||||
|
spec = importlib.util.spec_from_file_location(module_name, filename)
|
||||||
|
else:
|
||||||
|
msg = "configuration file should have a valid Python extension.\n"
|
||||||
|
util.warn(msg)
|
||||||
|
loader_ = importlib.machinery.SourceFileLoader(module_name, filename)
|
||||||
|
spec = importlib.util.spec_from_file_location(module_name, filename, loader=loader_)
|
||||||
mod = importlib.util.module_from_spec(spec)
|
mod = importlib.util.module_from_spec(spec)
|
||||||
sys.modules[module_name] = mod
|
sys.modules[module_name] = mod
|
||||||
spec.loader.exec_module(mod)
|
spec.loader.exec_module(mod)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user