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


Python DirectResponse.fail方法代码示例

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


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

示例1: addTrigger

# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import fail [as 别名]
 def addTrigger(self, newId):
     try:
         data = self._getFacade().addTrigger(newId)
     except DuplicateTriggerName as tnc:
         log.debug("Exception DuplicateTriggerName: %s" % tnc)
         return DirectResponse.fail(str(tnc))
     else:
         audit('UI.Trigger.Add', newId)
         return DirectResponse.succeed(data=data)
开发者ID:zenoss,项目名称:zenoss-prodbin,代码行数:11,代码来源:triggers.py

示例2: updateDetails

# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import fail [as 别名]
 def updateDetails(self, evid, **detailInfo):
     """
     On success, returns the status.
     """
     try:
         resp = self.zep.updateDetails(evid, **detailInfo)
     except ServiceResponseError as ex:
         return DirectResponse.fail(msg=str(ex))
     audit('UI.Event.UpdateEventDetails', self.context, evid=evid,
           details=detailInfo)
     return DirectResponse.succeed(status=resp['status'])
开发者ID:c0ns0le,项目名称:zenoss-4,代码行数:13,代码来源:zep.py

示例3: importConfiguration

# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import fail [as 别名]
 def importConfiguration(self, triggers=None, notifications=None):
     try:
         tcount = len(triggers) if triggers is not None else 0
         ncount = len(notifications) if notifications is not None else 0
         facade = self._getFacade()
         itcount, incount = facade.importConfiguration(triggers, notifications)
         msg = "Imported %d of %d triggers and %d of %d notifications" % (tcount, itcount, ncount, incount)
         audit("UI.TriggerNotification.Import", msg)
         return DirectResponse.succeed(msg=msg)
     except Exception as ex:
         audit("UI.TriggerNotification.Import", "Failed to import trigger/notification data")
         log.exception("Unable to import data:\ntriggers=%s\nnotifications=%s", repr(triggers), repr(notifications))
         return DirectResponse.fail(str(ex))
开发者ID:jpeacock-zenoss,项目名称:zenoss-prodbin,代码行数:15,代码来源:triggers.py

示例4: getRouterMethods

# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import fail [as 别名]
    def getRouterMethods(self, router=None):
        """
        Return a JSON list of methods, arguments and documentation

        Example usage from zendmd:

        from Products.Zuul.routers.introspection import IntrospectionRouter
        zz = IntrospectionRouter(dmd)
        pprint(zz.getRouterMethods('DeviceRouter').data)
        """
        if router is not None:
            klasses = self._getRouterByName(router)
            if klasses:
                # TODO: log something?
                klass = klasses[0]
            else:
                return DirectResponse.fail(msg="No router named '%s' found" % router)
        else:
            klass = self.__class__

        methods = {}
        for name, code in inspect.getmembers(klass):
            if name.startswith('_'):
                continue
            if not inspect.ismethod(code):
                continue

            argspec = inspect.getargspec(code)
            if argspec.defaults is None:
                args = argspec.args[1:] # Ignore 'self'
                kwargs = {}
            else:
                n = len(argspec.defaults)
                args = argspec.args[1:-n] # Ignore 'self'
                kwargs = dict(zip(argspec.args[-n:], argspec.defaults))

            methods[name] = dict(
                documentation=inspect.getdoc(code),
                kwargs=kwargs,
                args=args,
            )

        return DirectResponse(data=Zuul.marshal(methods))
开发者ID:bbc,项目名称:zenoss-prodbin,代码行数:45,代码来源:introspection.py

示例5: addTrigger

# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import fail [as 别名]
 def addTrigger(self, newId):
     try:
         data = self._getFacade().addTrigger(newId)
     except DuplicateTriggerName, tnc:
         log.debug("Exception DuplicateTriggerName: %s" % tnc)
         return DirectResponse.fail(str(tnc))
开发者ID:jpeacock-zenoss,项目名称:zenoss-prodbin,代码行数:8,代码来源:triggers.py


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