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

Python options.set函数代码示例

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

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



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

示例1: test_chunk_parameters

    def test_chunk_parameters(self):
        response = self.client.get(
            self.url,
            HTTP_AUTHORIZATION=u'Bearer {}'.format(self.token.token),
            format='json'
        )

        endpoint = options.get('system.upload-url-prefix')
        # We fallback to default system url if config is not set
        if len(endpoint) == 0:
            endpoint = options.get('system.url-prefix')

        assert response.status_code == 200, response.content
        assert response.data['chunkSize'] == CHUNK_UPLOAD_BLOB_SIZE
        assert response.data['chunksPerRequest'] == MAX_CHUNKS_PER_REQUEST
        assert response.data['maxRequestSize'] == MAX_REQUEST_SIZE
        assert response.data['maxFileSize'] == options.get('system.maximum-file-size')
        assert response.data['concurrency'] == MAX_CONCURRENCY
        assert response.data['hashAlgorithm'] == HASH_ALGORITHM
        assert response.data['url'] == options.get('system.url-prefix') + self.url

        options.set('system.upload-url-prefix', 'test')
        response = self.client.get(
            self.url,
            HTTP_AUTHORIZATION=u'Bearer {}'.format(self.token.token),
            format='json'
        )

        assert response.data['url'] == options.get('system.upload-url-prefix') + self.url
开发者ID:Kayle009,项目名称:sentry,代码行数:29,代码来源:test_chunk_upload.py


示例2: get_install_id

def get_install_id():
    from sentry import options
    install_id = options.get('sentry:install-id')
    if not install_id:
        install_id = sha1(uuid4().bytes).hexdigest()
        options.set('sentry:install-id', install_id)
    return install_id
开发者ID:Kayle009,项目名称:sentry,代码行数:7,代码来源:remote.py


示例3: put

    def put(self, request):
        # TODO(dcramer): this should validate options before saving them
        for k, v in six.iteritems(request.DATA):
            if v and isinstance(v, six.string_types):
                v = v.strip()
            try:
                option = options.lookup_key(k)
            except options.UnknownOption:
                # TODO(dcramer): unify API errors
                return Response({
                    'error': 'unknown_option',
                    'errorDetail': {
                        'option': k,
                    },
                }, status=400)

            try:
                if not (option.flags & options.FLAG_ALLOW_EMPTY) and not v:
                    options.delete(k)
                else:
                    options.set(k, v)
            except TypeError as e:
                return Response({
                    'error': 'invalid_type',
                    'errorDetail': {
                        'option': k,
                        'message': six.text_type(e),
                    },
                }, status=400)
        # TODO(dcramer): this has nothing to do with configuring options and
        # should not be set here
        options.set('sentry:version-configured', sentry.get_version())
        return Response(status=200)
开发者ID:ForkRepo,项目名称:sentry,代码行数:33,代码来源:system_options.py


示例4: test_registration_requires_subscribe_choice_with_newsletter

    def test_registration_requires_subscribe_choice_with_newsletter(self):
        options.set('auth.allow-registration', True)
        with self.feature('auth:register'):
            resp = self.client.post(
                self.path, {
                    'username': '[email protected]',
                    'password': 'foobar',
                    'name': 'Foo Bar',
                    'op': 'register',
                }
            )
        assert resp.status_code == 200

        with self.feature('auth:register'):
            resp = self.client.post(
                self.path, {
                    'username': '[email protected]',
                    'password': 'foobar',
                    'name': 'Foo Bar',
                    'op': 'register',
                    'subscribe': '0',
                }
            )
        assert resp.status_code == 302

        user = User.objects.get(username='[email protected]')
        assert user.email == '[email protected]'
        assert user.check_password('foobar')
        assert user.name == 'Foo Bar'
        assert not OrganizationMember.objects.filter(
            user=user,
        ).exists()

        assert newsletter.get_subscriptions(user) == {'subscriptions': []}
开发者ID:Kayle009,项目名称:sentry,代码行数:34,代码来源:test_auth_login.py


示例5: _needs_upgrade

