• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python initializer.bootstrap_options函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中sentry.runner.initializer.bootstrap_options函数的典型用法代码示例。如果您正苦于以下问题:Python bootstrap_options函数的具体用法?Python bootstrap_options怎么用?Python bootstrap_options使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_bootstrap_options_no_config

def test_bootstrap_options_no_config(settings):
    "No config file should gracefully extract values out of settings"
    settings.SECRET_KEY = 'my-system-secret-key'
    settings.EMAIL_BACKEND = 'my-mail-backend'
    settings.EMAIL_HOST = 'my-mail-host'
    settings.EMAIL_PORT = 123
    settings.EMAIL_HOST_USER = 'my-mail-username'
    settings.EMAIL_HOST_PASSWORD = 'my-mail-password'
    settings.EMAIL_USE_TLS = True
    settings.SERVER_EMAIL = 'my-mail-from'
    settings.EMAIL_SUBJECT_PREFIX = 'my-mail-subject-prefix'
    settings.FOO_BAR = 'lol'

    bootstrap_options(settings)
    assert settings.SENTRY_OPTIONS == {
        'system.secret-key': 'my-system-secret-key',
        'mail.backend': 'my-mail-backend',
        'mail.host': 'my-mail-host',
        'mail.port': 123,
        'mail.username': 'my-mail-username',
        'mail.password': 'my-mail-password',
        'mail.use-tls': True,
        'mail.from': 'my-mail-from',
        'mail.subject-prefix': 'my-mail-subject-prefix',
    }
开发者ID:Kayle009,项目名称:sentry,代码行数:25,代码来源:test_initializer.py


示例2: test_bootstrap_options_malformed_yml

def test_bootstrap_options_malformed_yml(settings, config_yml):
    config_yml.write("1")
    with pytest.raises(ConfigurationError):
        bootstrap_options(settings, str(config_yml))

    config_yml.write("{{{")
    with pytest.raises(ConfigurationError):
        bootstrap_options(settings, str(config_yml))
开发者ID:zenefits,项目名称:sentry,代码行数:8,代码来源:test_initializer.py


示例3: test_bootstrap_options_malformed_yml

def test_bootstrap_options_malformed_yml(settings, config_yml):
    config_yml.write('1')
    with pytest.raises(ConfigurationError):
        bootstrap_options(settings, six.text_type(config_yml))

    config_yml.write('{{{')
    with pytest.raises(ConfigurationError):
        bootstrap_options(settings, six.text_type(config_yml))
开发者ID:Kayle009,项目名称:sentry,代码行数:8,代码来源:test_initializer.py


示例4: test_bootstrap_options_simple

def test_bootstrap_options_simple(settings, config_yml):
    "Config options are specified in both places, but config.yml should prevail"
    settings.SECRET_KEY = 'xxx'
    settings.EMAIL_BACKEND = 'xxx'
    settings.EMAIL_HOST = 'xxx'
    settings.EMAIL_PORT = 6969
    settings.EMAIL_HOST_USER = 'xxx'
    settings.EMAIL_HOST_PASSWORD = 'xxx'
    settings.EMAIL_USE_TLS = False
    settings.SERVER_EMAIL = 'xxx'
    settings.EMAIL_SUBJECT_PREFIX = 'xxx'
    settings.SENTRY_OPTIONS = {'something.else': True}

    config_yml.write(
        """\
foo.bar: my-foo-bar
system.secret-key: my-system-secret-key
mail.backend: my-mail-backend
mail.host: my-mail-host
mail.port: 123
mail.username: my-mail-username
mail.password: my-mail-password
mail.use-tls: true
mail.from: my-mail-from
mail.subject-prefix: my-mail-subject-prefix
"""
    )

    bootstrap_options(settings, six.text_type(config_yml))
    assert settings.SENTRY_OPTIONS == {
        'something.else': True,
        'foo.bar': 'my-foo-bar',
        'system.secret-key': 'my-system-secret-key',
        'mail.backend': 'my-mail-backend',
        'mail.host': 'my-mail-host',
        'mail.port': 123,
        'mail.username': 'my-mail-username',
        'mail.password': 'my-mail-password',
        'mail.use-tls': True,
        'mail.from': 'my-mail-from',
        'mail.subject-prefix': 'my-mail-subject-prefix',
    }
    assert settings.SECRET_KEY == 'my-system-secret-key'
    assert settings.EMAIL_BACKEND == 'my-mail-backend'
    assert settings.EMAIL_HOST == 'my-mail-host'
    assert settings.EMAIL_PORT == 123
    assert settings.EMAIL_HOST_USER == 'my-mail-username'
    assert settings.EMAIL_HOST_PASSWORD == 'my-mail-password'
    assert settings.EMAIL_USE_TLS is True
    assert settings.SERVER_EMAIL == 'my-mail-from'
    assert settings.EMAIL_SUBJECT_PREFIX == 'my-mail-subject-prefix'
