mirror of
https://gitlab.com/Nils_Kasulke/spectre_project.git
synced 2026-04-04 11:37:25 +00:00
35 lines
842 B
Python
35 lines
842 B
Python
|
|
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)
|