def _needs_upgrade():
    version_configured = options.get('sentry:version-configured')
    if not version_configured:
        # If we were never previously upgraded (being a new install)
        # we want to force an upgrade, even if the values are set.
        return True

    smtp_disabled = not is_smtp_enabled()

    # Check all required options to see if they've been set
    for key in options.filter(flag=options.FLAG_REQUIRED):
        # ignore required flags which can be empty
        if key.flags & options.FLAG_ALLOW_EMPTY:
            continue
        # Ignore mail.* keys if smtp is disabled
        if smtp_disabled and key.name[:5] == 'mail.':
            continue
        if not options.isset(key.name):
            return True

    if version_configured != sentry.get_version():
        # Everything looks good, but version changed, so let's bump it
        options.set('sentry:version-configured', sentry.get_version())

    return False
开发者ID:yaoqi,项目名称:sentry,代码行数:25,代码来源:sentry_react.py


示例6: test_update_is_not_available

    def test_update_is_not_available(self):
        options.set('sentry:latest_version', '5.5.1')

        with mock.patch('sentry.get_version') as get_version:
            get_version.return_value = '5.5.0'
            resp = self.client.get(self.path)
            assert self.UPDATE_MESSAGE in resp.content
开发者ID:GrasIdevels,项目名称:sentry,代码行数:7,代码来源:tests.py


示例7: sync_docs

def sync_docs():
    from sentry import http, options

    session = http.build_session()

    logger.info('Syncing documentation (platform index)')
    data = session.get(BASE_URL.format('_index.json')).json()
    platform_list = []
    for platform_id, integrations in data['platforms'].iteritems():
        platform_list.append({
            'id': platform_id,
            'name': integrations['_self']['name'],
            'integrations': [
                {
                    'id': get_integration_id(platform_id, i_id),
                    'name': i_data['name'],
                    'type': i_data['type'],
                    'link': i_data['doc_link'],
                } for i_id, i_data in sorted(
                    integrations.iteritems(),
                    key=lambda x: x[1]['name']
                )
            ],
        })

    platform_list.sort(key=lambda x: x['name'])

    options.set('sentry:docs', {'platforms': platform_list})

    for platform_id, platform_data in data['platforms'].iteritems():
        for integration_id, integration in platform_data.iteritems():
            logger.info('Syncing documentation for %s integration', integration_id)
            sync_integration(platform_id, integration_id, integration['details'])
开发者ID:justintung,项目名称:sentry,代码行数:33,代码来源:sync_docs.py


示例8: put

 def put(self, request):
     # TODO(dcramer): this should validate options before saving them
     for k, v in request.DATA.iteritems():
         if v and isinstance(v, basestring):
             v = v.strip()
         try:
             if not v:
                 options.delete(k)
             else:
                 options.set(k, v)
         except options.UnknownOption:
             # TODO(dcramer): unify API errors
             return Response({
                 'error': 'unknown_option',
                 'errorDetail': {
                     'option': k,
                 },
             }, status=400)
         except TypeError as e:
             return Response({
                 'error': 'invalid_type',
                 'errorDetail': {
                     'option': k,
                     'message': unicode(e),
                 },
             }, status=400)
     # TODO(dcramer): this has nothing to do with configuring options and
     # should not be set here
     options.set('sentry:version-configured', sentry.get_version())
     return Response(status=200)
开发者ID:IthacaDream,项目名称:sentry,代码行数:30,代码来源:system_options.py


示例9: test_snuba_environment

    def test_snuba_environment(self):
        options.set('snuba.events-queries.enabled', True)
        url = u'/api/0/issues/{}/events/latest/'.format(self.group.id)
        response = self.client.get(url, format='json', data={'environment': ['production']})

        assert response.status_code == 200
        assert response.data['id'] == six.text_type(self.event2.event_id)
开发者ID:yaoqi,项目名称:sentry,代码行数:7,代码来源:test_group_events_latest.py


示例10: put

 def put(self, request):
     try:
         for k, v in request.DATA.iteritems():
             options.set(k, v)
     except Exception as e:
         return Response(unicode(e), status=400)
     options.set('sentry:version-configured', sentry.get_version())
     return Response(status=200)
开发者ID:rkeilty,项目名称:sentry,代码行数:8,代码来源:system_options.py


示例11: set

def set(option, value):
    "Set a configuration option to a new value."
    from sentry import options
    from sentry.options.manager import UnknownOption
    try:
        options.set(option, value)
    except UnknownOption:
        raise click.ClickException('unknown option: %s' % option)
