1
1
#
2
- # Copyright (c) 2019-2023 NVIDIA CORPORATION & AFFILIATES.
2
+ # Copyright (c) 2019-2024 NVIDIA CORPORATION & AFFILIATES.
3
3
# Apache-2.0
4
4
#
5
5
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -220,15 +220,15 @@ def create_indexable_thermal(rule, index, sysfs_folder, position, presence_cb=No
220
220
name = rule ['name' ].format (index )
221
221
sysfs_folder = rule .get ('sysfs_folder' , sysfs_folder )
222
222
temp_file = os .path .join (sysfs_folder , rule ['temperature' ].format (index ))
223
- _check_thermal_sysfs_existence (temp_file )
223
+ _check_thermal_sysfs_existence (temp_file , presence_cb )
224
224
if 'high_threshold' in rule :
225
225
high_th_file = os .path .join (sysfs_folder , rule ['high_threshold' ].format (index ))
226
- _check_thermal_sysfs_existence (high_th_file )
226
+ _check_thermal_sysfs_existence (high_th_file , presence_cb )
227
227
else :
228
228
high_th_file = None
229
229
if 'high_critical_threshold' in rule :
230
230
high_crit_th_file = os .path .join (sysfs_folder , rule ['high_critical_threshold' ].format (index ))
231
- _check_thermal_sysfs_existence (high_crit_th_file )
231
+ _check_thermal_sysfs_existence (high_crit_th_file , presence_cb )
232
232
else :
233
233
high_crit_th_file = None
234
234
high_th_default = rule .get ('high_threshold_default' )
@@ -253,15 +253,15 @@ def create_single_thermal(rule, sysfs_folder, position, presence_cb=None):
253
253
254
254
sysfs_folder = rule .get ('sysfs_folder' , sysfs_folder )
255
255
temp_file = os .path .join (sysfs_folder , temp_file )
256
- _check_thermal_sysfs_existence (temp_file )
256
+ _check_thermal_sysfs_existence (temp_file , presence_cb )
257
257
if 'high_threshold' in rule :
258
258
high_th_file = os .path .join (sysfs_folder , rule ['high_threshold' ])
259
- _check_thermal_sysfs_existence (high_th_file )
259
+ _check_thermal_sysfs_existence (high_th_file , presence_cb )
260
260
else :
261
261
high_th_file = None
262
262
if 'high_critical_threshold' in rule :
263
263
high_crit_th_file = os .path .join (sysfs_folder , rule ['high_critical_threshold' ])
264
- _check_thermal_sysfs_existence (high_crit_th_file )
264
+ _check_thermal_sysfs_existence (high_crit_th_file , presence_cb )
265
265
else :
266
266
high_crit_th_file = None
267
267
high_th_default = rule .get ('high_threshold_default' )
@@ -274,7 +274,11 @@ def create_single_thermal(rule, sysfs_folder, position, presence_cb=None):
274
274
return RemovableThermal (name , temp_file , high_th_file , high_crit_th_file , high_th_default , high_crit_th_default , scale , position , presence_cb )
275
275
276
276
277
- def _check_thermal_sysfs_existence (file_path ):
277
+ def _check_thermal_sysfs_existence (file_path , presence_cb ):
278
+ if presence_cb :
279
+ status , _ = presence_cb ()
280
+ if not status :
281
+ return
278
282
if not os .path .exists (file_path ):
279
283
logger .log_error ('Thermal sysfs {} does not exist' .format (file_path ))
280
284
0 commit comments