File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -184,15 +184,19 @@ def store_metadata_file(metadata_filename):
184184 metadata_filename = filename_ensure_json_extension (metadata_filename )
185185 metadata = {}
186186
187- # lshw only works on Linux, this intentionally raises a FileNotFoundError when ran on systems that do not have it
188- lshw_out = subprocess .run (["lshw" , "-json" ], capture_output = True )
187+ # lshw only works on Linux
188+ try :
189+ lshw_out = subprocess .run (["lshw" , "-json" ], capture_output = True )
189190
190- # sometimes lshw outputs a list of length 1, sometimes just as a dict, schema wants a list
191- lshw_string = lshw_out .stdout .decode ('utf-8' ).strip ()
192- if lshw_string [0 ] == '{' and lshw_string [- 1 ] == '}' :
193- lshw_string = '[' + lshw_string + ']'
191+ # sometimes lshw outputs a list of length 1, sometimes just as a dict, schema wants a list
192+ lshw_string = lshw_out .stdout .decode ('utf-8' ).strip ()
193+ if lshw_string [0 ] == '{' and lshw_string [- 1 ] == '}' :
194+ lshw_string = '[' + lshw_string + ']'
195+ hardware_desc = dict (lshw = json .loads (lshw_string ))
196+ except :
197+ hardware_desc = ["lshw error" ]
194198
195- metadata ["hardware" ] = dict ( lshw = json . loads ( lshw_string ))
199+ metadata ["hardware" ] = hardware_desc
196200
197201 # attempts to use nvidia-smi or rocm-smi if present
198202 device_query = {}
You can’t perform that action at this time.
0 commit comments