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


Python Failure.getErrorMessage方法代码示例

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


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

示例1: _do_get_connection

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import getErrorMessage [as 别名]
def _do_get_connection(account, conductor, ready, retries_left, backoff):
    this_ready = defer.Deferred()
    factory = ImapClientFactory(account, conductor, this_ready)
    factory.connect()
    try:
        conn = yield this_ready
        # yay - report we are good and tell the real callback we have it.
        account.reportStatus(brat.EVERYTHING, brat.GOOD)
        ready.callback(conn)
    except Exception, exc:
        fail = Failure()
        logger.debug("first chance connection error handling: %s\n%s", fail.getErrorMessage(), fail.getBriefTraceback())
        retries_left -= 1
        if retries_left <= 0:
            ready.errback(fail)
        else:
            status = failure_to_status(fail)
            account.reportStatus(**status)
            acct_id = account.details.get("id", "")
            logger.warning(
                "Failed to connect to account %r, will retry after %s secs: %s",
                acct_id,
                backoff,
                fail.getErrorMessage(),
            )
            next_backoff = min(backoff * 2, MAX_BACKOFF)  # magic number
            conductor.reactor.callLater(
                backoff, _do_get_connection, account, conductor, ready, retries_left, next_backoff
            )
开发者ID:anuarcs,项目名称:raindrop,代码行数:31,代码来源:imap.py

示例2: __unexpectedError

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import getErrorMessage [as 别名]
 def __unexpectedError(self, failure=None, task=None):
     self._fireStatusChanged(TranscoderStatusEnum.unexpected_error)
     if not failure:
         failure = Failure()
     self.onJobError(failure.getErrorMessage())
     log.notifyFailure(self, failure,
                       "Unexpected error%s",
                       (task and " during %s" % task) or "",
                       cleanTraceback=True)
     m = messages.Error(T_(failure.getErrorMessage()),
                        debug=log.getFailureMessage(failure))
     self.addMessage(m)
     return failure
开发者ID:osiloke,项目名称:Flumotion-Transcoder,代码行数:15,代码来源:filetranscoder.py

示例3: invoke

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import getErrorMessage [as 别名]
    def invoke(self, name, args):
        """Invoke Exposed Methods
           @param name (str) - name of method to invoke
           @param args (tuple) - arguments to pass to invoked method

           @return (defer.Deferred)
        """
        if name not in self.exposedMethods:
            return defer.fail(DroneCommandFailed(self.resultContext(
                "[%(application)s] Unknown method '%(method)s'", method=name, 
                error='unknown method'))
            )
        try:
            #our own form of maybeDeferred
            d = self.exposedMethods[name](*args)
            if isinstance(d, defer.Deferred):
                action = Action(' '.join([str(i) for i in \
                        (self.action, name) + tuple(args)]), d)
                return action.deferred
            elif isinstance(d, DroneCommandFailed):
                return defer.fail(d)
            elif isinstance(d, dict):
                return defer.succeed(d)
            elif isinstance(d, type(None)):
                #this just feels dirty
                return defer.succeed(d)
            elif isinstance(d, Failure):
                d.raiseException() #sigh
            #probably from a triggerred Event callback
            elif type(d) == types.InstanceType:
                return defer.succeed(None)
            return defer.fail(FormatError("Result is not formatted correctly you " + \
                 "must return self.resultContext or DroneCommandFailed." + \
                 "\nResult: <%s>" % (str(d),)))
        except:
            failure = Failure()
            if failure.check(DroneCommandFailed):
                template = "[%(application)s] %(description)s"
                context = failure.value.resultContext
                if not 'description' in context:
                    context['description'] = failure.getErrorMessage()
            else:
                template = "[%(application)s] " + "%s: %s" % (getException(failure),
                        failure.getErrorMessage())
                context = {'error': True, 'code':-2, 'stacktrace': failure.getTraceback()}
            return defer.fail(DroneCommandFailed(self.resultContext(template, 
                None, **context))
            )
开发者ID:cbrinley,项目名称:droned,代码行数:50,代码来源:action.py

示例4: decorator

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import getErrorMessage [as 别名]
 def decorator(*args, **kwargs):
     try: return func(*args, **kwargs)
     except:
         failure = Failure()
         msg = getException(failure)
         msg += ': ' + failure.getErrorMessage()
         return NoResource(msg)
开发者ID:DroneD,项目名称:droned,代码行数:9,代码来源:remote_config.py

示例5: _start_stop_common

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import getErrorMessage [as 别名]
 def _start_stop_common(self, label, action):
     result = {}
     try:
         function = getattr(self.model, action)
         d = defer.maybeDeferred(function, label)
         wfd = defer.waitForDeferred(d)
         yield wfd
         result = wfd.getResult()
         #take this time to update the instance
         if isinstance(result, dict):
             thisInst = self.model.getInstance(label)
             thisInst.updateInfo(result) 
     except:
         failure = Failure()
         if failure.check(DroneCommandFailed):
             result = failure.value.resultContext
         else:
             #log the error, allowing for debugging
             self.debugReport()
             #be nice and return something to the end user
             template = "%s: %s" % (getException(failure), failure.getErrorMessage())
             context = {'error':failure,'code':-2}
             result = self.resultContext(template, None, **context)
         #finally wrap the failure into a known type
         result = Failure(DroneCommandFailed(result))
     #AppInstances need a moment to be updated
     d = defer.Deferred()
     reactor.callLater(1.0, d.callback, None)
     wfd = defer.waitForDeferred(d)
     yield wfd
     wfd.getResult()
     yield result
