コード例 #1
0
    def init(self, parser, opts, args):
        # PasteDeploy config file
        if opts.paste:
            from .pasterapp import has_logging_config

            config_uri = os.path.abspath(opts.paste)
            config_file = config_uri.split('#')[0]

            if not os.path.exists(config_file):
                raise ConfigError("%r not found" % config_file)

            self.cfg.set("default_proc_name", config_file)
            self.app_uri = config_uri

            if has_logging_config(config_file):
                self.cfg.set("logconfig", config_file)

            return

        if not args:
            parser.error("No application module specified.")

        # ``args[0]`` 如: ``app.wsgi:app``
        self.cfg.set("default_proc_name", args[0])
        self.app_uri = args[0]
コード例 #2
0
    def init(self, parser, opts, args):
        if opts.paste:
            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]
コード例 #3
0
ファイル: wsgiapp.py プロジェクト: viplavdube/Car-Yard-App
    def load_config(self):
        super().load_config()

        if self.app_uri is None:
            if self.cfg.wsgi_app is not None:
                self.app_uri = self.cfg.wsgi_app
            else:
                raise ConfigError("No application module specified.")
コード例 #4
0
ファイル: config.py プロジェクト: teazj/gunicorn
def validate_reloader(val):
    if val is None:
        val = 'default'

    choices = ['poll', 'inotify', 'default']

    if val not in choices:
        raise ConfigError('Invalid reloader type. Must be one of: %s' %
                          choices)
コード例 #5
0
def validate_reloader(val):
    if val is None:
        val = 'auto'

    choices = ['auto', 'poll', 'inotify', 'off']

    if val not in choices:
        raise ConfigError('Invalid reloader type. Must be one of: %s' %
                          choices)

    return val
コード例 #6
0
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
コード例 #7
0
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: '******'" % val)
コード例 #8
0
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)
コード例 #9
0
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
コード例 #10
0
ファイル: config.py プロジェクト: xgenvn/API-Hour
def validate_config_dir(val):
    if val is None:
        return val
    else:
        # 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 find a config directory in %r" % val)

        return path
コード例 #11
0
    def init(self, parser, opts, args):
        if opts.paste and opts.paste is not None:
            path = os.path.abspath(
                os.path.normpath(os.path.join(util.getcwd(), opts.paste)))

            if not os.path.exists(path):
                raise ConfigError("%r not found" % val)

            # paste application, load the config
            self.cfgurl = 'config:%s' % path
            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]
コード例 #12
0
ファイル: wsgiapp.py プロジェクト: viplavdube/Car-Yard-App
    def init(self, parser, opts, args):
        self.app_uri = None

        if opts.paste:
            from .pasterapp import has_logging_config

            config_uri = os.path.abspath(opts.paste)
            config_file = config_uri.split("#")[0]

            if not os.path.exists(config_file):
                raise ConfigError("%r not found" % config_file)

            self.cfg.set("default_proc_name", config_file)
            self.app_uri = config_uri

            if has_logging_config(config_file):
                self.cfg.set("logconfig", config_file)

            return

        if len(args) > 0:
            self.cfg.set("default_proc_name", args[0])
            self.app_uri = args[0]
コード例 #13
0
def validate_reload_engine(val):
    if val not in reloader_engines:
        raise ConfigError("Invalid reload_engine: %r" % val)

    return val