此解析将dmidecode输出解析为JSON
dmiparser的Python项目详细描述
python dmiparser
关于
此解析将dmidecode输出解析为JSON。在
使用
#!/usr/bin/env python3importjsonfromdmiparserimportDmiParserif'__main__'==__name__:text='''# dmidecode 3.0Getting SMBIOS data from sysfs.SMBIOS 2.7 present.Handle 0x0003, DMI type 2, 17 bytesBase Board Information Manufacturer: Intel Corporation Product Name: S2600WT2R Version: H21573-372 Serial Number: BQWL81150522 Asset Tag: Base Board Asset Tag Features: Board is a hosting board Board is replaceable Location In Chassis: Part Component Chassis Handle: 0x0000 Type: Motherboard Contained Object Handles: 0 '''# just printparser=DmiParser(text)#parser = DmiParser(text, sort_keys=True, indent=2)print("parser is %s"%(type(parser)))print(parser)# if you want a stringdmistr=str(parser)print("dmistr is %s"%(type(dmistr)))print(dmistr)# if you want a data structuredmidata=json.loads(str(parser))print("dmidata is %s"%(type(dmidata)))print(dmidata)
示例
下面是一个简单的example演示如何使用dmiparser。在
版权所有
版权所有(c)2019秦凡东
许可证
读LICENSE。在
- 项目
标签: