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


Python CDevice.build_upon_spec方法代码示例

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


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

示例1: build_upon_spec

# 需要导入模块: from lib.Device import CDevice [as 别名]
# 或者: from lib.Device.CDevice import build_upon_spec [as 别名]
    def build_upon_spec(self):
        '''
        Load slic hw info from pub/slic.xml
        '''
        CDevice.build_upon_spec(self)
        
        # Read spec       
        str_spec_file = os.path.join('pub', 'slic.xml')
        try:
            root = ET.parse(str_spec_file).getroot()
        except:
            msg='specification file not found or not interpretable'
            msg+=traceback.format_exc()
            raise Exception(msg)

        lst_slic = root.findall('slic')
        obj_xmlnode_spec = None
        for i in lst_slic:
            ffid='%04x%04x'%(int(i.find('family_id').text, 16), 
                             int(i.find('fru_id').text, 16))
            if ffid == self.str_ffid:
                obj_xmlnode_spec = i
                break
        if obj_xmlnode_spec is None:
            raise Exception('No spec found for SLIC 0x%s'%self.str_ffid)
        
        # parse config
        str_smi_support = obj_xmlnode_spec.find('smi_support').text.lower()
        if str_smi_support not in ('0', 'false', 'no'):
            self.b_smi_supported = True
        else:
            self.b_smi_supported = False
        
        self.str_name = obj_xmlnode_spec.find('name').text

        #firmare file character string:
        try:
            self.fw_id = obj_xmlnode_spec.find('fw_id').text
        except:
            self.log('WARNING', 'fw_id not found in SLIC spec.')                
        #fw name in resume
        try:
            self.fw_name_resume = obj_xmlnode_spec.find('fw_name_resume').text
        except:
            self.log('WARNING', 'fw_name_resume not found in SLIC spec.') 

        #for Rockslide/RockslideX
        try:
            self.spirom_id = obj_xmlnode_spec.find('spirom_id').text
        except:
            self.log('WARNING', 'spirom_id not found in SLIC spec.')                
        try:
            self.cmd_fw_id = obj_xmlnode_spec.find('cmd_fw_id').text
        except:
            self.log('WARNING', 'cmd_fw_id not found in SLIC spec.')                
        try:
            self.protocol = obj_xmlnode_spec.find('protocol').text
        except:
            self.log('WARNING', 'protocol not found in SLIC spec.')                
        return 0
开发者ID:zhang-martin,项目名称:atom2,代码行数:62,代码来源:SLIC.py


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