开发者ID:Kayle009,项目名称:sentry,代码行数:51,代码来源:test_initializer.py


示例5: test_bootstrap_options_simple

def test_bootstrap_options_simple(settings, config_yml):
    "Config options are specified in both places, but config.yml should prevail"
    settings.SECRET_KEY = "xxx"
    settings.EMAIL_BACKEND = "xxx"
    settings.EMAIL_HOST = "xxx"
    settings.EMAIL_PORT = 6969
    settings.EMAIL_HOST_USER = "xxx"
    settings.EMAIL_HOST_PASSWORD = "xxx"
    settings.EMAIL_USE_TLS = False
    settings.SERVER_EMAIL = "xxx"
    settings.EMAIL_SUBJECT_PREFIX = "xxx"
    settings.SENTRY_OPTIONS = {"something.else": True}

    config_yml.write(
        """\
foo.bar: my-foo-bar
system.secret-key: my-system-secret-key
mail.backend: my-mail-backend
mail.host: my-mail-host
mail.port: 123
mail.username: my-mail-username
mail.password: my-mail-password
mail.use-tls: true
mail.from: my-mail-from
mail.subject-prefix: my-mail-subject-prefix
"""
    )

    bootstrap_options(settings, str(config_yml))
    assert settings.SENTRY_OPTIONS == {
        "something.else": True,
        "foo.bar": "my-foo-bar",
        "system.secret-key": "my-system-secret-key",
        "mail.backend": "my-mail-backend",
        "mail.host": "my-mail-host",
        "mail.port": 123,
        "mail.username": "my-mail-username",
        "mail.password": "my-mail-password",
        "mail.use-tls": True,
        "mail.from": "my-mail-from",
        "mail.subject-prefix": "my-mail-subject-prefix",
    }
    assert settings.SECRET_KEY == "my-system-secret-key"
    assert settings.EMAIL_BACKEND == "my-mail-backend"
    assert settings.EMAIL_HOST == "my-mail-host"
    assert settings.EMAIL_PORT == 123
    assert settings.EMAIL_HOST_USER == "my-mail-username"
    assert settings.EMAIL_HOST_PASSWORD == "my-mail-password"
    assert settings.EMAIL_USE_TLS is True
    assert settings.SERVER_EMAIL == "my-mail-from"
    assert settings.EMAIL_SUBJECT_PREFIX == "my-mail-subject-prefix"
开发者ID:zenefits,项目名称:sentry,代码行数:51,代码来源:test_initializer.py


示例6: test_bootstrap_options_no_config_only_sentry_options

def test_bootstrap_options_no_config_only_sentry_options(settings):
    "SENTRY_OPTIONS is only declared, but should be promoted into settings"
    settings.SENTRY_OPTIONS = {
        'system.secret-key': 'my-system-secret-key',
        'mail.backend': 'my-mail-backend',
        'mail.host': 'my-mail-host',
        'mail.port': 123,
        'mail.username': 'my-mail-username',
        'mail.password': 'my-mail-password',
        'mail.use-tls': True,
        'mail.from': 'my-mail-from',
        'mail.subject-prefix': 'my-mail-subject-prefix',
    }

    bootstrap_options(settings)
    assert settings.SECRET_KEY == 'my-system-secret-key'
    assert settings.EMAIL_BACKEND == 'my-mail-backend'
    assert settings.EMAIL_HOST == 'my-mail-host'
    assert settings.EMAIL_PORT == 123
    assert settings.EMAIL_HOST_USER == 'my-mail-username'
    assert settings.EMAIL_HOST_PASSWORD == 'my-mail-password'
    assert settings.EMAIL_USE_TLS is True
    assert settings.SERVER_EMAIL == 'my-mail-from'
    assert settings.EMAIL_SUBJECT_PREFIX == 'my-mail-subject-prefix'
开发者ID:Kayle009,项目名称:sentry,代码行数:24,代码来源:test_initializer.py


示例7: test_initialize_app

