本文整理汇总了Python中Products.ZenUtils.extdirect.router.DirectResponse.exception方法的典型用法代码示例。如果您正苦于以下问题:Python DirectResponse.exception方法的具体用法?Python DirectResponse.exception怎么用?Python DirectResponse.exception使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Products.ZenUtils.extdirect.router.DirectResponse
的用法示例。
在下文中一共展示了DirectResponse.exception方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parseFilter
# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import exception [as 别名]
def parseFilter(self, source):
try:
response = self._getFacade().parseFilter(source)
return DirectResponse.succeed(data=response)
except Exception, e:
log.exception(e)
return DirectResponse.exception(e, "Error parsing filter source. Please check your syntax.")
示例2: add_event
# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import exception [as 别名]
def add_event(self, summary, device, component, severity, evclasskey, evclass=None):
"""
Create a new event.
@type summary: string
@param summary: New event's summary
@type device: string
@param device: Device uid to use for new event
@type component: string
@param component: Component uid to use for new event
@type severity: string
@param severity: Severity of new event. Can be one of the following:
Critical, Error, Warning, Info, Debug, or Clear
@type evclasskey: string
@param evclasskey: The Event Class Key to assign to this event
@type evclass: string
@param evclass: Event class for the new event
@rtype: DirectResponse
"""
try:
self.zep.create(summary, severity, device, component, eventClassKey=evclasskey, eventClass=evclass)
return DirectResponse.succeed("Created event")
except NoConsumersException:
# This occurs if the event is queued but there are no consumers - i.e. zeneventd is not
# currently running.
msg = 'Queued event. Check zeneventd status on <a href="/zport/About/zenossInfo">Daemons</a>'
return DirectResponse.succeed(msg, sticky=True)
except PublishException, e:
# This occurs if there is a failure publishing the event to the queue.
log.exception("Failed creating event")
return DirectResponse.exception(e, "Failed to create event")
示例3: add_event
# 需要导入模块: from Products.ZenUtils.extdirect.router import DirectResponse [as 别名]
# 或者: from Products.ZenUtils.extdirect.router.DirectResponse import exception [as 别名]
def add_event(self, summary, device, component, severity, evclasskey,
evclass=None, monitor=None, **kwargs):
"""
Create a new event.
@type summary: string
@param summary: New event's summary
@type device: string
@param device: Device id to use for new event
@type component: string
@param component: Component uid to use for new event
@type severity: string
@param severity: Severity of new event. Can be one of the following:
Critical, Error, Warning, Info, Debug, or Clear
@type evclasskey: string
@param evclasskey: The Event Class Key to assign to this event
@type evclass: string
@param evclass: Event class for the new event
@rtype: DirectResponse
For other parameters please see class Event.
"""
device = device.strip() # ZEN-2479: support entries like "localhost "
try:
self.zep.create(summary, severity, device, component,
eventClassKey=evclasskey, eventClass=evclass,
monitor=monitor, **kwargs)
return DirectResponse.succeed("Created event")
except NoConsumersException:
# This occurs if the event is queued but there are no consumers - i.e. zeneventd is not
# currently running.
msg = 'Queued event. Check zeneventd status on <a href="/zport/dmd/daemons">Services</a>'
return DirectResponse.succeed(msg, sticky=True)
except PublishException, e:
# This occurs if there is a failure publishing the event to the queue.
log.exception("Failed creating event")
return DirectResponse.exception(e, "Failed to create event")