2020-07-14 16:20:41 -05:00
|
|
|
#!/usr/bin/env python
|
2020-11-11 00:13:23 -06:00
|
|
|
import os
|
2020-07-14 16:20:41 -05:00
|
|
|
import commands
|
|
|
|
|
2020-11-11 00:13:23 -06:00
|
|
|
def fantype_detect():
|
|
|
|
|
|
|
|
refpgaTMC_path = "/sys/devices/pci0000:00/0000:00:1c.0/0000:0f:00.0/refpga-tmc.15"
|
2020-07-14 16:20:41 -05:00
|
|
|
|
|
|
|
AFO = "1"
|
2020-11-11 00:13:23 -06:00
|
|
|
AFI = "0"
|
|
|
|
|
|
|
|
#default fan type is AFI
|
|
|
|
default_fantype = 0
|
|
|
|
|
|
|
|
for filename in os.listdir(refpgaTMC_path):
|
|
|
|
if filename.endswith('_type'):
|
|
|
|
fantype_path = os.path.join(refpgaTMC_path, filename)
|
|
|
|
cat_string = "cat "
|
|
|
|
fantype_string = cat_string + fantype_path
|
|
|
|
status,fan_type=commands.getstatusoutput(fantype_string)
|
|
|
|
if ((fan_type == AFO) or (fan_type == AFI)):
|
|
|
|
return fan_type
|
|
|
|
else:
|
|
|
|
pass
|
|
|
|
|
|
|
|
return default_fantype
|
|
|
|
|
|
|
|
def main():
|
|
|
|
AFO_value = "1"
|
|
|
|
|
|
|
|
fan_type = fantype_detect()
|
2020-07-14 16:20:41 -05:00
|
|
|
|
2020-11-11 00:13:23 -06:00
|
|
|
if fan_type == AFO_value:
|
2020-07-14 16:20:41 -05:00
|
|
|
temp_thres_file = open("/usr/local/bin/temperature_thresholds_AFO.txt", "r+")
|
|
|
|
print temp_thres_file.read()
|
|
|
|
else:
|
|
|
|
temp_thres_file = open("/usr/local/bin/temperature_thresholds_AFI.txt", "r+")
|
|
|
|
print temp_thres_file.read()
|
|
|
|
|
|
|
|
temp_thres_file.close()
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|