def test_initialize_app(settings):
    "Just a sanity check of the full initialization process"
    settings.SENTRY_OPTIONS = {'system.secret-key': 'secret-key'}
    bootstrap_options(settings)
    apply_legacy_settings(settings)
开发者ID:Kayle009,项目名称:sentry,代码行数:5,代码来源:test_initializer.py


示例8: test_bootstrap_options_empty_file

def test_bootstrap_options_empty_file(settings, config_yml):
    config_yml.write('')
    bootstrap_options(settings, six.text_type(config_yml))
    assert settings.SENTRY_OPTIONS == {}
开发者ID:Kayle009,项目名称:sentry,代码行数:4,代码来源:test_initializer.py


示例9: test_bootstrap_options_missing_file

def test_bootstrap_options_missing_file(settings):
    bootstrap_options(settings, 'this-file-does-not-exist-xxxxxxxxxxxxxx.yml')
    assert settings.SENTRY_OPTIONS == {}
开发者ID:Kayle009,项目名称:sentry,代码行数:3,代码来源:test_initializer.py


示例10: test_bootstrap_options_mail_aliases

def test_bootstrap_options_mail_aliases(settings):
    settings.SENTRY_OPTIONS = {
        'mail.backend': 'dummy',
    }
    bootstrap_options(settings)
    assert settings.EMAIL_BACKEND == 'alias-for-dummy'
开发者ID:Kayle009,项目名称:sentry,代码行数:6,代码来源:test_initializer.py


示例11: test_initialize_app

def test_initialize_app(settings):
    "Just a sanity check of the full initialization process"
    bootstrap_options(settings)
    apply_legacy_settings(settings)
开发者ID:thoinv,项目名称:sentry,代码行数:4,代码来源:test_initializer.py


示例12: pytest_configure

