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/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..17cba89 --- /dev/null +++ b/My-PC/info.py @@ -0,0 +1,103 @@ +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() + 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 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) Network Interface") + print("4) Quit") + + try: + 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 + 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() diff --git a/My-PC/requirements.txt b/My-PC/requirements.txt new file mode 100644 index 0000000..fb60dde Binary files /dev/null and b/My-PC/requirements.txt differ