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


Python ICatalogTool.getBrain方法代码示例

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


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

示例1: EventCompatInfo

# 需要导入模块: from Products.Zuul.interfaces import ICatalogTool [as 别名]
# 或者: from Products.Zuul.interfaces.ICatalogTool import getBrain [as 别名]

#.........这里部分代码省略.........
                         url=self._uuidUrl(self._eventActor.get('element_uuid')),
                         uuid=self._eventActor.get('element_uuid'))
        else:
            return dict(text=self._eventActor.get('element_title'),
                        url=device_url)

    @property
    def prodState(self):
        prodState = self._singleDetail(self._eventDetails.get('zenoss.device.production_state'))
        if prodState is not None:
            return self._dmd.convertProdState(prodState)

    @property
    def DevicePriority(self):
        DevicePriority = self._singleDetail(self._eventDetails.get('zenoss.device.priority'))
        if DevicePriority is not None:
            return self._dmd.convertPriority(DevicePriority)

    @property
    def details(self):
        return self._eventDetails

    def __getattr__(self, name):
        if self._eventDetails.get(name):
            return self._eventDetails.get(name)
        raise AttributeError(name)

    def _uuidUrl(self, uuid):
        if uuid:
            return '/zport/dmd/goto?guid=%s' % uuid


    def _get_device_url(self, eventDetails):
        url_and_path = [self._singleDetail(eventDetails.get(k)) for k in 'zenoss.device.url', 'zenoss.device.path']
        if len(url_and_path) != 2:
            return None
        url, path = url_and_path
        try:
            self._dmd.findChild(path)
        except:
            return None
        return url

    def _singleDetail(self, value):
        """
        A convenience method for fetching a single detail from a property which
        correlates to a repeated field on the protobuf.
        """
        if isinstance(value, (tuple, list, set)) and value:
            return value[0]

    def _findDetails(self, event):
        """
        Event details are created as a dictionary like the following:
            detail = {
                'name': 'zenoss.foo.bar',
                'value': 'baz'
            }
        This method maps these detail items to a flat dictionary to facilitate
        looking up details by key easier.

        @rtype dict
        """
        details = {}
        if 'details' in event:
            for d in event['details']:
                details[d['name']] = d.get('value', ())
        return details

    def _lookupDetailPath(self, prefix, values):
        if not values:
            return ()
        paths = []
        for value in values:
            paths.append({'uid': prefix + value, 'name': value})
        return paths

    def _getPathFromUuid(self, uuid):
        if uuid:
            path = self._manager.getPath(uuid)
            if path:
                return urllib.unquote(path)

    def _lookupEventClassMapping(self, mappingUuid):
        if not mappingUuid:
            return ""

        return {'uuid': mappingUuid, 'name': self._getNameFromUuid(mappingUuid)}

    def _getNameFromUuid(self, uuid):
        """
        Given a uuid this returns the objects name
        from the catalog, it does not wake the object up
        """
        if uuid:
            path = self._getPathFromUuid(uuid)
            if path:
                brain = self._catalog.getBrain(path)
                if brain:
                    return brain.name
开发者ID:SteelHouseLabs,项目名称:zenoss-prodbin,代码行数:104,代码来源:event.py


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