@@ -30,8 +30,12 @@ def parse_udevadm(file_content: str) -> List[dict]:
30
30
dimms = []
31
31
for device_id , device in devices .items ():
32
32
try :
33
- if device ["SPEED_MTS" ] == 666 :
34
- device ["SPEED_MTS" ] = 667
33
+
34
+ if "SERIAL_NUMBER" not in device :
35
+ logger .error ("Error while parsing device in udevadm - serial number not found" )
36
+ logger .error ("device:" )
37
+ logger .error (device )
38
+ continue
35
39
36
40
try :
37
41
if device ["SERIAL_NUMBER" ][0 :2 ] == "0x" :
@@ -45,19 +49,27 @@ def parse_udevadm(file_content: str) -> List[dict]:
45
49
logger .error (f"{ file_content = } " )
46
50
continue
47
51
48
- if sn :
49
- dimm = {
50
- "type" : "ram" ,
51
- "working" : "yes" ,
52
- "ram-type" : device ["TYPE" ].lower (),
53
- "frequency-hertz" : int (device ["SPEED_MTS" ]) * 1000 * 1000 ,
54
- "capacity-byte" : int (device ["SIZE" ]),
55
- "brand" : device ["MANUFACTURER" ],
56
- "model" : device ["PART_NUMBER" ],
57
- "sn" : sn ,
58
- }
59
- dimms .append (dimm )
52
+ ram_type = device ["TYPE" ].lower () if "TYPE" in device else None
53
+ size = device ["SIZE" ] if "SIZE" in device else None
54
+ speed = device ["SPEED_MTS" ] if "SPEED_MTS" in device else None
55
+ if speed == 666 :
56
+ speed = 667
57
+ manufacturer = device ["MANUFACTURER" ] if "MANUFACTURER" in device else None
58
+ part_number = device ["PART_NUMBER" ] if "PART_NUMBER" in device else None
59
+
60
+ dimm = {
61
+ "type" : "ram" ,
62
+ "working" : "yes" ,
63
+ "ram-type" : ram_type ,
64
+ "frequency-hertz" : int (speed ) * 1000 * 1000 ,
65
+ "capacity-byte" : int (size ),
66
+ "brand" : manufacturer ,
67
+ "model" : part_number ,
68
+ "sn" : sn ,
69
+ }
70
+ dimms .append (dimm )
60
71
except KeyError as e :
72
+ _errored = True
61
73
logger .error ("Error while parsing device in udevadm" )
62
74
logger .error (f"KeyError { e } " )
63
75
logger .error ("device:" )
0 commit comments