commit 8221fffdea45d8f63dd6d14e6c8c242574079d39 Author: Victor Date: Wed Dec 13 16:49:57 2023 +0100 Primer Commit, base de pryecto diff --git a/README.md b/README.md new file mode 100644 index 0000000..a20c2aa --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# Proyecto_SystemStatus + diff --git a/main.py b/main.py new file mode 100644 index 0000000..2075a41 --- /dev/null +++ b/main.py @@ -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") \ No newline at end of file