当前位置: 首页>>代码示例>>Python>>正文


Python deploy.loadapp方法代码示例

本文整理汇总了Python中paste.deploy.loadapp方法的典型用法代码示例。如果您正苦于以下问题:Python deploy.loadapp方法的具体用法?Python deploy.loadapp怎么用?Python deploy.loadapp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在paste.deploy的用法示例。


在下文中一共展示了deploy.loadapp方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_app

# 需要导入模块: from paste import deploy [as 别名]
# 或者: from paste.deploy import loadapp [as 别名]
def load_app(conf, not_implemented_middleware=True):
    global APPCONFIGS

    # Build the WSGI app
    cfg_path = conf.api.paste_config
    if not os.path.isabs(cfg_path):
        cfg_path = conf.find_file(cfg_path)

    if cfg_path is None or not os.path.exists(cfg_path):
        LOG.debug("No api-paste configuration file found! Using default.")
        cfg_path = os.path.abspath(pkg_resources.resource_filename(
            __name__, "api-paste.ini"))

    config = dict(conf=conf,
                  not_implemented_middleware=not_implemented_middleware)
    configkey = str(uuid.uuid4())
    APPCONFIGS[configkey] = config

    LOG.info("WSGI config used: %s", cfg_path)

    appname = "gnocchi+" + conf.api.auth_mode
    app = deploy.loadapp("config:" + cfg_path, name=appname,
                         global_conf={'configkey': configkey})
    return http_proxy_to_wsgi.HTTPProxyToWSGI(
        cors.CORS(app, conf=conf), conf=conf) 
开发者ID:gnocchixyz,项目名称:gnocchi,代码行数:27,代码来源:app.py

示例2: load_app

# 需要导入模块: from paste import deploy [as 别名]
# 或者: from paste.deploy import loadapp [as 别名]
def load_app(self, name):
        """Return the paste URLMap wrapped WSGI application.

        :param name: Name of the application to load.
        :returns: Paste URLMap object wrapping the requested application.
        :raises: `ec2api.exception.EC2APIPasteAppNotFound`

        """
        try:
            LOG.debug("Loading app %(name)s from %(path)s",
                      {'name': name, 'path': self.config_path})
            return deploy.loadapp("config:%s" % self.config_path, name=name)
        except LookupError as err:
            LOG.error(err)
            raise exception.EC2APIPasteAppNotFound(name=name,
                                                   path=self.config_path) 
开发者ID:openstack,项目名称:ec2-api,代码行数:18,代码来源:wsgi.py

示例3: main

# 需要导入模块: from paste import deploy [as 别名]
# 或者: from paste.deploy import loadapp [as 别名]
def main():
    # setup opts
    config.parse_args(args=sys.argv[1:])
    config.setup_logging()
    paste_conf = config.find_paste_config()

    # quick simple server for testing purposes or simple scenarios
    ip = CONF.get('bind_host', '0.0.0.0')
    port = CONF.get('bind_port', 9090)
    try:
        httpserver.serve(
            application=deploy.loadapp('config:%s' % paste_conf, name='main'),
            host=ip,
            port=port)
        message = (_i18n._('Server listening on %(ip)s:%(port)s') %
                   {'ip': ip, 'port': port})
        _LOG.info(message)
        print(message)
    except KeyboardInterrupt:
        print(_i18n._("Thank You ! \nBye."))
        sys.exit(0) 
开发者ID:openstack,项目名称:freezer-api,代码行数:23,代码来源:api.py

示例4: init_application

# 需要导入模块: from paste import deploy [as 别名]
# 或者: from paste.deploy import loadapp [as 别名]
def init_application():
    conf_files = _get_config_files()
    logging.register_options(cfg.CONF)
    cfg.CONF([], project='designate', default_config_files=conf_files)
    config.set_defaults()
    logging.setup(cfg.CONF, 'designate')

    policy.init()

    if not rpc.initialized():
        rpc.init(CONF)

    heartbeat = heartbeat_emitter.get_heartbeat_emitter('api')
    heartbeat.start()

    conf = conf_files[0]

    return deploy.loadapp('config:%s' % conf, name='osapi_dns') 
开发者ID:openstack,项目名称:designate,代码行数:20,代码来源:wsgi.py

示例5: load_paste_app

# 需要导入模块: from paste import deploy [as 别名]
# 或者: from paste.deploy import loadapp [as 别名]
def load_paste_app(app_name):
    """Builds and returns a WSGI app from a paste config file.

    :param app_name: Name of the application to load
    :raises ConfigFilesNotFoundError when config file cannot be located
    :raises RuntimeError when application cannot be loaded from config file
    """

    config_path = cfg.CONF.find_file(cfg.CONF.api_paste_config)
    if not config_path:
        raise cfg.ConfigFilesNotFoundError(
            config_files=[cfg.CONF.api_paste_config])
    config_path = os.path.abspath(config_path)
    LOG.info(_LI("Config paste file: %s"), config_path)

    try:
        app = deploy.loadapp("config:%s" % config_path, name=app_name)
    except (LookupError, ImportError):
        msg = (_("Unable to load %(app_name)s from "
                 "configuration file %(config_path)s.") %
               {'app_name': app_name,
                'config_path': config_path})
        LOG.exception(msg)
        raise RuntimeError(msg)
    return app 
开发者ID:platform9,项目名称:openstack-omni,代码行数:27,代码来源:config.py

示例6: initialize_application

# 需要导入模块: from paste import deploy [as 别名]
# 或者: from paste.deploy import loadapp [as 别名]
def initialize_application():
    conf_files = _get_config_files()
    api_config.parse_args([], default_config_files=conf_files)
    logging.setup(CONF, "masakari")

    objects.register_all()
    CONF(sys.argv[1:], project='masakari', version=version.version_string())

    # NOTE: Dump conf at debug (log_options option comes from oslo.service)
    # This is gross but we don't have a public hook into oslo.service to
    # register these options, so we are doing it manually for now;
    # remove this when we have a hook method into oslo.service.
    CONF.register_opts(service_opts.service_opts)
    if CONF.log_options:
        CONF.log_opt_values(logging.getLogger(__name__), logging.DEBUG)

    config.set_middleware_defaults()
    rpc.init(CONF)
    conf = conf_files[0]

    return deploy.loadapp('config:%s' % conf, name="masakari_api") 
开发者ID:openstack,项目名称:masakari,代码行数:23,代码来源:api.py

示例7: load_app

# 需要导入模块: from paste import deploy [as 别名]
# 或者: from paste.deploy import loadapp [as 别名]
def load_app():
    global APPCONFIGS
    # Build the WSGI app
    cfg_path = CONF.api.paste_config
    if not os.path.isabs(cfg_path):
        cfg_path = CONF.find_file(cfg_path)

    if cfg_path is None or not os.path.exists(cfg_path):
        raise cfg.ConfigFilesNotFoundError([CONF.api.paste_config])

    config = dict(conf=CONF)
    configkey = uuidutils.generate_uuid()
    APPCONFIGS[configkey] = config

    LOG.info('Full WSGI config used: %s', cfg_path)

    appname = "vitrage+" + CONF.api.auth_mode
    return deploy.loadapp("config:" + cfg_path, name=appname,
                          global_conf={'configkey': configkey}) 
开发者ID:openstack,项目名称:vitrage,代码行数:21,代码来源:app.py

示例8: load_paste_app

# 需要导入模块: from paste import deploy [as 别名]
# 或者: from paste.deploy import loadapp [as 别名]
def load_paste_app(app_name):
    """Builds and returns a WSGI app from a paste config file.

    :param app_name: Name of the application to load
    :raises ConfigFilesNotFoundError: when config file cannot be located
    :raises RuntimeError: when application cannot be loaded from config file
    """

    config_path = cfg.CONF.find_file(cfg.CONF.api_paste_config)
    if not config_path:
        raise cfg.ConfigFilesNotFoundError(
            config_files=[cfg.CONF.api_paste_config])
    config_path = os.path.abspath(config_path)
    LOG.info("Config paste file: %s", config_path)

    try:
        app = deploy.loadapp("config:%s" % config_path, name=app_name)
    except (LookupError, ImportError):
        msg = (_("Unable to load %(app_name)s from "
                 "configuration file %(config_path)s.") %
               {'app_name': app_name,
                'config_path': config_path})
        LOG.exception(msg)
        raise RuntimeError(msg)
    return app 
开发者ID:openstack,项目名称:tacker,代码行数:27,代码来源:config.py

示例9: paste_deploy_app

# 需要导入模块: from paste import deploy [as 别名]
# 或者: from paste.deploy import loadapp [as 别名]
def paste_deploy_app(paste_config_file, app_name, conf):
    """Load a WSGI app from a PasteDeploy configuration.

    Use deploy.loadapp() to load the app from the PasteDeploy configuration,
    ensuring that the supplied ConfigOpts object is passed to the app and
    filter constructors.

    :param paste_config_file: a PasteDeploy config file
    :param app_name: the name of the app/pipeline to load from the file
    :param conf: a ConfigOpts object to supply to the app and its filters
    :returns: the WSGI app
    """
    setup_paste_factories(conf)
    try:
        return deploy.loadapp("config:%s" % paste_config_file, name=app_name)
    finally:
        teardown_paste_factories() 
开发者ID:openstack,项目名称:senlin,代码行数:19,代码来源:wsgi.py

示例10: load_app

