mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
Merge pull request #894 from collinanderson/printstderr
sys.stderr.write -> print(msg, file=sys.stderr)
This commit is contained in:
commit
e0b3c42dd2
@ -2,6 +2,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.
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -34,7 +35,7 @@ class BaseApplication(object):
|
|||||||
self.load_default_config()
|
self.load_default_config()
|
||||||
self.load_config()
|
self.load_config()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
sys.stderr.write("\nError: %s\n" % str(e))
|
print("\nError: %s" % str(e), file=sys.stderr)
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
@ -70,7 +71,7 @@ class BaseApplication(object):
|
|||||||
try:
|
try:
|
||||||
Arbiter(self).run()
|
Arbiter(self).run()
|
||||||
except RuntimeError as e:
|
except RuntimeError as e:
|
||||||
sys.stderr.write("\nError: %s\n\n" % e)
|
print("\nError: %s\n" % e, file=sys.stderr)
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
@ -91,8 +92,9 @@ class Application(BaseApplication):
|
|||||||
try:
|
try:
|
||||||
execfile_(filename, cfg, cfg)
|
execfile_(filename, cfg, cfg)
|
||||||
except Exception:
|
except Exception:
|
||||||
print("Failed to read config file: %s" % filename)
|
print("Failed to read config file: %s" % filename, file=sys.stderr)
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
sys.stderr.flush()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
return cfg
|
return cfg
|
||||||
@ -118,7 +120,8 @@ class Application(BaseApplication):
|
|||||||
try:
|
try:
|
||||||
self.cfg.set(k.lower(), v)
|
self.cfg.set(k.lower(), v)
|
||||||
except:
|
except:
|
||||||
sys.stderr.write("Invalid value for %s: %s\n\n" % (k, v))
|
print("Invalid value for %s: %s\n" % (k, v), file=sys.stderr)
|
||||||
|
sys.stderr.flush()
|
||||||
raise
|
raise
|
||||||
|
|
||||||
return cfg
|
return cfg
|
||||||
@ -162,7 +165,8 @@ class Application(BaseApplication):
|
|||||||
try:
|
try:
|
||||||
self.load()
|
self.load()
|
||||||
except:
|
except:
|
||||||
sys.stderr.write("\nError while loading the application:\n\n")
|
msg = "\nError while loading the application:\n"
|
||||||
|
print(msg, file=sys.stderr)
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
# See the NOTICE for more information.
|
# See the NOTICE for more information.
|
||||||
|
|
||||||
""" module used to build the django wsgi application """
|
""" module used to build the django wsgi application """
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -36,9 +37,9 @@ def make_wsgi_application():
|
|||||||
if get_validation_errors(s):
|
if get_validation_errors(s):
|
||||||
s.seek(0)
|
s.seek(0)
|
||||||
error = s.read()
|
error = s.read()
|
||||||
sys.stderr.write("One or more models did not validate:\n%s" % error)
|
msg = "One or more models did not validate:\n%s" % error
|
||||||
|
print(msg, file=sys.stderr)
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
translation.activate(settings.LANGUAGE_CODE)
|
translation.activate(settings.LANGUAGE_CODE)
|
||||||
|
|||||||
@ -2,6 +2,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.
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
@ -155,7 +156,7 @@ class PasterServerApplication(PasterBaseApplication):
|
|||||||
if k.lower() in self.cfg.settings and v is not None:
|
if k.lower() in self.cfg.settings and v is not None:
|
||||||
self.cfg.set(k.lower(), v)
|
self.cfg.set(k.lower(), v)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
sys.stderr.write("\nConfig error: %s\n" % str(e))
|
print("\nConfig error: %s" % str(e), file=sys.stderr)
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,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.
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import errno
|
import errno
|
||||||
import os
|
import os
|
||||||
@ -520,8 +521,7 @@ class Arbiter(object):
|
|||||||
except AppImportError as e:
|
except AppImportError as e:
|
||||||
self.log.debug("Exception while loading the application: \n%s",
|
self.log.debug("Exception while loading the application: \n%s",
|
||||||
traceback.format_exc())
|
traceback.format_exc())
|
||||||
|
print("%s" % e, file=sys.stderr)
|
||||||
sys.stderr.write("%s\n" % e)
|
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
sys.exit(self.APP_LOAD_ERROR)
|
sys.exit(self.APP_LOAD_ERROR)
|
||||||
except:
|
except:
|
||||||
|
|||||||
@ -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.
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import email.utils
|
import email.utils
|
||||||
import fcntl
|
import fcntl
|
||||||
@ -520,13 +521,13 @@ def is_fileobject(obj):
|
|||||||
|
|
||||||
|
|
||||||
def warn(msg):
|
def warn(msg):
|
||||||
sys.stderr.write("!!!\n")
|
print("!!!", file=sys.stderr)
|
||||||
|
|
||||||
lines = msg.splitlines()
|
lines = msg.splitlines()
|
||||||
for i, line in enumerate(lines):
|
for i, line in enumerate(lines):
|
||||||
if i == 0:
|
if i == 0:
|
||||||
line = "WARNING: %s" % line
|
line = "WARNING: %s" % line
|
||||||
sys.stderr.write("!!! %s\n" % line)
|
print("!!! %s" % line, file=sys.stderr)
|
||||||
|
|
||||||
sys.stderr.write("!!!\n\n")
|
print("!!!\n", file=sys.stderr)
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user