fix hardware service

This commit is contained in:
Alex Bezdieniezhnykh
2025-05-02 13:25:33 +03:00
parent 7842fe1067
commit 472ed6533e
15 changed files with 118 additions and 142 deletions
+7 -3
View File
@@ -59,13 +59,17 @@ cdef class HardwareService:
# in case of subprocess error do:
# cdef bytes os_command_bytes = os_command.encode('utf-8')
# and use os_command_bytes
result = subprocess.check_output(os_command, shell=True).decode('utf-8')
lines = [line.strip() for line in result.splitlines() if line.strip()]
cdef str cpu = lines[0].replace("Name=", "").replace(" ", " ")
cdef str gpu = lines[1].replace("Name=", "").replace(" ", " ")
# could be multiple gpus
cdef str memory = lines[-2].replace("TotalVisibleMemorySize=", "").replace(" ", " ")
cdef str drive_serial = lines[-1]
return f'CPU: {cpu}. GPU: {gpu}. Memory: {memory}. Drive Serial: {drive_serial}'
len_lines = len(lines)
cdef str memory = lines[len_lines-2].replace("TotalVisibleMemorySize=", "").replace(" ", " ")
cdef str drive_serial = lines[len_lines-1]
cdef str res = f'CPU: {cpu}. GPU: {gpu}. Memory: {memory}. DriveSerial: {drive_serial}'
return res