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