top of page

import psutil
from datetime import datetime

def system_info():

    # --- Pulls Drive Informaiton ---
    partitions = psutil.disk_partitions(all=False)
    devices = [partition.device for partition in partitions]  # Extract 'device' field

    # --- Get Boot Time / Timestamp ---
    boot_time_timestamp = psutil.boot_time()    
    # Convert timestamp to a datetime object
    boot_time = datetime.fromtimestamp(boot_time_timestamp)    
    # Format the datetime object for readability
    readable_time = boot_time.strftime("%Y-%m-%d")


    # --------------------  Dictonary List | Key Value Pairs --------------------
    myHash ={
        'CPU_Count':psutil.cpu_count(logical=True), # Number of logical CPUs.
        'Hard_Drives':devices, # CPU utilization as a percentage.
        'Boot_Time':readable_time # System Last 
        }
    # --- Return Value ---
    return myHash

 

# --- Call Function and Assign to Var ---
All_Info=system_info()

 

# --- Da Loop and Display ---
for key, value in All_Info.items():
    print(f"{key}: {value}")

# --- Direct Refernce ---
print(All_Info['Boot_Time'])
 

PSUTIL System Info

PSUTIL-SystemInfo.png
bottom of page