本文整理汇总了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)
示例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