mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 15:06:29 +00:00
fix hardware service
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user