开发者ID:dca,项目名称:sentry,代码行数:8,代码来源:config.py


示例12: default_issue_plugin_config

def default_issue_plugin_config(plugin, project, form_data):
    plugin_key = plugin.get_conf_key()
    for field, value in six.iteritems(form_data):
        key = '%s:%s' % (plugin_key, field)
        if project:
            ProjectOption.objects.set_value(project, key, value)
        else:
            options.set(key, value)
开发者ID:duanshuaimin,项目名称:sentry,代码行数:8,代码来源:configuration.py


示例13: test_set_sentry_version_old

    def test_set_sentry_version_old(self, get_version):
        options.set(self.KEY, self.NEW)

        get_version.return_value = self.CURRENT

        set_sentry_version(latest=self.OLD)

        self.assertEqual(options.get(key=self.KEY), self.NEW)
开发者ID:BlueMoebius,项目名称:sentry,代码行数:8,代码来源:tests.py


示例14: test_register_renders_correct_template

    def test_register_renders_correct_template(self):
        options.set('auth.allow-registration', True)
        register_path = reverse('sentry-register')
        resp = self.client.get(register_path)

        assert resp.status_code == 200
        assert resp.context['op'] == 'register'
        self.assertTemplateUsed('sentry/login.html')
开发者ID:duanshuaimin,项目名称:sentry,代码行数:8,代码来源:test_auth_login.py


示例15: default_plugin_config

def default_plugin_config(plugin, project, request):
    plugin_key = plugin.get_conf_key()
    form_class = plugin.get_conf_form(project)
    template = plugin.get_conf_template(project)

    if form_class is None:
        return HttpResponseRedirect(reverse(
            'sentry-manage-project', args=[project.organization.slug, project.slug]))

    test_results = None

    form = form_class(
        request.POST if request.POST.get('plugin') == plugin.slug else None,
        initial=plugin.get_conf_options(project),
        prefix=plugin_key,
    )
    if form.is_valid():
        if 'action_test' in request.POST and plugin.is_testable():
            try:
                test_results = plugin.test_configuration(project)
            except Exception as exc:
                if hasattr(exc, 'read') and callable(exc.read):
                    test_results = '%s\n%s' % (exc, exc.read())
                else:
                    logging.exception('Plugin(%s) raised an error during test',
                                      plugin_key)
                    test_results = 'There was an internal error with the Plugin'
            if not test_results:
                test_results = 'No errors returned'
        else:
            for field, value in form.cleaned_data.iteritems():
                key = '%s:%s' % (plugin_key, field)
                if project:
                    ProjectOption.objects.set_value(project, key, value)
                else:
                    options.set(key, value)

            messages.add_message(
                request, messages.SUCCESS,
                _('Your settings were saved successfully.'))
            return HttpResponseRedirect(request.path)

    # TODO(mattrobenolt): Reliably determine if a plugin is configured
    # if hasattr(plugin, 'is_configured'):
    #     is_configured = plugin.is_configured(project)
    # else:
    #     is_configured = True
    is_configured = True

    return mark_safe(render_to_string(template, {
        'form': form,
        'request': request,
        'plugin': plugin,
        'plugin_description': plugin.get_description() or '',
        'plugin_test_results': test_results,
        'plugin_is_configured': is_configured,
    }, context_instance=RequestContext(request)))
开发者ID:carriercomm,项目名称:sentry-1,代码行数:57,代码来源:configuration.py


示例16: set_sentry_version

def set_sentry_version(latest=None, **kwargs):
    import sentry
    current = sentry.get_version()

    version = options.get('sentry:latest_version')

    for ver in (current, version):
        if Version(ver) >= Version(latest):
            return

    options.set('sentry:latest_version', (latest or current))
开发者ID:josephmc5,项目名称:sentry,代码行数:11,代码来源:core.py


示例17: set

def set(option, value):
    "Set a configuration option to a new value."
    from sentry import options
    from sentry.options.manager import UnknownOption

    try:
        options.set(option, value)
    except UnknownOption:
        raise click.ClickException("unknown option: %s" % option)
    except TypeError as e:
        raise click.ClickException(unicode(e))
开发者ID:ezc,项目名称:sentry,代码行数:11,代码来源:config.py


