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


Python traceback.format_stack方法代码示例

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


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

示例1: log

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import format_stack [as 别名]
def log(msg, msgx='', level=logging.INFO, need_tb=False):
    """
    Logging in UCC Config Module.
    :param msg: message content
    :param msgx: detail info.
    :param level: logging level
    :param need_tb: if need logging traceback
    :return:
    """
    global LOGGING_STOPPED
    if LOGGING_STOPPED:
        return

    msgx = ' - ' + msgx if msgx else ''
    content = 'UCC Config Module: %s%s' % (msg, msgx)
    if need_tb:
        stack = ''.join(traceback.format_stack())
        content = '%s\r\n%s' % (content, stack)
    stulog.logger.log(level, content, exc_info=1) 
开发者ID:remg427,项目名称:misp42splunk,代码行数:21,代码来源:config.py

示例2: error

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import format_stack [as 别名]
def error(message: str, *, stack: str = None, replace: bool = False) -> None:
    """Display an error message.

    Args:
        message: The message to show.
        stack: The stack trace to show (if any).
        replace: Replace existing messages which are still being shown.
    """
    if stack is None:
        stack = ''.join(traceback.format_stack())
        typ = 'error'
    else:
        typ = 'error (from exception)'
    _log_stack(typ, stack)
    log.message.error(message)
    global_bridge.show(usertypes.MessageLevel.error, message, replace) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:18,代码来源:message.py

示例3: _do_get

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import format_stack [as 别名]
def _do_get(self):
        if self._checked_out:
            if self._checkout_traceback:
                suffix = ' at:\n%s' % ''.join(
                    chop_traceback(self._checkout_traceback))
            else:
                suffix = ''
            raise AssertionError("connection is already checked out" + suffix)

        if not self._conn:
            self._conn = self._create_connection()

        self._checked_out = True
        if self._store_traceback:
            self._checkout_traceback = traceback.format_stack()
        return self._conn 
开发者ID:jpush,项目名称:jbox,代码行数:18,代码来源:pool.py

示例4: thread_stacktraces

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import format_stack [as 别名]
def thread_stacktraces():
  """
  Provides a dump of the stacktrace information for all active threads.

  :returns: **dict** that maps thread names to their stacktrace
  """

  stacktraces = {}

  for thread in threading.enumerate():
    frame = sys._current_frames().get(thread.ident, None)

    if frame:
      stacktraces[thread.name] = ''.join(traceback.format_stack(frame))
    else:
      stacktraces[thread.name] = 'No traceback available'

  return stacktraces 
开发者ID:torproject,项目名称:stem,代码行数:20,代码来源:output.py

示例5: tryLock

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import format_stack [as 别名]
def tryLock(self, timeout=None, id=None):
        if timeout is None:
            locked = QtCore.QMutex.tryLock(self)
        else:
            locked = QtCore.QMutex.tryLock(self, timeout)

        if self.debug and locked:
            self.l.lock()
            try:
                if id is None:
                    self.tb.append(''.join(traceback.format_stack()[:-1]))
                else:
                    self.tb.append("  " + str(id))
                #print 'trylock', self, len(self.tb)
            finally:
                self.l.unlock()
        return locked 
开发者ID:SrikanthVelpuri,项目名称:tf-pose,代码行数:19,代码来源:mutex.py

示例6: _startRunCallbacks

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import format_stack [as 别名]
def _startRunCallbacks(self, result):
        if self.called:
            if self._suppressAlreadyCalled:
                self._suppressAlreadyCalled = False
                return
            if self.debug:
                if self._debugInfo is None:
                    self._debugInfo = DebugInfo()
                extra = "\n" + self._debugInfo._getDebugTracebacks()
                raise AlreadyCalledError(extra)
            raise AlreadyCalledError
        if self.debug:
            if self._debugInfo is None:
                self._debugInfo = DebugInfo()
            self._debugInfo.invoker = traceback.format_stack()[:-2]
        self.called = True
        self.result = result
        self._runCallbacks() 
开发者ID:proxysh,项目名称:Safejumper-for-Desktop,代码行数:20,代码来源:defer.py

示例7: inspect_threads

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import format_stack [as 别名]
def inspect_threads(thread_names=[]):
    """inspect_threads() -> {thread_name: {"locals": {}, "stack": ""}} : return threads' locals and stack"""
    import threading
    import sys
    import traceback
    pylane_thread_name = "pylane-shell-thread"
    stacks = {}
    frames = sys._current_frames()
    threads = threading.enumerate()
    for thread in threads:
        if thread.name == pylane_thread_name:
            continue
        if thread_names and thread.name not in thread_names:
            continue
        frame = frames.get(thread.ident)
        stack = ''.join(traceback.format_stack(frame)) if frame else ''
        stacks[thread.name] = {
            "locals": frame.f_locals,
            "stack": stack
        }
    return stacks 
