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


Python options.set函数代码示例

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


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


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