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


Python paster.bootstrap方法代码示例

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


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

示例1: worker

# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import bootstrap [as 别名]
def worker(config_uri):
    """ Console entry script that starts a worker process
    """
    # TODO: import spacy's model to share it between workers

    pyramid_env = bootstrap(config_uri)

    # this conflicts with normal worker output
    # TODO: solve logging for the console
    # Setup logging to allow log output from command methods
    # from pyramid.paster import setup_logging
    # setup_logging(config_uri)

    try:
        qs = ['default']
        conn = redis_connection()
        with Connection(conn):
            w = Worker(qs)
            w.work()
    finally:
        pyramid_env['closer']() 
开发者ID:eea,项目名称:eea.corpus,代码行数:23,代码来源:async.py

示例2: main

# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import bootstrap [as 别名]
def main(args=None):
    if args is None:
        args = sys.argv[1:]
    try:
        config_file, recipient = args
    except ValueError:
        print("Usage: %s CONFIG RECIPIENT" % sys.argv[0])
        return 1

    print("Load config...")
    env = bootstrap(config_file)

    print("Send email to %r" % recipient)
    registry = env['registry']
    mailer = get_mailer(registry)

    message = Message(subject=subject,
                      recipients=[recipient],
                      body=body)
    mailer.send_immediately(message, fail_silently=False)
    print("Done.")
    return 0 
开发者ID:Kinto,项目名称:kinto-emailer,代码行数:24,代码来源:command_send.py

示例3: engine_from_settings

# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import bootstrap [as 别名]
def engine_from_settings(config, full_config=False):
    settings = get_appsettings(config, 'assembl')
    if settings['sqlalchemy.url'].startswith('virtuoso:'):
        db_schema = '.'.join((settings['db_schema'], settings['db_user']))
    else:
        db_schema = settings['db_schema']
    set_config(settings, True)
    session = None
    if full_config:
        env = bootstrap(config)
        configure_zmq(settings['changes.socket'], False)
        configure_model_watcher(env['registry'], 'assembl')
        logging.config.fileConfig(config)
        session = get_session_maker()
        metadata = get_metadata()
    else:
        session = make_session_maker(zope_tr=True)
        import assembl.models
        from assembl.lib.sqla import class_registry
        engine = configure_engine(settings, session_maker=session)
        metadata = get_metadata()
        metadata.bind = engine
        session = sessionmaker(engine)()
    return (metadata, session) 
开发者ID:conversence,项目名称:idealoom,代码行数:26,代码来源:clone_discussion.py

示例4: engine_from_settings

# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import bootstrap [as 别名]
def engine_from_settings(config, full_config=False):
    settings = get_appsettings(config, 'assembl')
    if settings['sqlalchemy.url'].startswith('virtuoso:'):
        db_schema = '.'.join((settings['db_schema'], settings['db_user']))
    else:
        db_schema = settings['db_schema']
    set_config(settings, True)
    session = None
    if full_config:
        env = bootstrap(config)
        configure_zmq(settings['changes.socket'], False)
        configure_model_watcher(env['registry'], 'assembl')
        logging.config.fileConfig(config)
    else:
        session = make_session_maker(zope_tr=True)
    import assembl.models
    from assembl.lib.sqla import class_registry
    engine = configure_engine(settings, session_maker=session)
    metadata = get_metadata()
    metadata.bind = engine
    session = sessionmaker(engine)()
    return (metadata, session) 
开发者ID:conversence,项目名称:idealoom,代码行数:24,代码来源:clone_database.py

示例5: get_app

# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import bootstrap [as 别名]
def get_app(ini_settings: dict, extra_init: t.Optional[t.Callable] = None) -> Router:
    """Construct a WSGI application from INI settings.

    You can pass extra callable which is called back when Initializer is about to finish. This allows you to poke app configuration easily.
    """
    if extra_init:
        # Convert extra init to string, because Paster stack doesn't allow raw objects through configuration
        options = {"extra_init": get_qual_name(extra_init)}
    else:
        options = None

    data = bootstrap(ini_settings["_ini_file"], options=options)
    return data["app"] 
开发者ID:websauna,项目名称:websauna,代码行数:15,代码来源:fixtures.py

示例6: app

# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import bootstrap [as 别名]
def app(request, ini_settings: dict, **settings_overrides) -> Router:
    """Initialize WSGI application from INI file given on the command line.

    :param settings_overrides: Override specific settings for the test case.

    :return: WSGI application instance as created by ``Initializer.make_wsgi_app()``. You can access the Initializer instance itself as ``app.initializer``.
    """
    if "_ini_file" not in ini_settings:
        raise RuntimeError("You need to give --ini test.ini command line option to py.test to find our test settings")

    data = bootstrap(ini_settings["_ini_file"])
    return data["app"] 
开发者ID:websauna,项目名称:websauna,代码行数:14,代码来源:fixtures.py

示例7: main

# 需要导入模块: from pyramid import paster [as 别名]
# 或者: from pyramid.paster import bootstrap [as 别名]
def main(cli_args=None):
    if cli_args is None:
        cli_args = sys.argv[1:]

    parser = argparse.ArgumentParser()
    parser.add_argument('--ini',
                        help='Application configuration file',
                        dest='ini_file',
                        required=False,
                        default=DEFAULT_CONFIG_FILE)
    parser.add_argument('-b', '--bucket',
                        help='Bucket name.',
                        type=str)
    parser.add_argument('-c', '--collection',
                        help='Collection name.',
                        type=str)
    args = parser.parse_args(args=cli_args)

    print("Load config...")
    env = bootstrap(args.ini_file)
    registry = env['registry']

    # Make sure that kinto-elasticsearch is configured.
    try:
        indexer = registry.indexer
    except AttributeError:
        logger.error("kinto-elasticsearch not available.")
        return 62

    bucket_id = args.bucket
    collection_id = args.collection

    # Get index schema from collection metadata.
    try:
        schema = get_index_schema(registry.storage, bucket_id, collection_id)
    except RecordNotFoundError:
        logger.error("No collection '%s' in bucket '%s'" % (collection_id, bucket_id))
        return 63

    # Give up if collection has no index mapping.
    if schema is None:
        logger.error("No `index:schema` attribute found in collection metadata.")
        return 64

    # XXX: Are you sure?
    recreate_index(indexer, bucket_id, collection_id, schema)
    reindex_records(indexer, registry.storage, bucket_id, collection_id)

    return 0 
开发者ID:Kinto,项目名称:kinto-elasticsearch,代码行数:51,代码来源:command_reindex.py


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