mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 22:56:29 +00:00
7750025631
remove dummy dlls, remove resource loader from c#. TODO: Load dlls separately by Loader UI and loader client WIP
37 lines
1.7 KiB
Cython
37 lines
1.7 KiB
Cython
import os
|
|
import subprocess
|
|
cdef class HardwareService:
|
|
|
|
@staticmethod
|
|
cdef str get_hardware_info():
|
|
if os.name == 'nt': # windows
|
|
os_command = (
|
|
"powershell -Command \""
|
|
"Get-CimInstance -ClassName Win32_Processor | Select-Object -ExpandProperty Name | Write-Output; "
|
|
"Get-CimInstance -ClassName Win32_VideoController | Select-Object -ExpandProperty Name | Write-Output; "
|
|
"Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object -ExpandProperty TotalVisibleMemorySize | Write-Output; "
|
|
"(Get-Disk | Where-Object {$_.IsSystem -eq $true}).SerialNumber"
|
|
"\""
|
|
)
|
|
else:
|
|
os_command = (
|
|
"lscpu | grep 'Model name:' | cut -d':' -f2 && "
|
|
"lspci | grep VGA | cut -d':' -f3 && "
|
|
"free -k | awk '/^Mem:/ {print $2}' && "
|
|
"cat /sys/block/sda/device/vpd_pg80 2>/dev/null || cat /sys/block/sda/device/serial 2>/dev/null"
|
|
)
|
|
|
|
result = subprocess.check_output(os_command, shell=True).decode('utf-8', errors='ignore')
|
|
lines = [line.replace(" ", " ").replace("Name=", "").strip('\x00\x14 \t\n\r\v\f') for line in result.splitlines() if line.strip()]
|
|
|
|
cdef str cpu = lines[0]
|
|
cdef str gpu = lines[1]
|
|
# could be multiple gpus
|
|
|
|
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
|