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


Python Failure.printDetailedTraceback方法代码示例

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


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

示例1: write

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import printDetailedTraceback [as 别名]
 def write(self, data):
     """write data to some file like object only writes happen if debug was
        specified during instantiation.
     """
     if hasattr(self.fd, 'write') and hasattr(self.fd.write, '__call__') \
             and self.debug: #only write on debug true
         try:
             self.fd.write(str(data)+'\n')
         except:
             failure = Failure()
             if self.verbose: failure.printDetailedTraceback(sys.stderr)
             else: failure.printTraceback(sys.stderr)
开发者ID:DroneD,项目名称:droned,代码行数:14,代码来源:decorators.py

示例2: display_result

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import printDetailedTraceback [as 别名]
    def display_result(self, result):
        """display the result in debug mode, always display tracebacks
           on failure. this is callback safe. 

           @param result (object)
           @return (param -> result)
        """
        if isinstance(result, Failure):
            if hasattr(result.value, "__class__"):
                eName = result.value.__class__.__name__
            else:  # guess in event failure doesn't make sense
                try:  # preload and reset later
                    eName = sys.exc_info()[0].__name__
                except AttributeError:
                    eName = "Unknown"  # fail
                except:
                    failure = Failure()
                    self.write("Something bad has happened")
                    fd = self.fd
                    if not fd:
                        self.fd = sys.stderr
                    if self.verbose:
                        failure.printDetailedTraceback(self.fd)
                    else:
                        failure.printTraceback(self.fd)
                    # restore the previous fd object
                    self.fd = fd
                    return result
            self.write(">>> %s call raised %s" % (self.function.func_name, eName))
            # make sure the fd is valid for tracebacks
            fd = self.fd
            if not fd:
                self.fd = sys.stderr
            if self.verbose:
                result.printDetailedTraceback(self.fd)
            else:
                result.printTraceback(self.fd)
            # restore the previous fd object
            self.fd = fd
            self.write(">>>")
        else:
            self.write(">>> Returning %s -> %s" % (self.function.func_name, str(result)))
        return result
开发者ID:cbrinley,项目名称:droned,代码行数:45,代码来源:decorators.py


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