开发者ID:cbrinley,项目名称:droned,代码行数:34,代码来源:appmgr.py

示例6: __call__

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import getErrorMessage [as 别名]
 def __call__(self, argstr):
     args = argstr.split()
     resultContext = None
     if not args: #return command usage
         methods = {}
         for name,args,doc in self.exposedMethodInfo:
             methods[name] = {'args' : args, 'doc' : doc}
         resultContext = dict(description=self.__doc__, methods=methods)
         yield resultContext
     else:
         method = args.pop(0)
         try:
             wfd = defer.waitForDeferred(
                     self.invoke(method,args)
             )
             yield wfd
             resultContext = wfd.getResult()
         except:
             failure = Failure()
             if failure.check(DroneCommandFailed):
                 resultContext = failure.value.resultContext
             else:
                 #be nice and return something to the end user
                 template = "[%(application)s] "
                 template += "%s: %s" % (getException(failure), failure.getErrorMessage())
                 context = {'error': True, 'code': -2, 'stacktrace': failure.getTraceback()}
                 resultContext = self.resultContext(template, None, 
                     **context
                 )
                 
         yield resultContext
开发者ID:cbrinley,项目名称:droned,代码行数:33,代码来源:action.py

示例7: parseError

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import getErrorMessage [as 别名]
 def parseError(self, err, query, instMap):
     err = Failure(err)
     err.value = 'Received %s from query: %s'%(err.value, query)
     log.error(err.getErrorMessage())
     results = {}
     for instances in instMap.values():
         for tables in instances.values():
             for table, props in tables:
                 results[table] = [err,]
     return results
开发者ID:alecsandrb,项目名称:Community-Zenpacks,代码行数:12,代码来源:WMIClient.py

示例8: newfunc

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import getErrorMessage [as 别名]
 def newfunc(*args,**kwargs):
     try:
         return func(*args,**kwargs)
     except:
         failure = Failure()
         caught_exc = failure.value
         err_msg = failure.getErrorMessage()
         if failure.check(exc): raise caught_exc #1
         exc_inst = exc(err_msg)
         exc_inst.inner_exception = caught_exc
         raise exc_inst
开发者ID:DroneD,项目名称:droned,代码行数:13,代码来源:decorators.py

示例9: _unexpected_error

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import getErrorMessage [as 别名]
 def _unexpected_error(self, failure=None, task=None):
     if not failure:
         failure = Failure()
     log.notifyFailure(self, failure,
                       "Unexpected error%s",
                       (task and " during %s" % task) or "",
                       cleanTraceback=True)
     m = messages.Error(_(failure.getErrorMessage()),
                        debug=log.getFailureMessage(failure))
     self.addMessage(m)
     return failure
开发者ID:osiloke,项目名称:Flumotion-Transcoder,代码行数:13,代码来源:base.py

示例10: __transcodingError

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import getErrorMessage [as 别名]
 def __transcodingError(self, failure=None, task=None):
     self._fireStatusChanged(TranscoderStatusEnum.error)
     if not failure:
         failure = Failure()
     self.onJobError(failure.getErrorMessage())
     log.notifyFailure(self, failure,
                       "Transocding error%s",
                       (task and " during %s" % task) or "",
                       cleanTraceback=True)
     self.setMood(moods.sad)
     return failure
开发者ID:osiloke,项目名称:Flumotion-Transcoder,代码行数:13,代码来源:filetranscoder.py

示例11: handleDeferreds

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import getErrorMessage [as 别名]
 def handleDeferreds(labels):
     """Remember last yield is the return value, don't use return"""
     results = {}
     descriptions = []
     ret = {}
     code = 0
     for l in labels:
         try:
             d = defer.maybeDeferred(func, l, *args[1:], **kwargs)
             wfd = defer.waitForDeferred(d)
             yield wfd
             ret = wfd.getResult()
         except:
             failure = Failure()
             des = "%s: %s" % \
                     (getException(failure),failure.getErrorMessage())
             if failure.check(DroneCommandFailed):
                 result[l] = failure.value.resultContext
                 if 'description' not in result[l]:
                     result[l]['description'] = des
                 result[l]['stacktrace'] = failure.getTraceback()
                 result[l]['error'] = True
                 if 'code' not in result[l]:
                     result[l]['code'] = 1
             else:
                 ret = {
                     'description': des,
                     'code': 1,
                     'error': True,
                     'stacktrace': failure.getTraceback()
                 }
         if not ret: #NoneType detection
             ret = {'description' : str(ret), 'code' : 0}
         if 'code' in ret:
             code += abs(ret['code'])
         results[l] = ret
         try:
             descriptions.append(results[l]['description'])
         except:
            self.debugReport()
     results['code'] = code
     try:
         results['description'] = '\n'.join(descriptions)
     except:
         results['description'] = None
     if len(labels) == 0:
         Label = labels[0]
     else:
         Label = None
     ret = self.resultContext('%(description)s',label=Label,**results) 
     yield ret
