本文整理汇总了Python中gunicorn.errors.ConfigError方法的典型用法代码示例。如果您正苦于以下问题:Python errors.ConfigError方法的具体用法?Python errors.ConfigError怎么用?Python errors.ConfigError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gunicorn.errors
的用法示例。
在下文中一共展示了errors.ConfigError方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: init
# 需要导入模块: from gunicorn import errors [as 别名]
# 或者: from gunicorn.errors import ConfigError [as 别名]
def init(self, parser, opts, args):
if opts.paste and opts.paste is not None:
app_name = 'main'
path = opts.paste
if '#' in path:
path, app_name = path.split('#')
path = os.path.abspath(os.path.normpath(
os.path.join(util.getcwd(), path)))
if not os.path.exists(path):
raise ConfigError("%r not found" % path)
# paste application, load the config
self.cfgurl = 'config:%s#%s' % (path, app_name)
self.relpath = os.path.dirname(path)
from .pasterapp import paste_config
return paste_config(self.cfg, self.cfgurl, self.relpath)
if len(args) < 1:
parser.error("No application module specified.")
self.cfg.set("default_proc_name", args[0])
self.app_uri = args[0]
示例2: validate_user
# 需要导入模块: from gunicorn import errors [as 别名]
# 或者: from gunicorn.errors import ConfigError [as 别名]
def validate_user(val):
if val is None:
return os.geteuid()
if isinstance(val, int):
return val
elif val.isdigit():
return int(val)
else:
try:
return pwd.getpwnam(val).pw_uid
except KeyError:
raise ConfigError("No such user: '%s'" % val)
示例3: validate_group
# 需要导入模块: from gunicorn import errors [as 别名]
# 或者: from gunicorn.errors import ConfigError [as 别名]
def validate_group(val):
if val is None:
return os.getegid()
if isinstance(val, int):
return val
elif val.isdigit():
return int(val)
else:
try:
return grp.getgrnam(val).gr_gid
except KeyError:
raise ConfigError("No such group: '%s'" % val)
示例4: validate_chdir
# 需要导入模块: from gunicorn import errors [as 别名]
# 或者: from gunicorn.errors import ConfigError [as 别名]
def validate_chdir(val):
# valid if the value is a string
val = validate_string(val)
# transform relative paths
path = os.path.abspath(os.path.normpath(os.path.join(util.getcwd(), val)))
# test if the path exists
if not os.path.exists(path):
raise ConfigError("can't chdir to %r" % val)
return path
示例5: validate_file
# 需要导入模块: from gunicorn import errors [as 别名]
# 或者: from gunicorn.errors import ConfigError [as 别名]
def validate_file(val):
if val is None:
return None
# valid if the value is a string
val = validate_string(val)
# transform relative paths
path = os.path.abspath(os.path.normpath(os.path.join(util.getcwd(), val)))
# test if the path exists
if not os.path.exists(path):
raise ConfigError("%r not found" % val)
return path
示例6: validate_reload_engine
# 需要导入模块: from gunicorn import errors [as 别名]
# 或者: from gunicorn.errors import ConfigError [as 别名]
def validate_reload_engine(val):
if val not in reloader_engines:
raise ConfigError("Invalid reload_engine: %r" % val)
return val