开发者ID:NtesEyes,项目名称:pylane,代码行数:23,代码来源:help_functions.py

示例8: format_error

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import format_stack [as 别名]
def format_error(e):
    # errback automatically wraps everything in a Twisted Failure
    if isinstance(e, failure.Failure):
        e = e.value

    if isinstance(e, str):
        err_string = e
    elif six.PY2:
        err_string = traceback.format_exc(e).rstrip()
    else:
        err_string = ''.join(traceback.format_exception(type(e), e, e.__traceback__)).rstrip()

    if err_string == 'None':
        # Reasonable heuristic for exceptions that were created by hand
        last = traceback.format_stack()[-2]
        err_string = '{}\n  {}'.format(e, last)
    # Quick and dirty hack for now.
    err_string = err_string.replace('Connection to the other side was lost in a non-clean fashion', 'Connection to the other side was lost in a non-clean fashion (HINT: this generally actually means we got a connection refused error. Check that the remote is actually running.)')
    return error.Error(err_string) 
开发者ID:openai,项目名称:universe,代码行数:21,代码来源:__init__.py

示例9: retain_error

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import format_stack [as 别名]
def retain_error(self, error, frame=None):
        """
        Adds details of an error to the report.

        :param error: The error exception to add to the report.
        """
        if frame is None:
            stack = traceback.format_exc()
            self.labels.add("@iopipe/error")
        else:
            stack = "\n".join(traceback.format_stack(frame))
            self.labels.add("@iopipe/timeout")
        details = {
            "name": type(error).__name__,
            "message": "{}".format(error),
            "stack": stack,
        }
        self.report["errors"] = details 
开发者ID:iopipe,项目名称:iopipe-python,代码行数:20,代码来源:report.py

示例10: debug_signal

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import format_stack [as 别名]
def debug_signal(signum, frame):
    import sys, traceback
    for thread_id, stack in sys._current_frames().iteritems():
        print('Thread id: %s\n%s' % (thread_id, ''.join(traceback.format_stack(stack)))) 
开发者ID:sippy,项目名称:rtp_cluster,代码行数:6,代码来源:rtp_cluster.py

示例11: _assert

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import format_stack [as 别名]
def _assert(condition):
    if not condition:
        sys.stderr.write(''.join(traceback.format_stack()[:-1]))
        comm.Abort() 
开发者ID:pyscf,项目名称:pyscf,代码行数:6,代码来源:mpi.py

示例12: log_expect_failure

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import format_stack [as 别名]
def log_expect_failure(self, expected_pattern):
        self.write_result("\n\n*** Did not find expected pattern {}\n\n".format(expected_pattern))
        # Generate a call stack in rift_expect.log for easier debugging
        # But pytest call stacks are very deep, so only show the "interesting" lines
        for line in traceback.format_stack():
            if "tests/" in line:
                self.write_result(line.strip())
                self.write_result("\n") 
开发者ID:brunorijsman,项目名称:rift-python,代码行数:10,代码来源:rift_expect_session.py

示例13: expect_failure

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import format_stack [as 别名]
def expect_failure(self, msg):
        self._results_file.write(msg + "\n\n")
        # Generate a call stack in rift_expect.log for easier debugging
        # But pytest call stacks are very deep, so only show the "interesting" lines
        for line in traceback.format_stack():
            if "tests/" in line:
                self._results_file.write(line.strip())
                self._results_file.write("\n")
        assert False, msg + " (see log_expect.log for details)" 
开发者ID:brunorijsman,项目名称:rift-python,代码行数:11,代码来源:log_expect_session.py

示例14: log_expect_failure

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import format_stack [as 别名]
def log_expect_failure(self):
        self.write_result("\n\n*** Did not find expected pattern\n\n")
        # Generate a call stack in the log file for easier debugging
        for line in traceback.format_stack():
            self.write_result(line.strip())
            self.write_result("\n") 
开发者ID:brunorijsman,项目名称:rift-python,代码行数:8,代码来源:config_generator.py

示例15: log_stack

# 需要导入模块: import traceback [as 别名]
# 或者: from traceback import format_stack [as 别名]
def log_stack(self, signal, frame):
        """Signal handler to log the stack trace of the current thread.

        For use with `set_blocking_signal_threshold`.
        """
        gen_log.warning('IOLoop blocked for %f seconds in\n%s',
                        self._blocking_signal_threshold,
                        ''.join(traceback.format_stack(frame))) 
开发者ID:tao12345666333,项目名称:tornado-zh,代码行数:10,代码来源:ioloop.py


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