# 需要导入模块: from paste import deploy [as 别名]
# 或者: from paste.deploy import loadapp [as 别名]
def load_app(conf):
    global APPCONFIGS

    # Build the WSGI app
    cfg_path = conf.api.paste_config
    if not os.path.isabs(cfg_path):
        cfg_path = conf.find_file(cfg_path)

    if cfg_path is None or not os.path.exists(cfg_path):
        raise cfg.ConfigFilesNotFoundError([conf.api.paste_config])

    config = dict(conf=conf)
    configkey = str(uuid.uuid4())
    APPCONFIGS[configkey] = config

    LOG.info("WSGI config used: %s", cfg_path)
    return deploy.loadapp("config:" + cfg_path,
                          name="aodh+" + (
                              conf.api.auth_mode
                              if conf.api.auth_mode else "noauth"
                          ),
                          global_conf={'configkey': configkey}) 
开发者ID:openstack,项目名称:aodh,代码行数:24,代码来源:app.py

示例11: load_app

# 需要导入模块: from paste import deploy [as 别名]
# 或者: from paste.deploy import loadapp [as 别名]
def load_app():
    cfg_file = None
    cfg_path = CONF.api.api_paste_config
    if not os.path.isabs(cfg_path):
        cfg_file = CONF.find_file(cfg_path)
    elif os.path.exists(cfg_path):
        cfg_file = cfg_path

    if not cfg_file:
        raise cfg.ConfigFilesNotFoundError([CONF.api.api_paste_config])
    LOG.info("Full WSGI config used: %s", cfg_file)
    return deploy.loadapp("config:" + cfg_file) 
开发者ID:openstack,项目名称:zun,代码行数:14,代码来源:app.py

示例12: load_pasteapp

# 需要导入模块: from paste import deploy [as 别名]
# 或者: from paste.deploy import loadapp [as 别名]
def load_pasteapp(config_url, relative_to, global_conf=None):
    return loadapp(config_url, relative_to=relative_to,
            global_conf=global_conf) 
开发者ID:jpush,项目名称:jbox,代码行数:5,代码来源:pasterapp.py

示例13: __init__

# 需要导入模块: from paste import deploy [as 别名]
# 或者: from paste.deploy import loadapp [as 别名]
def __init__(self, app, extra_environ=None, relative_to=None,
                 use_unicode=True, cookiejar=None, parser_features=None,
                 json_encoder=None, lint=True):
        if 'WEBTEST_TARGET_URL' in os.environ:
            app = os.environ['WEBTEST_TARGET_URL']
        if isinstance(app, string_types):
            if app.startswith('http'):
                try:
                    from wsgiproxy import HostProxy
                except ImportError:  # pragma: no cover
                    raise ImportError((
                        'Using webtest with a real url requires WSGIProxy2. '
                        'Please install it with: '
                        'pip install WSGIProxy2'))
                if '#' not in app:
                    app += '#httplib'
                url, client = app.split('#', 1)
                app = HostProxy(url, client=client)
            else:
                from paste.deploy import loadapp
                # @@: Should pick up relative_to from calling module's
                # __file__
                app = loadapp(app, relative_to=relative_to)
        self.app = app
        self.lint = lint
        self.relative_to = relative_to
        if extra_environ is None:
            extra_environ = {}
        self.extra_environ = extra_environ
        self.use_unicode = use_unicode
        self.cookiejar = cookiejar or http_cookiejar.CookieJar(
            policy=CookiePolicy())
        if parser_features is None:
            parser_features = 'html.parser'
        self.RequestClass.ResponseClass.parser_features = parser_features
        if json_encoder is None:
            json_encoder = json.JSONEncoder
        self.JSONEncoder = json_encoder 
开发者ID:MayOneUS,项目名称:pledgeservice,代码行数:40,代码来源:app.py

示例14: initialize_app

# 需要导入模块: from paste import deploy [as 别名]
# 或者: from paste.deploy import loadapp [as 别名]
def initialize_app(conf=None, name='main'):
    """ initializing app for paste to deploy it """

    # register and parse arguments
    config.parse_args(args=sys.argv[1:])
    # register logging opts
    config.setup_logging()
    # locate and load paste file
    conf = config.find_paste_config()
    app = deploy.loadapp('config:%s' % conf, name=name)
    return app 
开发者ID:openstack,项目名称:freezer-api,代码行数:13,代码来源:service.py

示例15: wsgi_application

# 需要导入模块: from paste import deploy [as 别名]
# 或者: from paste.deploy import loadapp [as 别名]
def wsgi_application(self):
        api_paste_config = cfg.CONF['service:api'].api_paste_config
        config_paths = utils.find_config(api_paste_config)

        if len(config_paths) == 0:
            msg = 'Unable to determine appropriate api-paste-config file'
            raise exceptions.ConfigurationError(msg)

        LOG.info('Using api-paste-config found at: %s', config_paths[0])

        return deploy.loadapp("config:%s" % config_paths[0], name='osapi_dns') 
开发者ID:openstack,项目名称:designate,代码行数:13,代码来源:service.py


注:本文中的paste.deploy.loadapp方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。