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


Python options.get函数代码示例

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


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

示例1: lookup_system_symbols

def lookup_system_symbols(symbols, sdk_info=None, cpu_name=None):
    """Looks for system symbols in the configured system server if
    enabled.  If this failes or the server is disabled, `None` is
    returned.
    """
    if not options.get('symbolserver.enabled'):
        return

    url = '%s/lookup' % options.get('symbolserver.options')['url'].rstrip('/')
    sess = Session()
    symbol_query = {
        'sdk_id': sdk_info_to_sdk_id(sdk_info),
        'cpu_name': cpu_name,
        'symbols': symbols,
    }

    attempts = 0

    with sess:
        while 1:
            try:
                rv = sess.post(url, json=symbol_query)
                # If the symbols server does not know about the SDK at all
                # it will report a 404 here.  In that case just assume
                # that we did not find a match and do not retry.
                if rv.status_code == 404:
                    return None
                rv.raise_for_status()
                return rv.json()['symbols']
            except (IOError, RequestException):
                attempts += 1
                if attempts > MAX_ATTEMPTS:
                    logger.error('Failed to contact system symbol server',
                                 exc_info=True)
                    return
开发者ID:duanshuaimin,项目名称:sentry,代码行数:35,代码来源:systemsymbols.py

示例2: test_simple

    def test_simple(self, safe_urlread, safe_urlopen):
        self.create_project(platform='java')

        safe_urlread.return_value = json.dumps({
            'notices': [],
            'version': {'stable': '1.0.0'},
        })

        with self.settings(SENTRY_ADMIN_EMAIL='[email protected]'):
            send_beacon()

        install_id = options.get('sentry:install-id')
        assert install_id and len(install_id) == 40

        safe_urlopen.assert_called_once_with(BEACON_URL, json={
            'install_id': install_id,
            'version': sentry.get_version(),
            'data': {
                'platforms': ['java'],
                'organizations': 2,
                'users': 2,
                'projects': 2,
                'teams': 2,
                'events.24h': 0,
            },
            'admin_email': '[email protected]',
        }, timeout=5)
        safe_urlread.assert_called_once_with(safe_urlopen.return_value)

        assert options.get('sentry:latest_version') == '1.0.0'
开发者ID:GpadillaQ,项目名称:sentry,代码行数:30,代码来源:test_beacon.py

示例3: test_simple

    def test_simple(self, safe_urlread, safe_urlopen,
                    mock_get_all_package_versions):
        mock_get_all_package_versions.return_value = {'foo': '1.0'}
        safe_urlread.return_value = json.dumps({
            'notices': [],
            'version': {'stable': '1.0.0'},
        })

        assert options.set('system.admin-email', '[email protected]')
        send_beacon()

        install_id = options.get('sentry:install-id')
        assert install_id and len(install_id) == 40

        safe_urlopen.assert_called_once_with(BEACON_URL, json={
            'install_id': install_id,
            'version': sentry.get_version(),
            'data': {
                'organizations': 1,
                'users': 0,
                'projects': 1,
                'teams': 1,
                'events.24h': 0,
            },
            'admin_email': '[email protected]',
            'packages': mock_get_all_package_versions.return_value,
        }, timeout=5)
        safe_urlread.assert_called_once_with(safe_urlopen.return_value)

        assert options.get('sentry:latest_version') == '1.0.0'
开发者ID:280185386,项目名称:sentry,代码行数:30,代码来源:test_beacon.py

示例4: has_apps_configured

 def has_apps_configured(self):
     return bool(
         options.get('github.apps-install-url') and
         options.get('github.integration-app-id') and
         options.get('github.integration-hook-secret') and
         options.get('github.integration-private-key')
     )
开发者ID:getsentry,项目名称:sentry-plugins,代码行数:7,代码来源:plugin.py

示例5: get_internal_source

def get_internal_source(project):
    """
    Returns the source configuration for a Sentry project.
    """
    internal_url_prefix = options.get('system.internal-url-prefix')
    if not internal_url_prefix:
        internal_url_prefix = options.get('system.url-prefix')
        if sys.platform == 'darwin':
            internal_url_prefix = internal_url_prefix \
                .replace("localhost", "host.docker.internal") \
                .replace("127.0.0.1", "host.docker.internal")

    assert internal_url_prefix
    sentry_source_url = '%s%s' % (
        internal_url_prefix.rstrip('/'),
        reverse('sentry-api-0-dsym-files', kwargs={
            'organization_slug': project.organization.slug,
            'project_slug': project.slug
        })
    )

    return {
        'type': 'sentry',
        'id': 'sentry:project',
        'url': sentry_source_url,
        'token': get_system_token(),
    }
开发者ID:getsentry,项目名称:sentry,代码行数:27,代码来源:symbolicator.py

示例6: _publish_to_kafka

    def _publish_to_kafka(self, request):
        """
        Sends raw event data to Kafka for later offline processing.
        """
        try:
            # This may fail when we e.g. send a multipart form. We ignore those errors for now.
            data = request.body

            if not data or len(data) > options.get('kafka-publisher.max-event-size'):
                return

            # Sampling
            if random.random() >= options.get('kafka-publisher.raw-event-sample-rate'):
                return

            # We want to send only serializable items from request.META
            meta = {}
            for key, value in request.META.items():
                try:
                    json.dumps([key, value])
                    meta[key] = value
                except (TypeError, ValueError):
                    pass

            meta['SENTRY_API_VIEW_NAME'] = self.__class__.__name__

            kafka_publisher.publish(
                channel=getattr(settings, 'KAFKA_RAW_EVENTS_PUBLISHER_TOPIC', 'raw-store-events'),
                value=json.dumps([meta, base64.b64encode(data)])
            )
        except Exception as e:
            logger.debug("Cannot publish event to Kafka: {}".format(e.message))
