From 121ba406c612bacfb48e2eeaac91de3819ce59b3 Mon Sep 17 00:00:00 2001 From: Maday44 Date: Sun, 9 Aug 2026 21:30:59 +0100 Subject: [PATCH 1/3] Add basic system information and input devices --- My-PC/README.md | 0 My-PC/info.py | 66 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 My-PC/README.md create mode 100644 My-PC/info.py diff --git a/My-PC/README.md b/My-PC/README.md new file mode 100644 index 0000000..e69de29 diff --git a/My-PC/info.py b/My-PC/info.py new file mode 100644 index 0000000..5e606c6 --- /dev/null +++ b/My-PC/info.py @@ -0,0 +1,66 @@ +import win32com.client +import wmi + +def info_pc(): + c = wmi.WMI() + my_system = c.Win32_ComputerSystem()[0] + + print(f"Manufacturer: {my_system.Manufacturer}") + print(f"Model: {my_system. Model}") + print(f"Name: {my_system.Name}") + print(f"NumberOfProcessors: {my_system.NumberOfProcessors}") + print(f"SystemType: {my_system.SystemType}") + print(f"SystemFamily: {my_system.SystemFamily}") + + +def list_plugged_in_devices(): + print("Loading getting machine devices\n") + + # WMI API + wmi = win32com.client.GetObject("winmgmts:") + + # query used to get the device information + devices = wmi.ExecQuery( + """ + SELECT Name, DeviceID, Manufacturer, PNPClass, Present, ConfigManagerErrorCode + FROM Win32_PnPEntity + WHERE Present = True AND Manufacturer != 'Microsoft' + """ + ) + + + print(f"({len(devices)} devices found: \n") + for dev in list(devices): + print(f"Device Name: {dev.Name}") + print(f" * Manufacturer: {dev.Manufacturer}") + print(f" * Class type: {dev.PNPClass}") + print(f" * Device ID: {dev.DeviceID}") + print(f" * Status Code: {dev.ConfigManagerErrorCode} (0 = Working Perfect)") + print("-" * 100) + + +def user_console(): + while True: + print("\n See Pc information") + print("1) Standard device information") + print("2) Input devices") + print("3) Quit") + + try: + option = int(input("What would you like to see about your device? (1-3): ")) + + if option == 1: + info_pc() + elif option == 2: + list_plugged_in_devices() + elif option == 3: + print("Exiting console application. Goodbye!") + break + else: + print("Invalid choice! Please choose 1, 2, or 3.") + + except ValueError: + print("Error: Please enter a valid number (1, 2, or 3).") + +if __name__ == "__main__": + user_console() From ab41eeb6b0739013bcdbfb5d924f9ee618c3ad56 Mon Sep 17 00:00:00 2001 From: Maday44 Date: Tue, 18 Aug 2026 22:07:35 +0100 Subject: [PATCH 2/3] Get Pc information When running in terminal, can pick a choice to get input devices plugged in, pc inoprmwtion, and network information through this terminal design --- My-PC/info.py | 63 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/My-PC/info.py b/My-PC/info.py index 5e606c6..17cba89 100644 --- a/My-PC/info.py +++ b/My-PC/info.py @@ -1,8 +1,23 @@ import win32com.client import wmi +import socket +import psutil + + +# code source: https://thepythoncode.com/article/get-hardware-system-information-python +def bytes_to_human(value, suffix="B"): + if value is None: + return "N/A" + value = float(value) + for unit in ("", "K", "M", "G", "T", "P"): + if abs(value) < 1024: + return f"{value:.2f}{unit}{suffix}" + value /= 1024 + return f"{value:.2f}EB" + def info_pc(): - c = wmi.WMI() + c = wmi.WMI() my_system = c.Win32_ComputerSystem()[0] print(f"Manufacturer: {my_system.Manufacturer}") @@ -15,20 +30,17 @@ def info_pc(): def list_plugged_in_devices(): print("Loading getting machine devices\n") - + # WMI API wmi = win32com.client.GetObject("winmgmts:") # query used to get the device information - devices = wmi.ExecQuery( - """ + devices = wmi.ExecQuery(""" SELECT Name, DeviceID, Manufacturer, PNPClass, Present, ConfigManagerErrorCode FROM Win32_PnPEntity WHERE Present = True AND Manufacturer != 'Microsoft' - """ - ) + """) - print(f"({len(devices)} devices found: \n") for dev in list(devices): print(f"Device Name: {dev.Name}") @@ -39,28 +51,53 @@ def list_plugged_in_devices(): print("-" * 100) +def network_info(): + for name, addresses in psutil.net_if_addrs().items(): + print("Interface:", name) + for address in addresses: + if address.family == socket.AF_INET: + print(" IPv4:", address.address) + print(" Netmask:", address.netmask) + elif address.family == socket.AF_INET6: + print(" IPv6:", address.address) + elif hasattr(psutil, "AF_LINK") and address.family == psutil.AF_LINK: + print(" MAC:", address.address) + + stats = psutil.net_if_stats() + for name, stat in stats.items(): + print(name, "up=" + str(stat.isup), "speed=" + str(stat.speed), "Mbps") + + io = psutil.net_io_counters() + print("Bytes sent:", bytes_to_human(io.bytes_sent)) + print("Bytes received:", bytes_to_human(io.bytes_recv)) + + def user_console(): while True: print("\n See Pc information") print("1) Standard device information") print("2) Input devices") - print("3) Quit") - + print("3) Network Interface") + print("4) Quit") + try: - option = int(input("What would you like to see about your device? (1-3): ")) - + option = int(input("What would you like to see about your device? (1-4): ")) + if option == 1: info_pc() elif option == 2: list_plugged_in_devices() elif option == 3: + network_info() + elif option == 4: print("Exiting console application. Goodbye!") - break + break else: print("Invalid choice! Please choose 1, 2, or 3.") - + except ValueError: print("Error: Please enter a valid number (1, 2, or 3).") + if __name__ == "__main__": user_console() From da34275b25a3afed009d52c965c4239966cb971d Mon Sep 17 00:00:00 2001 From: Maday44 Date: Tue, 18 Aug 2026 22:21:01 +0100 Subject: [PATCH 3/3] add requirement.txt --- My-PC/MyWebsite | 1 + My-PC/requirements.txt | Bin 0 -> 92 bytes 2 files changed, 1 insertion(+) create mode 160000 My-PC/MyWebsite create mode 100644 My-PC/requirements.txt diff --git a/My-PC/MyWebsite b/My-PC/MyWebsite new file mode 160000 index 0000000..2fe5f48 --- /dev/null +++ b/My-PC/MyWebsite @@ -0,0 +1 @@ +Subproject commit 2fe5f48b309791b5aca8b94e85cf67236df347ef diff --git a/My-PC/requirements.txt b/My-PC/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..fb60ddefd83e040bf162f2f48a4185599fdee413 GIT binary patch literal 92 zcmezW&xs+Gp@N}=!4?P&81xtn!I+nUiy@gIpCJc`ix?6aa)B78!UU+olmVoofT5V7 T6sR{7s177+4wNwhV~{KW09_6Z literal 0 HcmV?d00001