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


Python Client.send方法代码示例

本文整理汇总了Python中raven.Client.send方法的典型用法代码示例。如果您正苦于以下问题:Python Client.send方法的具体用法?Python Client.send怎么用?Python Client.send使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在raven.Client的用法示例。


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

示例1: send_to_sentry

# 需要导入模块: from raven import Client [as 别名]
# 或者: from raven.Client import send [as 别名]
def send_to_sentry(report):
    sentry_report = create_sentry_report(report)
    if not sentry_report:
        return

    for dsn, report in get_dsn_report_pairs(sentry_report):
        logger.info("Sending to {}.".format(dsn))
        try:
            client = Client(dsn, raise_send_errors=True)
            client.send(**report)
        except Exception as ex:
            # There is nothing we can do if sentry is not available
            logger.exception("Sending report failed: {}.".format(ex))
        else:
            logger.info("Report has been sent to sentry.")
开发者ID:acopar,项目名称:orange-web,代码行数:17,代码来源:sentry.py

示例2: send

# 需要导入模块: from raven import Client [as 别名]
# 或者: from raven.Client import send [as 别名]
    def send(self, timeout):
        """Submit the error including the user feedback. Blocking.

        Args:
            timeout (float): timeout for each request made
        Returns:
            str: The sentry event id
        Raises:
            SentryError
        """

        from raven import Client
        from raven.transport import http
        from raven.transport.http import HTTPTransport

        http.urlopen = urlopen_hack

        try:
            raise Exception
        except Exception:
            client = Client(
                self._dsn + "?timeout=%d" % timeout, install_sys_hook=False,
                install_logging_hook=False, capture_locals=False,
                transport=HTTPTransport)

            # replace the captured data with the one we already have
            old_send = client.send

            def inject_data(*args, **kwargs):
                kw = dict(self._kwargs)
                kw["event_id"] = kwargs.get("event_id", "")
                return old_send(*self._args, **kw)

            client.send = inject_data

            event_id = client.captureException()
            if client.state.did_fail():
                raise SentryError("captureException failed")

            # fix leak
            client.context.deactivate()

            if self._comment:
                send_feedback(self._dsn, event_id,
                              "default", "[email protected]", self._comment,
                              timeout)

            return event_id
开发者ID:zsau,项目名称:quodlibet,代码行数:50,代码来源:sentrywrapper.py

示例3: capture

# 需要导入模块: from raven import Client [as 别名]
# 或者: from raven.Client import send [as 别名]
    def capture(self, exc_info=None, fingerprint=None):
        """Captures the current exception and returns a CapturedException

        The returned object contains everything needed to submit the error
        at a later point in time (e.g. after pushing it to the main thread
        and displaying it in the UI)

        Args:
            exc_info (tuple): a sys.exc_info() return value
            fingerprint (List[str] or None):
                fingerprint for custom grouping
        Returns:
            CapturedException
        Raises:
            SentryError: Raised if raven isn't installed or capturing failed
                for some unknown reason.
        """

        try:
            from raven import Client
            from raven.transport import Transport
            from raven.processors import Processor
        except ImportError as e:
            raise SentryError(e)

        class DummyTransport(Transport):
            """A sync raven transport which does nothing"""

            def send(self, *args, **kwargs):
                pass

        # Some tags have a special meaning and conflict with info given to the
        # client, so pass them to the client instead
        tags = dict(self._tags)
        kwargs = {}
        if "release" in tags:
            kwargs["release"] = tags.pop("release")
        if "environment" in tags:
            kwargs["environment"] = tags.pop("environment")
        if "server_name" in tags:
            kwargs["name"] = tags.pop("server_name")

        # It would default to the hostname otherwise
        kwargs.setdefault("name", "default")

        # We use a dummy transport and intercept the captured data
        client = Client(
            self._dsn, install_sys_hook=False, install_logging_hook=False,
            capture_locals=True, transport=DummyTransport, tags=tags, **kwargs)

        data = [None]

        old_send = client.send

        def save_state(*args, **kwargs):
            data[0] = (args, kwargs)
            return old_send(*args, **kwargs)

        client.send = save_state
        client.captureException(exc_info, fingerprint=fingerprint)
        if data[0] is None:
            raise SentryError("Failed to capture")

        class SanitizePaths(Processor):
            """Makes filename on Windows match the Linux one.
            Also adjust abs_path, so it still contains filename.
            """

            def filter_stacktrace(self, data, **kwargs):
                for frame in data.get('frames', []):
                    if frame.get("abs_path"):
                        frame["abs_path"] = \
                            frame["abs_path"].replace(os.sep, "/")
                    if frame.get("filename"):
                        frame["filename"] = \
                            frame["filename"].replace(os.sep, "/")

        SanitizePaths(client).process(data[0][1])

        # fix leak
        client.context.deactivate()

        return CapturedException(self._dsn, data[0])
开发者ID:zsau,项目名称:quodlibet,代码行数:85,代码来源:sentrywrapper.py

示例4: len

# 需要导入模块: from raven import Client [as 别名]
# 或者: from raven.Client import send [as 别名]
        netloc = url.hostname
        netloc += ':%s' % url.port

        path_bits = url.path.rsplit('/', 1)
        if len(path_bits) > 1:
            path = path_bits[0]
        else:
            path = ''
        project = path_bits[-1]

        if not all([netloc, project, url.username, url.password]):
            raise ValueError('Invalid Sentry DSN: %r' % url.geturl())

        server = '%s://%s%s/api/store/' % (url.scheme, netloc, path)

        # Note that these variables in the scope are not actually used
        # for anything w.r.t the DummyTransport
        scope.update({
            'SENTRY_SERVERS': [server],
            'SENTRY_PROJECT': project,
            'SENTRY_PUBLIC_KEY': url.username,
            'SENTRY_SECRET_KEY': url.password,
        })
        return scope


Client.register_scheme('mock', DummyScheme)
c = Client(dsn="mock://some_username:[email protected]:8143/1")
c.send(a=42, b=55, c=range(50))

开发者ID:crankycoder,项目名称:sandbox,代码行数:31,代码来源:raven_ng.py


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