开发者ID:Kayle009,项目名称:sentry,代码行数:32,代码来源:api.py

示例7: get

    def get(self, request, organization):
        """
        Return chunk upload parameters
        ``````````````````````````````
        :auth: required
        """
        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')

        url = reverse('sentry-api-0-chunk-upload', args=[organization.slug])
        endpoint = urljoin(endpoint.rstrip('/') + '/', url.lstrip('/'))

        return Response(
            {
                'url': endpoint,
                'chunkSize': DEFAULT_BLOB_SIZE,
                'chunksPerRequest': MAX_CHUNKS_PER_REQUEST,
                'maxRequestSize': MAX_REQUEST_SIZE,
                'concurrency': MAX_CONCURRENCY,
                'hashAlgorithm': HASH_ALGORITHM,
                'compression': ['gzip'],
            }
        )
开发者ID:alexandrul,项目名称:sentry,代码行数:25,代码来源:chunk.py

示例8: 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

示例9: u2f_appid

def u2f_appid(request):
    facets = options.get("u2f.facets")
    if not facets:
        facets = [options.get("system.url-prefix")]
    return HttpResponse(
        json.dumps({"trustedFacets": [{"version": {"major": 1, "minor": 0}, "ids": [x.rstrip("/") for x in facets]}]}),
        content_type="application/fido.trusted-apps+json",
    )
开发者ID:ForkRepo,项目名称:sentry,代码行数:8,代码来源:twofactor.py

示例10: test_put_simple

 def test_put_simple(self):
     self.login_as(user=self.user)
     assert options.get('mail.host') != 'lolcalhost'
     response = self.client.put(self.url, {
         'mail.host': 'lolcalhost',
     })
     assert response.status_code == 200
     assert options.get('mail.host') == 'lolcalhost'
开发者ID:280185386,项目名称:sentry,代码行数:8,代码来源:test_system_options.py

示例11: status_mail

def status_mail(request):
    form = TestEmailForm(request.POST or None)

    if form.is_valid():
        body = """This email was sent as a request to test the Sentry outbound email configuration."""
        try:
            send_mail(
                "%s Test Email" % (options.get("mail.subject-prefix"),),
                body,
                options.get("mail.from"),
                [request.user.email],
                fail_silently=False,
            )
        except Exception as e:
            form.errors["__all__"] = [six.text_type(e)]

    return render_to_response(
        "sentry/admin/status/mail.html",
        {
            "form": form,
            "mail_host": options.get("mail.host"),
            "mail_password": bool(options.get("mail.password")),
            "mail_username": options.get("mail.username"),
            "mail_port": options.get("mail.port"),
            "mail_use_tls": options.get("mail.use-tls"),
            "mail_from": options.get("mail.from"),
            "mail_list_namespace": options.get("mail.list-namespace"),
        },
        request,
    )
开发者ID:GeekGalaxy,项目名称:sentry,代码行数:30,代码来源:admin.py

示例12: status_mail

def status_mail(request):
    form = TestEmailForm(request.POST or None)

    if form.is_valid():
        body = """This email was sent as a request to test the Sentry outbound email configuration."""
        try:
            send_mail(
                '%s Test Email' % (options.get('mail.subject-prefix'), ),
                body,
                options.get('mail.from'), [request.user.email],
                fail_silently=False
            )
        except Exception as e:
            form.errors['__all__'] = [six.text_type(e)]

    return render_to_response(
        'sentry/admin/status/mail.html', {
            'form': form,
            'mail_host': options.get('mail.host'),
            'mail_password': bool(options.get('mail.password')),
            'mail_username': options.get('mail.username'),
            'mail_port': options.get('mail.port'),
            'mail_use_tls': options.get('mail.use-tls'),
            'mail_from': options.get('mail.from'),
            'mail_list_namespace': options.get('mail.list-namespace'),
        }, request
    )
开发者ID:NuttasitBoonwat,项目名称:sentry,代码行数:27,代码来源:admin.py

示例13: get_storage

def get_storage():
    from sentry import options
    backend = options.get('filestore.backend')
    options = options.get('filestore.options')

    try:
        backend = settings.SENTRY_FILESTORE_ALIASES[backend]
    except KeyError:
        pass

    storage = get_storage_class(backend)
    return storage(**options)
开发者ID:alexandrul,项目名称:sentry,代码行数:12,代码来源:file.py

示例14: u2f_appid

def u2f_appid(request):
    facets = options.get('u2f.facets')
    if not facets:
        facets = [options.get('system.url-prefix')]
    return HttpResponse(json.dumps({
        'trustedFacets': [{
            'version': {
                'major': 1,
                'minor': 0
            },
            'ids': [x.rstrip('/') for x in facets]
        }]
    }), content_type='application/fido.trusted-apps+json')
开发者ID:Akashguharoy,项目名称:sentry,代码行数:13,代码来源:twofactor.py

示例15: _is_symbolicator_enabled

def _is_symbolicator_enabled(project, data):
    if not options.get('symbolicator.enabled'):
        return False

    if project.get_option('sentry:symbolicator-enabled'):
        return True

    percentage = options.get('sentry:symbolicator-percent-opt-in') or 0
    if percentage > 0:
        id_bit = int(data['event_id'][4:6], 16)
        return id_bit < percentage * 256

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


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