@@ -40,7 +40,7 @@ def collect_dmidecode_info(data, failures):
4040 try :
4141 data ['dmi' ] = parse_dmi (shret )
4242 except (ValueError , IndexError ) as exc :
43- LOG .warning ('Failed to collect dmidecode info %s: ' , exc )
43+ LOG .warning ('Failed to collect dmidecode info: %s' , exc )
4444
4545
4646def parse_dmi (data ):
@@ -69,28 +69,30 @@ def parse_dmi(data):
6969 if not len (infoblock ):
7070 continue
7171
72- if infoblock .startswith ('Handle 0x' ):
73- try :
74- # Determine DMI type value. Handle line will look like this:
75- # Handle 0x0018, DMI type 17, 27 bytes
76- dmi_type = int (infoblock .split (',' , 2 )[1 ].strip ()[
77- len ('DMI type' ):])
78- except (ValueError , IndexError ) as exc :
79- LOG .warning ('Failed to parse Handle type in dmi output: %s' ,
80- exc )
81- continue
82-
83- if dmi_type in TYPE .values ():
84- sectiondata = _parse_handle_block (infoblock )
85-
86- if dmi_type == TYPE ['bios' ]:
87- dmi_info ['bios' ] = sectiondata
88- elif dmi_type == TYPE ['cpu' ]:
89- dmi_info ['cpu' ].append (sectiondata )
90- elif dmi_type == TYPE ['memory' ]:
91- memorydata .append (sectiondata )
92- elif dmi_type == TYPE ['devices' ]:
93- devicedata .append (sectiondata )
72+ if not infoblock .startswith ('Handle 0x' ):
73+ continue
74+
75+ try :
76+ # Determine DMI type value. Handle line will look like this:
77+ # Handle 0x0018, DMI type 17, 27 bytes
78+ dmi_type = int (infoblock .split (',' , 2 )[1 ].strip ()[
79+ len ('DMI type' ):])
80+ except (ValueError , IndexError ) as exc :
81+ LOG .warning ('Failed to parse Handle type in dmi output: %s' ,
82+ exc )
83+ continue
84+
85+ if dmi_type in TYPE .values ():
86+ sectiondata = _parse_handle_block (infoblock )
87+
88+ if dmi_type == TYPE ['bios' ]:
89+ dmi_info ['bios' ] = sectiondata
90+ elif dmi_type == TYPE ['cpu' ]:
91+ dmi_info ['cpu' ].append (sectiondata )
92+ elif dmi_type == TYPE ['memory' ]:
93+ memorydata .append (sectiondata )
94+ elif dmi_type == TYPE ['devices' ]:
95+ devicedata .append (sectiondata )
9496
9597 return _save_data (dmi_info , memorydata , devicedata )
9698
@@ -124,7 +126,7 @@ def _save_data(dmi_info, memorydata, devicedata):
124126 dmi_info ['memory' ] = memorydata [0 ]
125127 dmi_info ['memory' ]['Number Of Devices' ] = device_count
126128 dmi_info ['memory' ].pop ('Handle' )
127- except ( KeyError ) as exc :
129+ except KeyError as exc :
128130 LOG .warning ('Failed to process memory dmi data: %s' , exc )
129131 raise
130132
0 commit comments