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


Python utils.get_auth_header函数代码示例

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


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

示例1: send_encoded

    def send_encoded(self, message, auth_header=None, **kwargs):
        """
        Given an already serialized message, signs the message and passes the
        payload off to ``send_remote``.
        """
        client_string = 'raven-python/%s' % (raven.VERSION,)

        if not auth_header:
            timestamp = time.time()
            auth_header = get_auth_header(
                protocol=self.protocol_version,
                timestamp=timestamp,
                client=client_string,
                api_key=self.remote.public_key,
                api_secret=self.remote.secret_key,
            )

        headers = {
            'User-Agent': client_string,
            'X-Sentry-Auth': auth_header,
            'Content-Encoding': self.get_content_encoding(),
            'Content-Type': 'application/octet-stream',
        }

        self.send_remote(
            url=self.remote.store_endpoint,
            data=message,
            headers=headers,
            **kwargs
        )
开发者ID:xmonster-tech,项目名称:raven-python,代码行数:30,代码来源:base.py

示例2: send_encoded

    def send_encoded(self, message, public_key=None, auth_header=None, **kwargs):
        """
        Given an already serialized message, signs the message and passes the
        payload off to ``send_remote`` for each server specified in the servers
        configuration.
        """
        if not self.servers:
            warnings.warn('Raven client has no remote servers configured')
            return

        client_string = 'raven-python/%s' % (raven.VERSION,)

        if not auth_header:
            timestamp = time.time()
            auth_header = get_auth_header(
                protocol=self.protocol_version,
                timestamp=timestamp,
                client=client_string,
                api_key=public_key or self.public_key
            )

        for url in self.servers:
            headers = {
                'User-Agent': client_string,
                'X-Sentry-Auth': auth_header,
                'Content-Type': 'application/octet-stream',
            }

            self.send_remote(url=url, data=message, headers=headers)
开发者ID:akbargumbira,项目名称:inasafe,代码行数:29,代码来源:base.py

示例3: send

    def send(self, **data):
        """
        Sends the message to the server.

        If ``servers`` was passed into the constructor, this will serialize the data and pipe it to
        each server using ``send_remote()``. Otherwise, this will communicate with ``sentry.models.GroupedMessage``
        directly.
        """
        message = base64.b64encode(json.dumps(data).encode('zlib'))

        for url in self.servers:
            timestamp = time.time()
            signature = get_signature(message, timestamp, self.secret_key or self.key)
            headers = {
                'X-Sentry-Auth': get_auth_header(signature, timestamp, 'raven/%s' % (raven.VERSION,), self.public_key),
                'Content-Type': 'application/octet-stream',
            }

            try:
                self.send_remote(url=url, data=message, headers=headers)
            except urllib2.HTTPError, e:
                body = e.read()
                self.logger.error('Unable to reach Sentry log server: %s (url: %%s, body: %%s)' % (e,), url, body,
                             exc_info=True, extra={'data': {'body': body, 'remote_url': url}})
                self.logger.log(data.pop('level', None) or logging.ERROR, data.pop('message', None))
            except urllib2.URLError, e:
                self.logger.error('Unable to reach Sentry log server: %s (url: %%s)' % (e,), url,
                             exc_info=True, extra={'data': {'remote_url': url}})
                self.logger.log(data.pop('level', None) or logging.ERROR, data.pop('message', None))
开发者ID:Lothiraldan,项目名称:raven,代码行数:29,代码来源:base.py

示例4: send_encoded

    def send_encoded(self, message, auth_header=None, **kwargs):
        """
        Given an already serialized message, signs the message and passes the
        payload off to ``send_remote`` for each server specified in the servers
        configuration.
        """
        client_string = "raven-python/%s" % (raven.VERSION,)

        if not auth_header:
            timestamp = time.time()
            auth_header = get_auth_header(
                protocol=self.protocol_version,
                timestamp=timestamp,
                client=client_string,
                api_key=self.remote.public_key,
                api_secret=self.remote.secret_key,
            )

        headers = {
            "User-Agent": client_string,
            "X-Sentry-Auth": auth_header,
            "Content-Encoding": self.get_content_encoding(),
            "Content-Type": "application/octet-stream",
        }

        self.send_remote(url=self.remote.store_endpoint, data=message, headers=headers, **kwargs)
开发者ID:HPotter,项目名称:raven-python,代码行数:26,代码来源:base.py

示例5: send_encoded

    def send_encoded(self, message, auth_header=None, **kwargs):
        """
        Given an already serialized message, signs the message and passes the
        payload off to ``send_remote`` for each server specified in the servers
        configuration.

        callback can be specified as a keyword argument
        """
        if not auth_header:
            timestamp = time.time()
            auth_header = get_auth_header(
                protocol=self.protocol_version,
                timestamp=timestamp,
                client='raven-python/%s' % (raven.VERSION,),
                api_key=self.public_key,
                api_secret=self.secret_key,
            )

        for url in self.servers:
            headers = {
                'X-Sentry-Auth': auth_header,
                'Content-Type': 'application/octet-stream',
            }

            self.send_remote(
                url=url, data=message, headers=headers,
                callback=kwargs.get('callback', None)
            )
开发者ID:DriverX,项目名称:raven-python,代码行数:28,代码来源:__init__.py

示例6: send_encoded

    def send_encoded(self, message, public_key=None, auth_header=None, **kwargs):
        """
        Given an already serialized message, signs the message and passes the
        payload off to ``send_remote`` for each server specified in the servers
        configuration.

        callback can be specified as a keyword argument
        """
        if not self.servers:
            warnings.warn("Raven client has no remote servers configured")
            return

        if not auth_header:
            timestamp = time.time()
            auth_header = get_auth_header(
                protocol=self.protocol_version,
                timestamp=timestamp,
                client="raven-python/%s" % (raven.VERSION,),
                api_key=public_key or self.public_key,
            )

        for url in self.servers:
            headers = {"X-Sentry-Auth": auth_header, "Content-Type": "application/octet-stream"}

            self.send_remote(url=url, data=message, headers=headers, callback=kwargs.get("callback", None))
开发者ID:koordinates,项目名称:raven,代码行数:25,代码来源:__init__.py

示例7: send

    def send(self, **kwargs):
        # These imports all need to be internal to this function as this class
        # is set up by django while still parsing LOGGING settings and we
        # cannot import this stuff until settings are finalized.
        from sentry.web.api import StoreView
        from django.test import RequestFactory

        # Report the issue to an upstream Sentry if active
        # NOTE: we don't want to check self.is_enabled() like normal, since
        # is_enabled behavior is overridden in this class. We explicitly
        # want to check if the remote is active.
        if self.remote.is_active():
            from sentry import options
            # Append some extra tags that are useful for remote reporting
            super_kwargs = copy.deepcopy(kwargs)
            super_kwargs['tags']['install-id'] = options.get('sentry:install-id')
            super(SentryInternalClient, self).send(**super_kwargs)

        if not is_current_event_safe():
            self.error_logger.warn('internal-error.unsafe-stacktrace')
            return

        key = self.project_key
        if key is None:
            return

        client_string = 'raven-python/{}'.format(raven.VERSION)
        headers = {
            'HTTP_X_SENTRY_AUTH': get_auth_header(
                protocol=self.protocol_version,
                timestamp=time(),
                client=client_string,
                api_key=key.public_key,
                api_secret=key.secret_key,
            ),
            'HTTP_CONTENT_ENCODING': self.get_content_encoding(),
        }
        self.request_factory = self.request_factory or RequestFactory()
        request = self.request_factory.post(
            '/api/{}/store/'.format(key.project_id),
            data=self.encode(kwargs),
            content_type='application/octet-stream',
            **headers
        )
        resp = StoreView.as_view()(
            request,
            project_id=six.text_type(key.project_id),
        )
        if resp.status_code != 200:
            self.error_logger.warn('internal-error.invalid-response', extra={
                'project_id': settings.SENTRY_PROJECT,
                'project_key': settings.SENTRY_PROJECT_KEY,
                'status_code': resp.status_code,
            })
开发者ID:mjumbewu,项目名称:sentry,代码行数:54,代码来源:raven.py

示例8: send

    def send(self, **kwargs):
        # Report the issue to an upstream Sentry if active
        # NOTE: we don't want to check self.is_enabled() like normal, since
        # is_enabled behavior is overridden in this class. We explicitly
        # want to check if the remote is active.
        if self.remote.is_active():
            from sentry import options
            # Append some extra tags that are useful for remote reporting
            super_kwargs = copy.deepcopy(kwargs)
            super_kwargs['tags']['install-id'] = options.get('sentry:install-id')
            super(SentryInternalClient, self).send(**super_kwargs)

        if not is_current_event_safe():
            return

        # These imports all need to be internal to this function as this class
        # is set up by django while still parsing LOGGING settings and we
        # cannot import this stuff until settings are finalized.
        from sentry.models import ProjectKey
        from sentry.web.api import StoreView
        from django.test import RequestFactory
        key = None
        if settings.SENTRY_PROJECT_KEY is not None:
            key = ProjectKey.objects.filter(
                id=settings.SENTRY_PROJECT_KEY,
                project=settings.SENTRY_PROJECT).first()
        if key is None:
            key = ProjectKey.get_default(settings.SENTRY_PROJECT)
        if key is None:
            return

        client_string = 'raven-python/%s' % (raven.VERSION,)
        headers = {
            'HTTP_X_SENTRY_AUTH': get_auth_header(
                protocol=self.protocol_version,
                timestamp=time.time(),
                client=client_string,
                api_key=key.public_key,
                api_secret=key.secret_key,
            ),
            'HTTP_CONTENT_ENCODING': self.get_content_encoding(),
        }
        self.request_factory = self.request_factory or RequestFactory()
        request = self.request_factory.post(
            '/api/store',
            data=self.encode(kwargs),
            content_type='application/octet-stream',
            **headers
        )
        StoreView.as_view()(
            request,
            project_id=six.text_type(settings.SENTRY_PROJECT),
        )