开发者ID:cbrinley,项目名称:droned,代码行数:53,代码来源:appmgr.py

示例12: parseError

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import getErrorMessage [as 别名]
 def parseError(self, err, query, instMap):
     if isinstance(err.value, pywbem.cim_http.AuthError):
         msg = 'AuthError: Please check zWinUser and zWinPassword zProperties'
     else:
         msg = 'Received %s from query: %s'%(err.value[1], query)
     err = Failure(err)
     err.value = msg
     log.error(err.getErrorMessage())
     results = {}
     for instances in instMap.values():
         for tables in instances.values():
             for table, props in tables:
                 results[table] = [err]
     return results
开发者ID:alecsandrb,项目名称:Community-Zenpacks,代码行数:16,代码来源:WBEMClient.py

示例13: resultContext

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import getErrorMessage [as 别名]
    def resultContext(self, template, instance=None, **context):
        """Creates a dict containg relevant contextual information about a 
           result.  You can override this method and tailor it to your liking.
           We typically use this to pass verbose structured data to a master
           DroneD controller (not provided with DroneD core) so that it may
           quickly make decisions based on the result of it's previous command
           and control activities.

           IF you set 'error' in the **context this will raise a server error
           at the remote end. This can be good or bad depending on your outlook
           on exceptions.  Consider this your only warning.

           return dict
        """
        if 'application' not in context:
            context['application'] = self.action
        failure = context.pop('error', False)
        if isinstance(failure, Failure):
            if 'description' not in context:
                context['description'] = '[%s] %s: %s' % \
                        (self.action, getException(failure), failure.getErrorMessage())
            if 'code' not in context:
                context['code'] = -2
            context['error'] = True
            context['stacktrace'] = failure.getTraceback()
            self.log('Result context during exception\n%(stacktrace)s' % context)
            return context #failed so bad we need to shortcut out
        else:
            context['error'] = bool(failure)
        if instance: #this was made for AppManager's
            if hasattr(instance, 'version'):
                context['version'] = instance.version
            if hasattr(instance, 'label'):
                context['label'] = instance.label
            if hasattr(instance, 'running'):
                context['running'] = instance.running
        try: #fail-safe in case someone is a bonehead
            context['description'] = template % context
        except:
            failure = Failure()
            context['description'] = '[%s] %s: %s' % \
                    (self.action, getException(failure), failure.getErrorMessage())
            context['stacktrace'] = failure.getTraceback()
            if 'code' not in context:
                context['code'] = -2
        #be nice to blaster api and the remote client
        context.update({'code' : context.get('code',0) })
        return context
开发者ID:cbrinley,项目名称:droned,代码行数:50,代码来源:action.py

示例14: test_render_deferred_failure

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import getErrorMessage [as 别名]
 def test_render_deferred_failure(self):
     "Render function w/ failed deferred return."
     d = defer.Deferred()
     
     def render_GET(request):
         return d
     
     phony_call_router = object()
     self.request.method = "GET"
     res = urldispatch.URLMatchJSONResource(self.request,
                                            url_matches=self.route_map,
                                            call_router=phony_call_router)
     res.render_GET = render_GET
     ret_res = res.render(self.request)
     self.assertEqual(NOT_DONE_YET, ret_res)
     fail = Failure(Exception("test error"))
     d.errback(fail=fail)
     self.assertEqual(str(webapi.UnexpectedServerError(self.request,
                                                       fail.getErrorMessage())),
                      self.request.content.getvalue())
开发者ID:notoriousno,项目名称:shiji,代码行数:22,代码来源:test_urldispatch.py

示例15: msgBufResponse

# 需要导入模块: from twisted.python.failure import Failure [as 别名]
# 或者: from twisted.python.failure.Failure import getErrorMessage [as 别名]
 def msgBufResponse(self, result):
     """Format results, encode, and respond"""
     response, contentType = result
     try:
         return {
             'response' : urllib.quote(blaster.Serialize().execute(
                 contentType, drone.formatResults(response))),
             'type' : contentType,
             'code' : 200
         }
     except:
         failure = Failure()
         Msg = {
             'code' : 1,
             'description' : failure.getErrorMessage(),
             'stacktrace': failure.getTraceback(),
             'error' : True
         }
         return {
             'response' : urllib.quote(blaster.Serialize().execute(
                     contentType, Msg)),
             'type' : 'text/plain',
             'code' : 500
         }
开发者ID:cbrinley,项目名称:droned,代码行数:26,代码来源:drone.py


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