def pytest_configure(config):
    # HACK: Only needed for testing!
    os.environ.setdefault("_SENTRY_SKIP_CONFIGURATION", "1")

    os.environ.setdefault("RECAPTCHA_TESTING", "True")
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sentry.conf.server")

    settings.SOUTH_TESTS_MIGRATE = os.environ.get("SENTRY_SOUTH_TESTS_MIGRATE", "1") == "1"

    if not settings.configured:
        # only configure the db if its not already done
        test_db = os.environ.get("DB", "postgres")
        if test_db == "mysql":
            settings.DATABASES["default"].update(
                {"ENGINE": "django.db.backends.mysql", "NAME": "sentry", "USER": "root"}
            )
            # mysql requires running full migration all the time
            settings.SOUTH_TESTS_MIGRATE = True
        elif test_db == "postgres":
            settings.DATABASES["default"].update({"ENGINE": "sentry.db.postgres", "USER": "postgres", "NAME": "sentry"})
            # postgres requires running full migration all the time
            # since it has to install stored functions which come from
            # an actual migration.
            settings.SOUTH_TESTS_MIGRATE = True
        elif test_db == "sqlite":
            settings.DATABASES["default"].update({"ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:"})

    settings.TEMPLATE_DEBUG = True

    # Disable static compiling in tests
    settings.STATIC_BUNDLES = {}

    # override a few things with our test specifics
    settings.INSTALLED_APPS = tuple(settings.INSTALLED_APPS) + ("tests",)
    # Need a predictable key for tests that involve checking signatures
    settings.SENTRY_PUBLIC = False

    if not settings.SENTRY_CACHE:
        settings.SENTRY_CACHE = "sentry.cache.django.DjangoCache"
        settings.SENTRY_CACHE_OPTIONS = {}

    # This speeds up the tests considerably, pbkdf2 is by design, slow.
    settings.PASSWORD_HASHERS = ["django.contrib.auth.hashers.MD5PasswordHasher"]

    # Replace real sudo middleware with our mock sudo middleware
    # to assert that the user is always in sudo mode
    middleware = list(settings.MIDDLEWARE_CLASSES)
    sudo = middleware.index("sentry.middleware.sudo.SudoMiddleware")
    middleware[sudo] = "sentry.testutils.middleware.SudoMiddleware"
    settings.MIDDLEWARE_CLASSES = tuple(middleware)

    # enable draft features
    settings.SENTRY_OPTIONS["mail.enable-replies"] = True

    settings.SENTRY_ALLOW_ORIGIN = "*"

    settings.SENTRY_TSDB = "sentry.tsdb.inmemory.InMemoryTSDB"
    settings.SENTRY_TSDB_OPTIONS = {}

    settings.RECAPTCHA_PUBLIC_KEY = "a" * 40
    settings.RECAPTCHA_PRIVATE_KEY = "b" * 40

    settings.BROKER_BACKEND = "memory"
    settings.BROKER_URL = None
    settings.CELERY_ALWAYS_EAGER = False
    settings.CELERY_EAGER_PROPAGATES_EXCEPTIONS = True

    settings.DISABLE_RAVEN = True

    settings.CACHES = {"default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}}

    if not hasattr(settings, "SENTRY_OPTIONS"):
        settings.SENTRY_OPTIONS = {}

    settings.SENTRY_OPTIONS.update(
        {
            "redis.clusters": {"default": {"hosts": {0: {"db": 9}}}},
            "mail.backend": "django.core.mail.backends.locmem.EmailBackend",
            "system.url-prefix": "http://testserver",
        }
    )

    # django mail uses socket.getfqdn which doesn't play nice if our
    # networking isn't stable
    patcher = mock.patch("socket.getfqdn", return_value="localhost")
    patcher.start()

    from sentry.runner.initializer import bootstrap_options, initialize_receivers, fix_south, bind_cache_to_option_store

    bootstrap_options(settings)
    fix_south(settings)

    bind_cache_to_option_store()

    initialize_receivers()

    from sentry.utils.redis import clusters

    with clusters.get("default").all() as client:
        client.flushdb()
#.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:django-sentry,代码行数:101,代码来源:pytest.py


示例13: test_bootstrap_options_empty_file

def test_bootstrap_options_empty_file(settings, config_yml):
    config_yml.write("")
    bootstrap_options(settings, str(config_yml))
    assert settings.SENTRY_OPTIONS == {}
开发者ID:zenefits,项目名称:sentry,代码行数:4,代码来源:test_initializer.py


示例14: test_bootstrap_options_mail_aliases

def test_bootstrap_options_mail_aliases(settings):
    settings.SENTRY_OPTIONS = {"mail.backend": "dummy"}
    bootstrap_options(settings)
    assert settings.EMAIL_BACKEND == "alias-for-dummy"
开发者ID:zenefits,项目名称:sentry,代码行数:4,代码来源:test_initializer.py


示例15: pytest_configure


#.........这里部分代码省略.........

    settings.TEMPLATE_DEBUG = True

    # Disable static compiling in tests
    settings.STATIC_BUNDLES = {}

    # override a few things with our test specifics
    settings.INSTALLED_APPS = tuple(settings.INSTALLED_APPS) + (
        'tests',
    )
    # Need a predictable key for tests that involve checking signatures
    settings.SENTRY_PUBLIC = False

    if not settings.SENTRY_CACHE:
        settings.SENTRY_CACHE = 'sentry.cache.django.DjangoCache'
        settings.SENTRY_CACHE_OPTIONS = {}

    # This speeds up the tests considerably, pbkdf2 is by design, slow.
    settings.PASSWORD_HASHERS = [
        'django.contrib.auth.hashers.MD5PasswordHasher',
    ]

    # Replace real sudo middleware with our mock sudo middleware
    # to assert that the user is always in sudo mode
    middleware = list(settings.MIDDLEWARE_CLASSES)
    sudo = middleware.index('sentry.middleware.sudo.SudoMiddleware')
    middleware[sudo] = 'sentry.testutils.middleware.SudoMiddleware'
    settings.MIDDLEWARE_CLASSES = tuple(middleware)

    # enable draft features
    settings.SENTRY_OPTIONS['mail.enable-replies'] = True

    settings.SENTRY_ALLOW_ORIGIN = '*'

    settings.SENTRY_TSDB = 'sentry.tsdb.inmemory.InMemoryTSDB'
    settings.SENTRY_TSDB_OPTIONS = {}

    settings.RECAPTCHA_PUBLIC_KEY = 'a' * 40
    settings.RECAPTCHA_PRIVATE_KEY = 'b' * 40

    settings.BROKER_BACKEND = 'memory'
    settings.BROKER_URL = None
    settings.CELERY_ALWAYS_EAGER = False
    settings.CELERY_EAGER_PROPAGATES_EXCEPTIONS = True

    settings.DEBUG_VIEWS = True

    settings.DISABLE_RAVEN = True

    settings.CACHES = {
        'default': {
            'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
        }
    }

    if not hasattr(settings, 'SENTRY_OPTIONS'):
        settings.SENTRY_OPTIONS = {}

    settings.SENTRY_OPTIONS.update({
        'redis.clusters': {
            'default': {
                'hosts': {
                    0: {
                        'db': 9,
                    },
                },
            },
        },
        'mail.backend': 'django.core.mail.backends.locmem.EmailBackend',
        'system.url-prefix': 'http://testserver',
    })

    # django mail uses socket.getfqdn which doesn't play nice if our
    # networking isn't stable
    patcher = mock.patch('socket.getfqdn', return_value='localhost')
    patcher.start()

    from sentry.runner.initializer import (
        bootstrap_options, configure_structlog, initialize_receivers, fix_south,
        bind_cache_to_option_store)

    bootstrap_options(settings)
    configure_structlog()
    fix_south(settings)

    bind_cache_to_option_store()

    initialize_receivers()

    from sentry.utils.redis import clusters

    with clusters.get('default').all() as client:
        client.flushdb()

    # force celery registration
    from sentry.celery import app  # NOQA

    # disable DISALLOWED_IPS
    from sentry import http
    http.DISALLOWED_IPS = set()
开发者ID:Cobbyzhang,项目名称:sentry,代码行数:101,代码来源:pytest.py


示例16: pytest_configure


#.........这里部分代码省略.........

    settings.SENTRY_OPTIONS['cloudflare.secret-key'] = 'cloudflare-secret-key'

    # enable draft features
    settings.SENTRY_OPTIONS['mail.enable-replies'] = True

    settings.SENTRY_ALLOW_ORIGIN = '*'

    settings.SENTRY_TSDB = 'sentry.tsdb.inmemory.InMemoryTSDB'
    settings.SENTRY_TSDB_OPTIONS = {}

    if settings.SENTRY_NEWSLETTER == 'sentry.newsletter.base.Newsletter':
        settings.SENTRY_NEWSLETTER = 'sentry.newsletter.dummy.DummyNewsletter'
        settings.SENTRY_NEWSLETTER_OPTIONS = {}

    settings.BROKER_BACKEND = 'memory'
    settings.BROKER_URL = None
    settings.CELERY_ALWAYS_EAGER = False
    settings.CELERY_EAGER_PROPAGATES_EXCEPTIONS = True

    settings.DEBUG_VIEWS = True

    settings.SENTRY_ENCRYPTION_SCHEMES = ()

    settings.DISABLE_RAVEN = True

    settings.CACHES = {
        'default': {
            'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
        }
    }

    if not hasattr(settings, 'SENTRY_OPTIONS'):
        settings.SENTRY_OPTIONS = {}

    settings.SENTRY_OPTIONS.update(
        {
            'redis.clusters': {
                'default': {
                    'hosts': {
                        0: {
                            'db': 9,
                        },
                    },
                },
            },
            'mail.backend': 'django.core.mail.backends.locmem.EmailBackend',
            'system.url-prefix': 'http://testserver',

            'slack.client-id': 'slack-client-id',
            'slack.client-secret': 'slack-client-secret',
            'slack.verification-token': 'slack-verification-token',

            'github-app.name': 'sentry-test-app',
            'github-app.client-id': 'github-client-id',
            'github-app.client-secret': 'github-client-secret',

            'vsts.client-id': 'vsts-client-id',
            'vsts.client-secret': 'vsts-client-secret',
        }
    )

    # django mail uses socket.getfqdn which doesn't play nice if our
    # networking isn't stable
    patcher = mock.patch('socket.getfqdn', return_value='localhost')
    patcher.start()

    if not settings.SOUTH_TESTS_MIGRATE:
        settings.INSTALLED_APPS = tuple(i for i in settings.INSTALLED_APPS if i != 'south')

    from sentry.runner.initializer import (
        bootstrap_options, configure_structlog, initialize_receivers, fix_south,
        bind_cache_to_option_store, setup_services
    )

    bootstrap_options(settings)
    configure_structlog()
    fix_south(settings)

    import django
    if hasattr(django, 'setup'):
        django.setup()

    bind_cache_to_option_store()

    initialize_receivers()
    setup_services()
    register_extensions()

    from sentry.utils.redis import clusters

    with clusters.get('default').all() as client:
        client.flushdb()

    # force celery registration
    from sentry.celery import app  # NOQA

    # disable DISALLOWED_IPS
    from sentry import http
    http.DISALLOWED_IPS = set()
开发者ID:Kayle009,项目名称:sentry,代码行数:101,代码来源:sentry.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.parse_query函数代码示例发布时间:2022-05-27
下一篇:
Python roles.get_top_dog函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap