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


Python Failure.printTraceback方法代码示例

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


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

示例1: dispatch

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import printTraceback [as 别名]
 def dispatch(self, *a, **k):
     for handler in self._listeners:
         try:
             handler(*a, **k)
         except Exception, e:
             f = Failure(e)
             f.printTraceback()
             log.err(e)
开发者ID:csv,项目名称:beatlounge,代码行数:10,代码来源:base.py

示例2: handle

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import printTraceback [as 别名]
 def handle(self, message, address):
     try:
         (v,) = message.arguments
         self.dispatch(self._transform(float(v)))
     except Exception, e:
         f = Failure(e)
         f.printTraceback()
         log.msg('[FloatDispatcher.handle] error', e)
开发者ID:csv,项目名称:beatlounge,代码行数:10,代码来源:base.py

示例3: write

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import printTraceback [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

示例4: display_result

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import printTraceback [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

示例5: run

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import printTraceback [as 别名]
    def run(self):
        """
        Function that does common PUT/COPY/MOVE behavior.

        @return: a Deferred with a status response result.
        """

        try:
            reservation = None
            
            # Handle all validation operations here.
            yield self.fullValidation()

            # Reservation and UID conflict checking is next.
            if self.destinationadbk:    
                # Reserve UID
                self.destination_index = self.destinationparent.index()
                reservation = StoreAddressObjectResource.UIDReservation(
                    self.destination_index, self.uid, self.destination_uri
                )
                if self.indexdestination:
                    yield reservation.reserve()
            
                # UID conflict check - note we do this after reserving the UID to avoid a race condition where two requests
                # try to write the same vcard data to two different resource URIs.
                result, message, rname = self.noUIDConflict(self.uid)
                if not result:
                    log.err(message)
                    raise HTTPError(ErrorResponse(responsecode.FORBIDDEN,
                        NoUIDConflict(davxml.HRef.fromString(joinURL(parentForURL(self.destination_uri), rname.encode("utf-8"))))
                    ))
            
            # Get current quota state.
            yield self.checkQuota()

            # Do the actual put or copy
            response = (yield self.doStore())
            
            # Remember the resource's content-type.
            if self.destinationadbk:
                content_type = self.request.headers.getHeader("content-type")
                if content_type is None:
                    content_type = MimeType("text", "vcard",
                                            params={"charset":"utf-8"})
                self.destination.writeDeadProperty(
                    davxml.GETContentType.fromString(generateContentType(content_type))
                )

            # Delete the original source if needed.
            if self.deletesource:
                yield self.doSourceQuotaCheck()

            # Do quota check on destination
            if self.destquota is not None:
                yield self.doDestinationQuotaCheck()
    
            if reservation:
                yield reservation.unreserve()
    
            returnValue(response)
    
        except Exception, err:
            # Preserve the real traceback to display later, since the error-
            # handling here yields out of the generator and thereby shreds the
            # stack.
            f = Failure()

            if reservation:
                yield reservation.unreserve()
    
            # FIXME: transaction needs to be rolled back.

            # Display the traceback.  Unfortunately this will usually be
            # duplicated by the higher-level exception handler that captures
            # the thing that raises here, but it's better than losing the
            # information.
            f.printTraceback()

            raise err
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:81,代码来源:put_addressbook_common.py


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