Primer Commit, base de pryecto

master
Victor 9 months ago
commit 8221fffdea

@ -0,0 +1,2 @@
# Proyecto_SystemStatus

@ -0,0 +1,53 @@
import psutil
threads_por_nucleo = psutil.cpu_count(logical=False)
memoria = psutil.virtual_memory()
def get_running_processes():
# Using list comprehension to get information about all running processes
return [proc.info for proc in psutil.process_iter(['pid', 'name', 'username'])]
def procesesRunning():
# Get and print information about all running processes
running_processes = get_running_processes()
# Print the information without a separate loop
print("\n".join([f"PID: {process['pid']}, Name: {process['name']}, User: {process['username']}" for process in running_processes]))
battery = psutil.sensors_battery()
plugged = battery.power_plugged
percent = str(battery.percent)
plugged = "Plugged In" if plugged else "Not Plugged In"
ans=True
while ans:
print("""
1. Hilos por nucleo
2. Memoria Total
3. Memoria Diponible
4. Porcentaje de memoria utilizada
5. El estado de bateria
6. Procesos activados
7. El uso del CPU
8. Exit/Quit
""")
ans=input("Elige que tipo de informacio deseas saber:")
if ans=="1":
print(f"Tu procesador tiene {threads_por_nucleo} hilos por núcleo.")
elif ans=="2":
print(f"Memoria total: {memoria.total} bytes")
elif ans=="3":
print(f"Memoria disponible: {memoria.available} bytes")
elif ans == "4":
print(f"Porcentaje de memoria utilizada: {memoria.percent}%")
elif ans == "5":
print(percent+'% | '+plugged)
elif ans == "6":
procesesRunning()
elif ans == "7":
cpu_usage = psutil.cpu_percent(interval=1)
print(f"CPU Usage: {cpu_usage}%")
elif ans=="8":
print("\n Goodbye")
ans = None
else:
print("\n Not Valid Choice Try again")
Loading…
Cancel
Save

Powered by INFORMATICA.FP.EDU.ES.