Files
spectre_project/add_system.py

35 lines
842 B
Python
Raw Permalink Normal View History

2020-04-14 18:06:24 +02:00
from subprocess import check_output
from os import name as os_name
def os_info():
if os_name == 'nt':
return command_to_string(['ver'])
else:
return command_to_string(['uname', '-a'])
def cpu_info():
if os_name == 'nt':
return command_to_string(['powershell', 'Get-WmiObject', '-class', 'win32_processor'])
else:
return read_file("/proc/cpuinfo")
def mem_info():
if os_name == 'nt':
return command_to_string(['powershell', 'Get-WmiObject', '-class', 'win32_Physicalmemory'])
else:
return read_file("/proc/mem")
def command_to_string(command):
return check_output(command, shell=True).decode("UTF-8")
def read_file(fileName):
with open(fileName) as f:
return f.read()
cpu = cpu_info()
os = os_info()
mem = mem_info()
print(os)
print(cpu)
print(mem)