开发者ID:binlee1990,项目名称:sentry,代码行数:53,代码来源:raven.py

示例9: test_no_secret_key

    def test_no_secret_key(self):
        dsn = 'https://[email protected]/1'
        res = RemoteConfig.from_string(dsn)
        assert res.project == '1'
        assert res.base_url == 'https://sentry.local'
        assert res.store_endpoint == 'https://sentry.local/api/1/store/'
        assert res.public_key == 'foo'
        assert res.secret_key is None
        assert res.options == {}
        assert res.is_active()

        assert get_auth_header(protocol=7, timestamp=42,
                               client='raven-python/1.0',
                               api_key=res.public_key) == (
            'Sentry sentry_timestamp=42, sentry_client=raven-python/1.0, '
            'sentry_version=7, sentry_key=foo')
开发者ID:ehfeng,项目名称:raven-python,代码行数:16,代码来源:tests.py

示例10: send

    def send(self, **data):
        """
        Sends the message to the server.

        If ``servers`` was passed into the constructor, this will serialize the data and pipe it to
        each server using ``send_remote()``. Otherwise, this will communicate with ``sentry.models.GroupedMessage``
        directly.
        """
        message = base64.b64encode(json.dumps(data).encode('zlib'))

        for url in self.servers:
            timestamp = time.time()
            signature = get_signature(message, timestamp, self.secret_key or self.key)
            headers = {
                'X-Sentry-Auth': get_auth_header(signature, timestamp, 'raven/%s' % (raven.VERSION,), self.public_key),
                'Content-Type': 'application/octet-stream',
            }

            self.send_remote(url=url, data=message, headers=headers)
开发者ID:mahendra,项目名称:raven,代码行数:19,代码来源:base.py

示例11: send_encoded

    def send_encoded(self, message):
        """
        Given an already serialized message, signs the message and passes the payload
        off to ``send_remote`` for each server specified in the servers configuration.
        """
        for url in self.servers:
            timestamp = time.time()
            signature = get_signature(message, timestamp, self.secret_key or self.key)
            headers = {
                'X-Sentry-Auth': get_auth_header(
                    protocol=self.protocol_version,
                    signature=signature,
                    timestamp=timestamp,
                    client='raven-python/%s' % (raven.VERSION,),
                    api_key=self.public_key
                ),
                'Content-Type': 'application/octet-stream',
            }

            self.send_remote(url=url, data=message, headers=headers)
开发者ID:andymccurdy,项目名称:raven,代码行数:20,代码来源:base.py

示例12: send

    def send(self, **kwargs):
        """
        Sends the message to the server.

        If ``servers`` was passed into the constructor, this will serialize the data and pipe it to
        each server using ``send_remote()``. Otherwise, this will communicate with ``sentry.models.GroupedMessage``
        directly.
        """
        message = base64.b64encode(json.dumps(kwargs).encode("zlib"))
        for url in self.servers:
            timestamp = time.time()
            signature = get_signature(self.key, message, timestamp)
            headers = {
                "Authorization": get_auth_header(
                    signature, timestamp, "%s/%s" % (self.__class__.__name__, raven.VERSION)
                ),
                "Content-Type": "application/octet-stream",
            }

            try:
                self.send_remote(url=url, data=message, headers=headers)
            except urllib2.HTTPError, e:
                body = e.read()
                logger.error(
                    "Unable to reach Sentry log server: %s (url: %%s, body: %%s)" % (e,),
                    url,
                    body,
                    exc_info=True,
                    extra={"data": {"body": body, "remote_url": url}},
                )
                logger.log(kwargs.pop("level", None) or logging.ERROR, kwargs.pop("message", None))
            except urllib2.URLError, e:
                logger.error(
                    "Unable to reach Sentry log server: %s (url: %%s)" % (e,),
                    url,
                    exc_info=True,
                    extra={"data": {"remote_url": url}},
                )
                logger.log(kwargs.pop("level", None) or logging.ERROR, kwargs.pop("message", None))
开发者ID:ncfcmark,项目名称:raven-python,代码行数:39,代码来源:base.py


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