From 0419678d4e6a6d885298ef2fa1990eaa3abd2047 Mon Sep 17 00:00:00 2001 From: Alexander Rossmanith Date: Fri, 7 Aug 2026 20:16:38 +0530 Subject: [PATCH] initial commit --- README.md | 0 poetry.lock | 58 +++++++++++++++++++++++++++++++++++ pyproject.toml | 19 ++++++++++++ src/usbdeviceinfo/__init__.py | 0 src/usbdeviceinfo/main.py | 29 ++++++++++++++++++ tests/__init__.py | 0 6 files changed, 106 insertions(+) create mode 100644 README.md create mode 100644 poetry.lock create mode 100644 pyproject.toml create mode 100644 src/usbdeviceinfo/__init__.py create mode 100644 src/usbdeviceinfo/main.py create mode 100644 tests/__init__.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..b1a6fc4 --- /dev/null +++ b/poetry.lock @@ -0,0 +1,58 @@ +# This file is automatically @generated by Poetry 2.2.1 and should not be changed by hand. + +[[package]] +name = "pywin32" +version = "311" +description = "Python for Window Extensions" +optional = false +python-versions = "*" +groups = ["main"] +files = [ + {file = "pywin32-311-cp310-cp310-win32.whl", hash = "sha256:d03ff496d2a0cd4a5893504789d4a15399133fe82517455e78bad62efbb7f0a3"}, + {file = "pywin32-311-cp310-cp310-win_amd64.whl", hash = "sha256:797c2772017851984b97180b0bebe4b620bb86328e8a884bb626156295a63b3b"}, + {file = "pywin32-311-cp310-cp310-win_arm64.whl", hash = "sha256:0502d1facf1fed4839a9a51ccbcc63d952cf318f78ffc00a7e78528ac27d7a2b"}, + {file = "pywin32-311-cp311-cp311-win32.whl", hash = "sha256:184eb5e436dea364dcd3d2316d577d625c0351bf237c4e9a5fabbcfa5a58b151"}, + {file = "pywin32-311-cp311-cp311-win_amd64.whl", hash = "sha256:3ce80b34b22b17ccbd937a6e78e7225d80c52f5ab9940fe0506a1a16f3dab503"}, + {file = "pywin32-311-cp311-cp311-win_arm64.whl", hash = "sha256:a733f1388e1a842abb67ffa8e7aad0e70ac519e09b0f6a784e65a136ec7cefd2"}, + {file = "pywin32-311-cp312-cp312-win32.whl", hash = "sha256:750ec6e621af2b948540032557b10a2d43b0cee2ae9758c54154d711cc852d31"}, + {file = "pywin32-311-cp312-cp312-win_amd64.whl", hash = "sha256:b8c095edad5c211ff31c05223658e71bf7116daa0ecf3ad85f3201ea3190d067"}, + {file = "pywin32-311-cp312-cp312-win_arm64.whl", hash = "sha256:e286f46a9a39c4a18b319c28f59b61de793654af2f395c102b4f819e584b5852"}, + {file = "pywin32-311-cp313-cp313-win32.whl", hash = "sha256:f95ba5a847cba10dd8c4d8fefa9f2a6cf283b8b88ed6178fa8a6c1ab16054d0d"}, + {file = "pywin32-311-cp313-cp313-win_amd64.whl", hash = "sha256:718a38f7e5b058e76aee1c56ddd06908116d35147e133427e59a3983f703a20d"}, + {file = "pywin32-311-cp313-cp313-win_arm64.whl", hash = "sha256:7b4075d959648406202d92a2310cb990fea19b535c7f4a78d3f5e10b926eeb8a"}, + {file = "pywin32-311-cp314-cp314-win32.whl", hash = "sha256:b7a2c10b93f8986666d0c803ee19b5990885872a7de910fc460f9b0c2fbf92ee"}, + {file = "pywin32-311-cp314-cp314-win_amd64.whl", hash = "sha256:3aca44c046bd2ed8c90de9cb8427f581c479e594e99b5c0bb19b29c10fd6cb87"}, + {file = "pywin32-311-cp314-cp314-win_arm64.whl", hash = "sha256:a508e2d9025764a8270f93111a970e1d0fbfc33f4153b388bb649b7eec4f9b42"}, + {file = "pywin32-311-cp38-cp38-win32.whl", hash = "sha256:6c6f2969607b5023b0d9ce2541f8d2cbb01c4f46bc87456017cf63b73f1e2d8c"}, + {file = "pywin32-311-cp38-cp38-win_amd64.whl", hash = "sha256:c8015b09fb9a5e188f83b7b04de91ddca4658cee2ae6f3bc483f0b21a77ef6cd"}, + {file = "pywin32-311-cp39-cp39-win32.whl", hash = "sha256:aba8f82d551a942cb20d4a83413ccbac30790b50efb89a75e4f586ac0bb8056b"}, + {file = "pywin32-311-cp39-cp39-win_amd64.whl", hash = "sha256:e0c4cfb0621281fe40387df582097fd796e80430597cb9944f0ae70447bacd91"}, + {file = "pywin32-311-cp39-cp39-win_arm64.whl", hash = "sha256:62ea666235135fee79bb154e695f3ff67370afefd71bd7fea7512fc70ef31e3d"}, +] + +[[package]] +name = "wmi" +version = "1.5.1" +description = "Windows Management Instrumentation" +optional = false +python-versions = "*" +groups = ["main"] +files = [ + {file = "WMI-1.5.1-py2.py3-none-any.whl", hash = "sha256:1d6b085e5c445141c475476000b661f60fff1aaa19f76bf82b7abb92e0ff4942"}, + {file = "WMI-1.5.1.tar.gz", hash = "sha256:b6a6be5711b1b6c8d55bda7a8befd75c48c12b770b9d227d31c1737dbf0d40a6"}, +] + +[package.dependencies] +pywin32 = "*" + +[package.extras] +all = ["pytest", "sphinx", "twine", "wheel"] +dev = ["pytest", "sphinx", "twine", "wheel"] +docs = ["sphinx"] +package = ["twine", "wheel"] +tests = ["pytest"] + +[metadata] +lock-version = "2.1" +python-versions = ">=3.11" +content-hash = "46b21e085660df7f6d643f0df534aee5acb9d605211ef719027e26e8b2aa972d" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..b34f723 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,19 @@ +[project] +name = "usbdeviceinfo" +version = "0.1.0" +description = "" +authors = [ + {name = "Your Name",email = "you@example.com"} +] +readme = "README.md" +requires-python = ">=3.11" +dependencies = [ + "wmi (>=1.5.1,<2.0.0)" +] + +[tool.poetry] +packages = [{include = "usbdeviceinfo", from = "src"}] + +[build-system] +requires = ["poetry-core>=2.0.0,<3.0.0"] +build-backend = "poetry.core.masonry.api" diff --git a/src/usbdeviceinfo/__init__.py b/src/usbdeviceinfo/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/usbdeviceinfo/main.py b/src/usbdeviceinfo/main.py new file mode 100644 index 0000000..8f7ad85 --- /dev/null +++ b/src/usbdeviceinfo/main.py @@ -0,0 +1,29 @@ +import argparse +import wmi + + +def main(): + parser = argparse.ArgumentParser(description="Get physical disk info from drive letter") + parser.add_argument("driveletter", help="Drive letter (e.g., E:)") + args = parser.parse_args() + try: + driveinfo = get_driveinfo(args.driveletter) + print(f"Model : {driveinfo.Model}") + print(f"Serial Number: {driveinfo.SerialNumber}") + print(f"Manufacturer : {driveinfo.Manufacturer}") + except ValueError: + print(f"No physical disk found for drive letter {args.driveletter}") + + +def get_driveinfo(driveletter): + c = wmi.WMI() + for disk in c.Win32_DiskDrive(): + for partition in disk.associators("Win32_DiskDriveToDiskPartition"): + for logical_disk in partition.associators("Win32_LogicalDiskToPartition"): + if logical_disk.DeviceID.upper() == driveletter.upper(): + return disk + raise ValueError + + +if __name__ == "__main__": + main() diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29