示例18: test_optimizer_enabled

    def test_optimizer_enabled(self):
        prev_optimizer_enabled = options.get('snuba.search.pre-snuba-candidates-optimizer')
        options.set('snuba.search.pre-snuba-candidates-optimizer', True)

        try:
            results = self.backend.query(
                [self.project],
                environments=[self.environments['production']],
                tags={'server': 'example.com'})
            assert set(results) == set([self.group1])
        finally:
            options.set('snuba.search.pre-snuba-candidates-optimizer', prev_optimizer_enabled)
开发者ID:Kayle009,项目名称:sentry,代码行数:12,代码来源:test_backend.py


示例19: send_beacon

def send_beacon():
    """
    Send a Beacon to a remote server operated by the Sentry team.

    See the documentation for more details.
    """
    from sentry import options
    from sentry.models import Organization, Project, Team, User

    if not settings.SENTRY_BEACON:
        logger.info('Not sending beacon (disabled)')
        return

    install_id = options.get('sentry:install-id')
    if not install_id:
        logger.info('Generated installation ID: %s', install_id)
        install_id = sha1(uuid4().hex).hexdigest()
        options.set('sentry:install-id', install_id)

    end = timezone.now()
    events_24h = tsdb.get_sums(
        model=tsdb.models.internal,
        keys=['events.total'],
        start=end - timedelta(hours=24),
        end=end,
    )['events.total']

    payload = {
        'install_id': install_id,
        'version': sentry.get_version(),
        'admin_email': settings.SENTRY_ADMIN_EMAIL,
        'data': {
            # TODO(dcramer): we'd also like to get an idea about the throughput
            # of the system (i.e. events in 24h)
            'users': User.objects.count(),
            'projects': Project.objects.count(),
            'teams': Team.objects.count(),
            'organizations': Organization.objects.count(),
            'events.24h': events_24h,
        }
    }

    # TODO(dcramer): relay the response 'notices' as admin broadcasts
    try:
        request = safe_urlopen(BEACON_URL, json=payload, timeout=5)
        response = safe_urlread(request)
    except Exception:
        logger.warning('Failed sending beacon', exc_info=True)
        return

    data = json.loads(response)
    if 'version' in data:
        options.set('sentry:latest_version', data['version']['stable'])
开发者ID:carriercomm,项目名称:sentry-1,代码行数:53,代码来源:beacon.py


示例20: send_beacon

def send_beacon():
    """
    Send a Beacon to a remote server operated by the Sentry team.

    See the documentation for more details.
    """
    from sentry import options
    from sentry.models import Organization, Project, Team, User

    if not settings.SENTRY_BEACON:
        logger.info('Not sending beacon (disabled)')
        return

    # TODO(dcramer): move version code off of PyPi and into beacon
    install_id = options.get('sentry:install-id')
    if not install_id:
        logger.info('Generated installation ID: %s', install_id)
        install_id = sha1(uuid4().hex).hexdigest()
        options.set('sentry:install-id', install_id)

    internal_project_ids = filter(bool, [
        settings.SENTRY_PROJECT, settings.SENTRY_FRONTEND_PROJECT,
    ])
    platform_list = list(set(Project.objects.exclude(
        id__in=internal_project_ids,
    ).values_list('platform', flat=True)))

    payload = {
        'install_id': install_id,
        'version': sentry.get_version(),
        'admin_email': settings.SENTRY_ADMIN_EMAIL,
        'data': {
            # TODO(dcramer): we'd also like to get an idea about the throughput
            # of the system (i.e. events in 24h)
            'platforms': platform_list,
            'users': User.objects.count(),
            'projects': Project.objects.count(),
            'teams': Team.objects.count(),
            'organizations': Organization.objects.count(),
        }
    }

    # TODO(dcramer): relay the response 'notices' as admin broadcasts
    try:
        request = safe_urlopen(BEACON_URL, json=payload, timeout=5)
        response = safe_urlread(request)
    except Exception:
        logger.warning('Failed sending beacon', exc_info=True)
        return

    data = json.loads(response)
    if 'version' in data:
        options.set('sentry:latest_version', data['version']['stable'])
开发者ID:DZTPY,项目名称:sentry,代码行数:53,代码来源:beacon.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python permissions.can_admin_group函数代码示例发布时间:2022-05-27
下一篇:
Python options.get函数代码示例发布时间: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