diff --git a/pyarchitecture/__init__.py b/pyarchitecture/__init__.py index 3c21ac1..1f77993 100644 --- a/pyarchitecture/__init__.py +++ b/pyarchitecture/__init__.py @@ -96,7 +96,7 @@ def commandline() -> None: if cpu_info and not save_info: pprint(cpu.get_cpu_info()) if gpu_info and not save_info: - pprint(gpu.get_gpu_names()) + pprint(gpu.get_gpu_info()) if mem_info and not save_info: pprint(memory.get_memory_info()) if all_info and not save_info: @@ -114,7 +114,7 @@ def commandline() -> None: if cpu_info: data["CPU"] = cpu.get_cpu_info() if gpu_info: - data["GPU"] = gpu.get_gpu_names() + data["GPU"] = gpu.get_gpu_info() if disk_info: data["Disks"] = disks.get_all_disks() if mem_info: diff --git a/pyarchitecture/cpu/main.py b/pyarchitecture/cpu/main.py index 59dcd98..ae189eb 100644 --- a/pyarchitecture/cpu/main.py +++ b/pyarchitecture/cpu/main.py @@ -2,7 +2,7 @@ import os import subprocess -from pyarchitecture import models +from pyarchitecture.cpu import models LOGGER = logging.getLogger(__name__) diff --git a/pyarchitecture/disks/linux.py b/pyarchitecture/disks/linux.py index 3ae6398..6c8df16 100644 --- a/pyarchitecture/disks/linux.py +++ b/pyarchitecture/disks/linux.py @@ -22,23 +22,23 @@ def drive_info(disk_lib: str | os.PathLike) -> List[Dict[str, str]]: for device in data.get("blockdevices", []): if device["type"] == "disk": disk_info = { - "DeviceID": device["name"], - "Size": device["size"], - "Name": device.get("model", "Unknown"), - "Mountpoints": [], + "device_id": device["name"], + "size": device["size"], + "name": device.get("model", "Unknown"), + "mountpoints": [], } # Collect mount points from partitions if "children" in device: for partition in device["children"]: if partition.get("mountpoint"): - disk_info["Mountpoints"].append(partition["mountpoint"]) - if not disk_info["Mountpoints"] and device.get("mountpoint"): + disk_info["mountpoints"].append(partition["mountpoint"]) + if not disk_info["mountpoints"] and device.get("mountpoint"): if isinstance(device["mountpoint"], list): - disk_info["Mountpoints"] = device["mountpoint"] + disk_info["mountpoints"] = device["mountpoint"] else: - disk_info["Mountpoints"] = [device["mountpoint"]] - elif not disk_info["Mountpoints"]: - disk_info["Mountpoints"] = ["Not Mounted"] - disk_info["Mountpoints"] = ", ".join(disk_info["Mountpoints"]) + disk_info["mountpoints"] = [device["mountpoint"]] + elif not disk_info["mountpoints"]: + disk_info["mountpoints"] = ["Not Mounted"] + disk_info["mountpoints"] = ", ".join(disk_info["Mountpoints"]) disks.append(disk_info) return disks diff --git a/pyarchitecture/disks/macOS.py b/pyarchitecture/disks/macOS.py index 048ff3b..84b92ce 100644 --- a/pyarchitecture/disks/macOS.py +++ b/pyarchitecture/disks/macOS.py @@ -95,17 +95,17 @@ def drive_info(disk_lib: str | os.PathLike) -> List[Dict[str, str]]: if disk.get("Virtual") == "No": physical_disks.append( { - "Name": disk.get("Device / Media Name"), - "Size": squire.size_converter( + "name": disk.get("Device / Media Name"), + "size": squire.size_converter( parse_size(disk.get("Disk Size", "")) ), - "DeviceID": disk.get("Device Identifier"), - "Node": disk.get("Device Node"), + "device_id": disk.get("Device Identifier"), + "node": disk.get("Device Node"), } ) # Instantiate default dict with keys as DeviceIDs and values as empty list _ = device_ids[disk["Device Identifier"]] mountpoints = update_mountpoints(disks, device_ids) for disk in physical_disks: - disk["Mountpoints"] = ", ".join(mountpoints[disk["DeviceID"]]) + disk["mountpoints"] = ", ".join(mountpoints[disk["device_id"]]) return physical_disks diff --git a/pyarchitecture/disks/windows.py b/pyarchitecture/disks/windows.py index 86b9d17..d745896 100644 --- a/pyarchitecture/disks/windows.py +++ b/pyarchitecture/disks/windows.py @@ -22,9 +22,9 @@ def reformat_windows(data: Dict[str, str | int | float]) -> Dict[str, str]: Returns a dictionary of key-value pairs. """ data["ID"] = data["DeviceID"][-1] - data["Name"] = data["Model"] - data["DeviceID"] = data["DeviceID"].replace("\\", "").replace(".", "") - data["Size"] = squire.size_converter(data["Size"]) + data["name"] = data["Model"] + data["device_id"] = data["DeviceID"].replace("\\", "").replace(".", "") + data["size"] = squire.size_converter(data["Size"]) del data["Caption"] del data["Model"] return data diff --git a/pyarchitecture/memory/__init__.py b/pyarchitecture/memory/__init__.py index f0b3c81..848248c 100644 --- a/pyarchitecture/memory/__init__.py +++ b/pyarchitecture/memory/__init__.py @@ -2,7 +2,7 @@ import os from typing import Dict -from pyarchitecture import models +from pyarchitecture import models, squire from pyarchitecture.memory import linux, macOS, windows LOGGER = logging.getLogger(__name__) @@ -26,11 +26,14 @@ def _get_mem_lib(user_input: str | os.PathLike) -> str: return mem_lib -def get_memory_info(mem_lib: str | os.PathLike = None) -> Dict[str, int]: +def get_memory_info( + mem_lib: str | os.PathLike = None, humanize: bool = True +) -> Dict[str, int | str]: """OS-agnostic function to get memory information. Args: mem_lib: Custom memory library path. + humanize: Flag to return humanized memory info. Returns: Dict[str, int]: @@ -42,6 +45,9 @@ def get_memory_info(mem_lib: str | os.PathLike = None) -> Dict[str, int]: models.OperatingSystem.windows: windows.get_memory_info, } try: - return os_map[models.OPERATING_SYSTEM](mem_lib) + raw_info = os_map[models.OPERATING_SYSTEM](_get_mem_lib(mem_lib)) + if humanize: + return {k: squire.size_converter(v) for k, v in raw_info.items()} + return raw_info except Exception as error: LOGGER.error(error) diff --git a/pyarchitecture/memory/windows.py b/pyarchitecture/memory/windows.py index b7e90ef..7ad417a 100644 --- a/pyarchitecture/memory/windows.py +++ b/pyarchitecture/memory/windows.py @@ -25,7 +25,7 @@ class MEMORYSTATUSEX(ctypes.Structure): ] -def get_memory_info(*args) -> Dict[str, int]: +def get_memory_info(_: str) -> Dict[str, int]: """Get memory information for Windows OS. Returns: