print('Serial device is not specified (neither in config nor in command line)')
...
...
@@ -165,6 +165,18 @@ if __name__ == "__main__":
print('Baudrate is not specified (neither in config nor in command line)')
exit()
ifnotargs.manual:
drivesLen=len(config['drives'])
ifdrivesLen==0:
print('No drives are specified in config. At least one drive must be specified')
exit()
ifdrivesLen>3:
print(f'{drivesLen} drives are specified in config. Note that only 3 drives are supported, so only the first 3 will be used.')
iflen(config['controlGroups'])!=3:
print('Incorrect number of control groups in config. There should be 3 control groups.')
exit()
serial_port=open_serial(port,baudrate)
...
...
@@ -179,17 +191,31 @@ if __name__ == "__main__":
output=str(subprocess.Popen(['netcat','localhost','7634'],stdout=subprocess.PIPE,stderr=subprocess.STDOUT).communicate()[0])#получаем output от hddtemp
#b'|/dev/sda2|ST340014A|41|C|'
ifoutput=="b''":
print('Hddtemp output is empty, make sure it is running. If not, launch it with #hddtemp -d')
print('Hddtemp output is empty, make sure it is running. If not, launch it: #systemctl start hddtemp.service')
#exit()
#вычленяем значение температуры:
temp_pos_end=output.find('|C|')
temp_pos_start=output.rfind('|',0,temp_pos_end)+1
temp=output[temp_pos_start:temp_pos_end]
try:
temperatures[0]=int(temp)
exceptValueError:
print('Error: Failed to get a temperature value from hddtemp output')
else:
driveCount=len(config['drives'])
ifdriveCount>3:
driveCount=3
foriinrange(driveCount):
drive=config['drives'][i]
drive_pos=output.find(drive)
ifdrive_pos==-1:
print(f'Drive {drive} not found in hddtemp output')