67 lines
2.0 KiB
Python
67 lines
2.0 KiB
Python
import os
|
|
from multiprocessing import freeze_support
|
|
import cpuinfo
|
|
import psutil
|
|
import math
|
|
import platform
|
|
import socket
|
|
|
|
def get_cpu_brand():
|
|
freeze_support()
|
|
return cpuinfo.get_cpu_info()['brand_raw']
|
|
|
|
def get_cpu_core():
|
|
freeze_support()
|
|
return os.cpu_count()
|
|
|
|
def get_ram_info():
|
|
freeze_support()
|
|
ram_info = psutil.virtual_memory()
|
|
total_ram = ram_info.total / (1024 ** 3) # In Gigabytes
|
|
return math.ceil(total_ram)
|
|
|
|
def get_total_hdd(function):
|
|
freeze_support()
|
|
space = 0
|
|
disk_partitions = psutil.disk_partitions()
|
|
for partition in disk_partitions:
|
|
partition_info = psutil.disk_usage(partition.mountpoint)
|
|
if function == "free":
|
|
space += round(partition_info.free / (1024 ** 3), 2)
|
|
elif function == "used":
|
|
space += round(partition_info.used / (1024 ** 3), 2)
|
|
elif function == "total":
|
|
space += round(partition_info.total / (1024 ** 3), 2)
|
|
return math.ceil(space)
|
|
|
|
def get_single_hdd(function):
|
|
freeze_support()
|
|
used_disk_size = 0
|
|
disk_partitions = psutil.disk_partitions()
|
|
partition_return = []
|
|
for partition in disk_partitions:
|
|
partition_info = psutil.disk_usage(partition.mountpoint)
|
|
if function == "free":
|
|
space = round(partition_info.free / (1024 ** 3), 2)
|
|
elif function == "used":
|
|
space = round(partition_info.used / (1024 ** 3), 2)
|
|
elif function == "total":
|
|
space = round(partition_info.total / (1024 ** 3), 2)
|
|
partition_name = partition.mountpoint.replace(':\\',"")
|
|
partition_return.append(f"{partition_name}: {space}GB")
|
|
return partition_return
|
|
|
|
def get_winver():
|
|
freeze_support()
|
|
return platform.platform()
|
|
|
|
def get_local_ip():
|
|
try:
|
|
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
s.connect(("8.8.8.8", 80))
|
|
local_ip = s.getsockname()[0]
|
|
s.close()
|
|
return local_ip
|
|
except Exception as e:
|
|
print(f"Fehler beim Abrufen der lokalen IP-Adresse: {e}")
|
|
return None |