HWProbe 0.0.1b1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. hwprobe-0.0.1b1/LICENSE +12 -0
  2. hwprobe-0.0.1b1/PKG-INFO +94 -0
  3. hwprobe-0.0.1b1/README.md +78 -0
  4. hwprobe-0.0.1b1/pyproject.toml +38 -0
  5. hwprobe-0.0.1b1/setup.cfg +4 -0
  6. hwprobe-0.0.1b1/src/HWProbe.egg-info/PKG-INFO +94 -0
  7. hwprobe-0.0.1b1/src/HWProbe.egg-info/SOURCES.txt +64 -0
  8. hwprobe-0.0.1b1/src/HWProbe.egg-info/dependency_links.txt +1 -0
  9. hwprobe-0.0.1b1/src/HWProbe.egg-info/requires.txt +1 -0
  10. hwprobe-0.0.1b1/src/HWProbe.egg-info/top_level.txt +1 -0
  11. hwprobe-0.0.1b1/src/hwprobe/__init__.py +38 -0
  12. hwprobe-0.0.1b1/src/hwprobe/core/common/edid.py +128 -0
  13. hwprobe-0.0.1b1/src/hwprobe/core/linux/__init__.py +2 -0
  14. hwprobe-0.0.1b1/src/hwprobe/core/linux/common.py +52 -0
  15. hwprobe-0.0.1b1/src/hwprobe/core/linux/cpu.py +178 -0
  16. hwprobe-0.0.1b1/src/hwprobe/core/linux/display.py +33 -0
  17. hwprobe-0.0.1b1/src/hwprobe/core/linux/dmi_decode.py +54 -0
  18. hwprobe-0.0.1b1/src/hwprobe/core/linux/graphics.py +191 -0
  19. hwprobe-0.0.1b1/src/hwprobe/core/linux/manager.py +62 -0
  20. hwprobe-0.0.1b1/src/hwprobe/core/linux/memory.py +174 -0
  21. hwprobe-0.0.1b1/src/hwprobe/core/linux/network.py +106 -0
  22. hwprobe-0.0.1b1/src/hwprobe/core/linux/storage.py +140 -0
  23. hwprobe-0.0.1b1/src/hwprobe/core/mac/__init__.py +2 -0
  24. hwprobe-0.0.1b1/src/hwprobe/core/mac/cpu.py +141 -0
  25. hwprobe-0.0.1b1/src/hwprobe/core/mac/deprecated/common.py +66 -0
  26. hwprobe-0.0.1b1/src/hwprobe/core/mac/deprecated/ioreg.py +199 -0
  27. hwprobe-0.0.1b1/src/hwprobe/core/mac/display.py +127 -0
  28. hwprobe-0.0.1b1/src/hwprobe/core/mac/graphics.py +204 -0
  29. hwprobe-0.0.1b1/src/hwprobe/core/mac/manager.py +61 -0
  30. hwprobe-0.0.1b1/src/hwprobe/core/mac/memory.py +242 -0
  31. hwprobe-0.0.1b1/src/hwprobe/core/mac/network.py +249 -0
  32. hwprobe-0.0.1b1/src/hwprobe/core/mac/storage.py +74 -0
  33. hwprobe-0.0.1b1/src/hwprobe/core/windows/__init__.py +1 -0
  34. hwprobe-0.0.1b1/src/hwprobe/core/windows/audio.py +72 -0
  35. hwprobe-0.0.1b1/src/hwprobe/core/windows/baseboard.py +32 -0
  36. hwprobe-0.0.1b1/src/hwprobe/core/windows/common.py +44 -0
  37. hwprobe-0.0.1b1/src/hwprobe/core/windows/cpu.py +189 -0
  38. hwprobe-0.0.1b1/src/hwprobe/core/windows/display.py +777 -0
  39. hwprobe-0.0.1b1/src/hwprobe/core/windows/graphics.py +42 -0
  40. hwprobe-0.0.1b1/src/hwprobe/core/windows/manager.py +72 -0
  41. hwprobe-0.0.1b1/src/hwprobe/core/windows/memory.py +158 -0
  42. hwprobe-0.0.1b1/src/hwprobe/core/windows/network.py +84 -0
  43. hwprobe-0.0.1b1/src/hwprobe/core/windows/storage.py +95 -0
  44. hwprobe-0.0.1b1/src/hwprobe/core/windows/win_enum.py +116 -0
  45. hwprobe-0.0.1b1/src/hwprobe/interops/mac/bindings/gpu_info.py +154 -0
  46. hwprobe-0.0.1b1/src/hwprobe/interops/mac/bindings/storage_info.py +100 -0
  47. hwprobe-0.0.1b1/src/hwprobe/interops/win/bindings/__init__.py +0 -0
  48. hwprobe-0.0.1b1/src/hwprobe/interops/win/bindings/gpu_info.py +129 -0
  49. hwprobe-0.0.1b1/src/hwprobe/interops/win/dll/hw_helper.dll +0 -0
  50. hwprobe-0.0.1b1/src/hwprobe/interops/win/legacy/constants.py +48 -0
  51. hwprobe-0.0.1b1/src/hwprobe/interops/win/legacy/signatures.py +164 -0
  52. hwprobe-0.0.1b1/src/hwprobe/interops/win/legacy/structs.py +104 -0
  53. hwprobe-0.0.1b1/src/hwprobe/models/audio_models.py +42 -0
  54. hwprobe-0.0.1b1/src/hwprobe/models/baseboard_models.py +19 -0
  55. hwprobe-0.0.1b1/src/hwprobe/models/component_model.py +8 -0
  56. hwprobe-0.0.1b1/src/hwprobe/models/cpu_models.py +31 -0
  57. hwprobe-0.0.1b1/src/hwprobe/models/display_models.py +59 -0
  58. hwprobe-0.0.1b1/src/hwprobe/models/gpu_models.py +66 -0
  59. hwprobe-0.0.1b1/src/hwprobe/models/info_models.py +79 -0
  60. hwprobe-0.0.1b1/src/hwprobe/models/memory_models.py +33 -0
  61. hwprobe-0.0.1b1/src/hwprobe/models/network_models.py +33 -0
  62. hwprobe-0.0.1b1/src/hwprobe/models/size_models.py +21 -0
  63. hwprobe-0.0.1b1/src/hwprobe/models/status_models.py +64 -0
  64. hwprobe-0.0.1b1/src/hwprobe/models/storage_models.py +36 -0
  65. hwprobe-0.0.1b1/src/hwprobe/util/location_paths.py +314 -0
  66. hwprobe-0.0.1b1/src/hwprobe/util/nvidia.py +42 -0
@@ -0,0 +1,12 @@
1
+ Copyright 2025 Mahasvan Mohan
2
+
3
+ Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
4
+
5
+ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
6
+
7
+ 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8
+
9
+ 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10
+
11
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
12
+
@@ -0,0 +1,94 @@
1
+ Metadata-Version: 2.4
2
+ Name: HWProbe
3
+ Version: 0.0.1b1
4
+ Summary: A cross-platform system information gatherer
5
+ Author-email: Mahasvan <mahasvan@gmail.com>
6
+ License-Expression: BSD-3-Clause
7
+ Project-URL: Homepage, https://github.com/Mahasvan/HWProbe
8
+ Project-URL: Issues, https://github.com/Mahasvan/HWProbe/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: pydantic
15
+ Dynamic: license-file
16
+
17
+ # HWProbe
18
+
19
+ A Python Library to simplify retrieval of hardware components of your computer.
20
+
21
+ - To get started, read the **[Quickstart](https://mahasvan.github.io/HWProbe/quickstart.html).**
22
+ - Additionally, you can view the **[Documentation](https://mahasvan.github.io/HWProbe/)**.
23
+
24
+ ## Installation
25
+
26
+ ### macOS / Linux
27
+
28
+ ```bash
29
+ pip3 install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ HWProbe
30
+ ```
31
+
32
+ ### Windows
33
+
34
+ ```bash
35
+ pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ HWProbe
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ```python
41
+ from hwprobe import HardwareManager
42
+ import json
43
+
44
+ hm = HardwareManager()
45
+
46
+ data = hm.fetch_hardware_info()
47
+
48
+ # All data returned are Pydantic models and have strict schema
49
+ # You can use it as is, or serialize it to JSON if you wish.
50
+ # We print the data in JSON here for readability.
51
+
52
+ json_data = json.loads(data.model_dump_json())
53
+ print(json.dumps(json_data, indent=2))
54
+ ```
55
+
56
+ ## Tracker
57
+
58
+ ### Hardware Discovery Progress Tracker
59
+
60
+ | Component | Linux | macOS | Windows |
61
+ |-------------|:-----:|:------:|:-------:|
62
+ | CPU | ✅ | ✅ | ✅ |
63
+ | GPU | ✅ | ✅ | ✅ |
64
+ | Memory | ✅ | ✅ | ✅ |
65
+ | Network | ✅ | ✅ | ✅ |
66
+ | Storage | ✅ | ✅ | ✅ |
67
+ | -- | -- | - | - |
68
+ | Display | ❌ | ❌* (2) | ✅* (3) |
69
+ | Audio | ❌ | ❌ | ✅* (3) |
70
+ | Motherboard | ❌ | ❌ | ✅ |
71
+ | Vendor | ❌ | ❌ | ➖ |
72
+ | Input | ❌ | ❌ | ❌ |
73
+
74
+ 1. PCIe gen info only for Nvidia
75
+ 2. In progress
76
+ 3. Need to rewrite C++ bindings
77
+
78
+ ### Miscellaneous Tasks / Problems
79
+
80
+ | Task | Status |
81
+ |--------------------------------------------------------------------------------------------------|:------:|
82
+ | GH actions for compiling `interops/{platform}/*.{c\|cpp}` to their respective output directories | ❌ |
83
+ | Group Pydantic Model fields into essential and optional | ❌ |
84
+ | Remove `pyobjc` dependency in macOS by rewriting dependent code chunks in C++ | ✅ |
85
+ | Autodetection of storage units | ❌ |
86
+
87
+ ### Supporting Features
88
+
89
+ | Feature | Status |
90
+ |------------------------------------------------------------------------------------------------------------------------------|:------:|
91
+ | PCI Lookup — [DeviceHunt](https://devicehunt.com) | ❌ |
92
+ | PCI Lookup — [PCI IDs Repository](https://pci-ids.ucw.cz) ([GitHub](https://github.com/pciutils/pciids/blob/master/pci.ids)) | ❌ |
93
+ | Logging | ✅ |
94
+ | Working Library | ✅ |
@@ -0,0 +1,78 @@
1
+ # HWProbe
2
+
3
+ A Python Library to simplify retrieval of hardware components of your computer.
4
+
5
+ - To get started, read the **[Quickstart](https://mahasvan.github.io/HWProbe/quickstart.html).**
6
+ - Additionally, you can view the **[Documentation](https://mahasvan.github.io/HWProbe/)**.
7
+
8
+ ## Installation
9
+
10
+ ### macOS / Linux
11
+
12
+ ```bash
13
+ pip3 install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ HWProbe
14
+ ```
15
+
16
+ ### Windows
17
+
18
+ ```bash
19
+ pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ HWProbe
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ```python
25
+ from hwprobe import HardwareManager
26
+ import json
27
+
28
+ hm = HardwareManager()
29
+
30
+ data = hm.fetch_hardware_info()
31
+
32
+ # All data returned are Pydantic models and have strict schema
33
+ # You can use it as is, or serialize it to JSON if you wish.
34
+ # We print the data in JSON here for readability.
35
+
36
+ json_data = json.loads(data.model_dump_json())
37
+ print(json.dumps(json_data, indent=2))
38
+ ```
39
+
40
+ ## Tracker
41
+
42
+ ### Hardware Discovery Progress Tracker
43
+
44
+ | Component | Linux | macOS | Windows |
45
+ |-------------|:-----:|:------:|:-------:|
46
+ | CPU | ✅ | ✅ | ✅ |
47
+ | GPU | ✅ | ✅ | ✅ |
48
+ | Memory | ✅ | ✅ | ✅ |
49
+ | Network | ✅ | ✅ | ✅ |
50
+ | Storage | ✅ | ✅ | ✅ |
51
+ | -- | -- | - | - |
52
+ | Display | ❌ | ❌* (2) | ✅* (3) |
53
+ | Audio | ❌ | ❌ | ✅* (3) |
54
+ | Motherboard | ❌ | ❌ | ✅ |
55
+ | Vendor | ❌ | ❌ | ➖ |
56
+ | Input | ❌ | ❌ | ❌ |
57
+
58
+ 1. PCIe gen info only for Nvidia
59
+ 2. In progress
60
+ 3. Need to rewrite C++ bindings
61
+
62
+ ### Miscellaneous Tasks / Problems
63
+
64
+ | Task | Status |
65
+ |--------------------------------------------------------------------------------------------------|:------:|
66
+ | GH actions for compiling `interops/{platform}/*.{c\|cpp}` to their respective output directories | ❌ |
67
+ | Group Pydantic Model fields into essential and optional | ❌ |
68
+ | Remove `pyobjc` dependency in macOS by rewriting dependent code chunks in C++ | ✅ |
69
+ | Autodetection of storage units | ❌ |
70
+
71
+ ### Supporting Features
72
+
73
+ | Feature | Status |
74
+ |------------------------------------------------------------------------------------------------------------------------------|:------:|
75
+ | PCI Lookup — [DeviceHunt](https://devicehunt.com) | ❌ |
76
+ | PCI Lookup — [PCI IDs Repository](https://pci-ids.ucw.cz) ([GitHub](https://github.com/pciutils/pciids/blob/master/pci.ids)) | ❌ |
77
+ | Logging | ✅ |
78
+ | Working Library | ✅ |
@@ -0,0 +1,38 @@
1
+ [build-system]
2
+ requires = ["setuptools"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [tool.setuptools.dynamic]
6
+ version = { attr = "hwprobe.__version__" }
7
+
8
+ [project]
9
+ name = "HWProbe"
10
+ dynamic = ["version"]
11
+ description = "A cross-platform system information gatherer"
12
+ readme = "README.md"
13
+ requires-python = ">=3.9"
14
+ license = "BSD-3-Clause"
15
+ license-files = ["LICEN[CS]E*"]
16
+
17
+ authors = [
18
+ { name = "Mahasvan", email = "mahasvan@gmail.com" }
19
+ ]
20
+
21
+ classifiers = [
22
+ "Programming Language :: Python :: 3",
23
+ "Operating System :: OS Independent",
24
+ ]
25
+
26
+ dependencies = [
27
+ "pydantic",
28
+ ]
29
+
30
+ [tool.setuptools.packages.find]
31
+ where = ["src"]
32
+
33
+ [tool.setuptools.package-data]
34
+ "hwprobe" = ["interops/**/dll/*.dll"]
35
+
36
+ [project.urls]
37
+ Homepage = "https://github.com/Mahasvan/HWProbe"
38
+ Issues = "https://github.com/Mahasvan/HWProbe/issues"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,94 @@
1
+ Metadata-Version: 2.4
2
+ Name: HWProbe
3
+ Version: 0.0.1b1
4
+ Summary: A cross-platform system information gatherer
5
+ Author-email: Mahasvan <mahasvan@gmail.com>
6
+ License-Expression: BSD-3-Clause
7
+ Project-URL: Homepage, https://github.com/Mahasvan/HWProbe
8
+ Project-URL: Issues, https://github.com/Mahasvan/HWProbe/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: pydantic
15
+ Dynamic: license-file
16
+
17
+ # HWProbe
18
+
19
+ A Python Library to simplify retrieval of hardware components of your computer.
20
+
21
+ - To get started, read the **[Quickstart](https://mahasvan.github.io/HWProbe/quickstart.html).**
22
+ - Additionally, you can view the **[Documentation](https://mahasvan.github.io/HWProbe/)**.
23
+
24
+ ## Installation
25
+
26
+ ### macOS / Linux
27
+
28
+ ```bash
29
+ pip3 install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ HWProbe
30
+ ```
31
+
32
+ ### Windows
33
+
34
+ ```bash
35
+ pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ HWProbe
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ```python
41
+ from hwprobe import HardwareManager
42
+ import json
43
+
44
+ hm = HardwareManager()
45
+
46
+ data = hm.fetch_hardware_info()
47
+
48
+ # All data returned are Pydantic models and have strict schema
49
+ # You can use it as is, or serialize it to JSON if you wish.
50
+ # We print the data in JSON here for readability.
51
+
52
+ json_data = json.loads(data.model_dump_json())
53
+ print(json.dumps(json_data, indent=2))
54
+ ```
55
+
56
+ ## Tracker
57
+
58
+ ### Hardware Discovery Progress Tracker
59
+
60
+ | Component | Linux | macOS | Windows |
61
+ |-------------|:-----:|:------:|:-------:|
62
+ | CPU | ✅ | ✅ | ✅ |
63
+ | GPU | ✅ | ✅ | ✅ |
64
+ | Memory | ✅ | ✅ | ✅ |
65
+ | Network | ✅ | ✅ | ✅ |
66
+ | Storage | ✅ | ✅ | ✅ |
67
+ | -- | -- | - | - |
68
+ | Display | ❌ | ❌* (2) | ✅* (3) |
69
+ | Audio | ❌ | ❌ | ✅* (3) |
70
+ | Motherboard | ❌ | ❌ | ✅ |
71
+ | Vendor | ❌ | ❌ | ➖ |
72
+ | Input | ❌ | ❌ | ❌ |
73
+
74
+ 1. PCIe gen info only for Nvidia
75
+ 2. In progress
76
+ 3. Need to rewrite C++ bindings
77
+
78
+ ### Miscellaneous Tasks / Problems
79
+
80
+ | Task | Status |
81
+ |--------------------------------------------------------------------------------------------------|:------:|
82
+ | GH actions for compiling `interops/{platform}/*.{c\|cpp}` to their respective output directories | ❌ |
83
+ | Group Pydantic Model fields into essential and optional | ❌ |
84
+ | Remove `pyobjc` dependency in macOS by rewriting dependent code chunks in C++ | ✅ |
85
+ | Autodetection of storage units | ❌ |
86
+
87
+ ### Supporting Features
88
+
89
+ | Feature | Status |
90
+ |------------------------------------------------------------------------------------------------------------------------------|:------:|
91
+ | PCI Lookup — [DeviceHunt](https://devicehunt.com) | ❌ |
92
+ | PCI Lookup — [PCI IDs Repository](https://pci-ids.ucw.cz) ([GitHub](https://github.com/pciutils/pciids/blob/master/pci.ids)) | ❌ |
93
+ | Logging | ✅ |
94
+ | Working Library | ✅ |
@@ -0,0 +1,64 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/HWProbe.egg-info/PKG-INFO
5
+ src/HWProbe.egg-info/SOURCES.txt
6
+ src/HWProbe.egg-info/dependency_links.txt
7
+ src/HWProbe.egg-info/requires.txt
8
+ src/HWProbe.egg-info/top_level.txt
9
+ src/hwprobe/__init__.py
10
+ src/hwprobe/core/common/edid.py
11
+ src/hwprobe/core/linux/__init__.py
12
+ src/hwprobe/core/linux/common.py
13
+ src/hwprobe/core/linux/cpu.py
14
+ src/hwprobe/core/linux/display.py
15
+ src/hwprobe/core/linux/dmi_decode.py
16
+ src/hwprobe/core/linux/graphics.py
17
+ src/hwprobe/core/linux/manager.py
18
+ src/hwprobe/core/linux/memory.py
19
+ src/hwprobe/core/linux/network.py
20
+ src/hwprobe/core/linux/storage.py
21
+ src/hwprobe/core/mac/__init__.py
22
+ src/hwprobe/core/mac/cpu.py
23
+ src/hwprobe/core/mac/display.py
24
+ src/hwprobe/core/mac/graphics.py
25
+ src/hwprobe/core/mac/manager.py
26
+ src/hwprobe/core/mac/memory.py
27
+ src/hwprobe/core/mac/network.py
28
+ src/hwprobe/core/mac/storage.py
29
+ src/hwprobe/core/mac/deprecated/common.py
30
+ src/hwprobe/core/mac/deprecated/ioreg.py
31
+ src/hwprobe/core/windows/__init__.py
32
+ src/hwprobe/core/windows/audio.py
33
+ src/hwprobe/core/windows/baseboard.py
34
+ src/hwprobe/core/windows/common.py
35
+ src/hwprobe/core/windows/cpu.py
36
+ src/hwprobe/core/windows/display.py
37
+ src/hwprobe/core/windows/graphics.py
38
+ src/hwprobe/core/windows/manager.py
39
+ src/hwprobe/core/windows/memory.py
40
+ src/hwprobe/core/windows/network.py
41
+ src/hwprobe/core/windows/storage.py
42
+ src/hwprobe/core/windows/win_enum.py
43
+ src/hwprobe/interops/mac/bindings/gpu_info.py
44
+ src/hwprobe/interops/mac/bindings/storage_info.py
45
+ src/hwprobe/interops/win/bindings/__init__.py
46
+ src/hwprobe/interops/win/bindings/gpu_info.py
47
+ src/hwprobe/interops/win/dll/hw_helper.dll
48
+ src/hwprobe/interops/win/legacy/constants.py
49
+ src/hwprobe/interops/win/legacy/signatures.py
50
+ src/hwprobe/interops/win/legacy/structs.py
51
+ src/hwprobe/models/audio_models.py
52
+ src/hwprobe/models/baseboard_models.py
53
+ src/hwprobe/models/component_model.py
54
+ src/hwprobe/models/cpu_models.py
55
+ src/hwprobe/models/display_models.py
56
+ src/hwprobe/models/gpu_models.py
57
+ src/hwprobe/models/info_models.py
58
+ src/hwprobe/models/memory_models.py
59
+ src/hwprobe/models/network_models.py
60
+ src/hwprobe/models/size_models.py
61
+ src/hwprobe/models/status_models.py
62
+ src/hwprobe/models/storage_models.py
63
+ src/hwprobe/util/location_paths.py
64
+ src/hwprobe/util/nvidia.py
@@ -0,0 +1 @@
1
+ pydantic
@@ -0,0 +1 @@
1
+ hwprobe
@@ -0,0 +1,38 @@
1
+ import os
2
+ import platform
3
+
4
+ __version__ = "0.0.1b1"
5
+ __author__ = "Mahasvan"
6
+ __license__ = "BSD-3-Clause"
7
+
8
+ # Refactor this if we have Linux/OSX interops in future
9
+ # Should be defined in each platform.
10
+ _dll_path = os.path.join(os.path.dirname(__file__), "interops", "win", "dll")
11
+
12
+
13
+ def _detect_platform() -> str:
14
+ """Allow overriding platform selection for tests via env.
15
+
16
+ Set HWPROBE_PLATFORM to one of linux|darwin|windows to force a backend.
17
+ Defaults to the host platform.
18
+ """
19
+ override = os.environ.get("HWPROBE_PLATFORM", "").lower()
20
+ if override in {"linux", "darwin", "windows", "win32", "nt"}:
21
+ return override
22
+ return platform.system().lower()
23
+
24
+
25
+ _platform = _detect_platform()
26
+
27
+ if _platform in {"windows", "win32", "nt"}:
28
+ from hwprobe.core.windows import WindowsHardwareManager as HardwareManager
29
+
30
+ if hasattr(os, "add_dll_directory"):
31
+ os.add_dll_directory(_dll_path)
32
+ elif _platform == "darwin":
33
+ from hwprobe.core.mac import MacHardwareManager as HardwareManager
34
+ else:
35
+ # Default to Linux for unknown/override cases (including tests on macOS)
36
+ from hwprobe.core.linux import LinuxHardwareManager as HardwareManager
37
+
38
+ __all__ = ["HardwareManager"]
@@ -0,0 +1,128 @@
1
+ from hwprobe.models.display_models import DisplayModuleInfo, ResolutionInfo
2
+
3
+ BIT_DEPTH_ENUM = {
4
+ 1: 6,
5
+ 2: 8,
6
+ 3: 10,
7
+ 4: 12,
8
+ 5: 14,
9
+ 6: 16
10
+ }
11
+
12
+ INTERFACE_ENUM = {
13
+ 0: "Undefined",
14
+ 1: "DVI",
15
+ 2: "HDMI", # Standard HDMI-A
16
+ 3: "HDMI (B)",
17
+ 4: "MDDI",
18
+ 5: "DisplayPort"
19
+ }
20
+
21
+ DESCRIPTOR_TAG_ENUM = {
22
+ 0xFF: "Serial Number",
23
+ 0xFE: "Alphanumeric Data String",
24
+ 0xFC: "Display Product Name",
25
+ }
26
+
27
+
28
+ def _get_bits(data: bytes, start_bit: int, end_bit: int) -> int:
29
+ # Get the bit values in an offset, given a bytes object.
30
+
31
+ if start_bit < 0 or end_bit <= start_bit:
32
+ raise ValueError("Invalid bit range")
33
+
34
+ total_bits = len(data) * 8
35
+ if end_bit > total_bits:
36
+ raise ValueError("Bit range exceeds data length")
37
+
38
+ # Convert bytes to integer
39
+ value = int.from_bytes(data, byteorder="big")
40
+
41
+ # Number of bits to extract
42
+ length = end_bit - start_bit
43
+
44
+ # Shift right to drop lower bits, then mask
45
+ shift = total_bits - end_bit
46
+ return (value >> shift) & ((1 << length) - 1)
47
+
48
+
49
+ def parse_edid(edid_data: bytes) -> DisplayModuleInfo:
50
+ # todo: Parse EDID v1.2 and v1.3. This will work for v1.4, but need to verify on the older versions.
51
+ module = DisplayModuleInfo()
52
+
53
+ module.year = edid_data[0x11] + 1990
54
+
55
+ manuf_bits = int.from_bytes(edid_data[0x08:0x0A], byteorder="big")
56
+ char1 = chr(((manuf_bits >> 10) & 0x1F) + 64)
57
+ char2 = chr(((manuf_bits >> 5) & 0x1F) + 64)
58
+ char3 = chr((manuf_bits & 0x1F) + 64)
59
+ manuf_string = char1 + char2 + char3
60
+
61
+ module.manufacturer_code = manuf_string
62
+
63
+ product_code = edid_data[0x0A:0x0C].hex().upper()
64
+
65
+ id_serial_number = "0x" + edid_data[0x0C:0x10].hex().upper()
66
+
67
+ input_type = edid_data[0x14]
68
+ if input_type >> 7 == 1: # MSB is 1 => Digital output
69
+ module.resolution = ResolutionInfo()
70
+
71
+ module.resolution.bit_depth = BIT_DEPTH_ENUM.get(
72
+ _get_bits(input_type.to_bytes(1, byteorder="little"), 1, 4),
73
+ 0)
74
+
75
+ module.interface = INTERFACE_ENUM.get(input_type & 7, "Unknown")
76
+
77
+ else:
78
+ pass
79
+
80
+ resolution = (0, 0, 0) # Width, Height, Refresh Rate
81
+ # We will use this tuple to find the max resolution and refresh rate, and update it in `module.resolution`.
82
+
83
+ for block_start in range(0x36, 0x6d, 18):
84
+ block = edid_data[block_start:block_start + 18]
85
+ zeros = 0x00.to_bytes(1, byteorder='little') * 2
86
+ if block[:2] == zeros:
87
+ tag = block[3]
88
+ if tag in DESCRIPTOR_TAG_ENUM:
89
+ # Refer to DESCRIPTOR_TAG_ENUM for valid block type codes
90
+ if tag == 0xFF:
91
+ # todo: test if this works
92
+ module.serial_number = block[5:].decode("ascii").strip()
93
+ if tag == 0xFC:
94
+ module.name = block[5:].decode("ascii").strip()
95
+
96
+ else:
97
+ if not module.resolution: continue
98
+
99
+ pixel_clock_hz = (block[0] | (block[1] << 8)) * 10_000
100
+
101
+ horiz = ((block[4] & 0xF0) << 4) | block[2]
102
+ vert = ((block[7] & 0xF0) << 4) | block[5]
103
+
104
+ h_blank = ((block[4] & 0x0F) << 8) | block[3]
105
+ v_blank = ((block[7] & 0x0F) << 8) | block[6]
106
+ refresh_rate = pixel_clock_hz / ((horiz + h_blank) * (vert + v_blank))
107
+
108
+ resolution = max(
109
+ resolution,
110
+ (horiz, vert, round(refresh_rate, 2)),
111
+ key=lambda x: (x[0] * x[1], x[2])
112
+ )
113
+
114
+ if resolution != (0, 0, 0):
115
+ if not module.resolution:
116
+ module.resolution = ResolutionInfo()
117
+ module.resolution.width = resolution[0]
118
+ module.resolution.height = resolution[1]
119
+ module.resolution.refresh_rate = resolution[2]
120
+
121
+ # print("\nRaw EDID:")
122
+ # for byte in edid_data:
123
+ # print(f"{byte:02X}", end=" ")
124
+
125
+ return module
126
+
127
+ # todo: parse extension blocks
128
+ # todo: remove logging when verified to work
@@ -0,0 +1,2 @@
1
+ from hwprobe.core.linux.manager import LinuxHardwareManager
2
+
@@ -0,0 +1,52 @@
1
+ # Source: https://github.com/KernelWanderers/OCSysInfo/blob/main/src/util/pci_root.py
2
+
3
+
4
+ def pci_path_linux(device_slot: str):
5
+ """
6
+ :param device_slot: format: <domain>:<bus>:<slot>.<function>
7
+ :return: PCI Path
8
+ """
9
+
10
+ # Construct PCI path
11
+ # E.g: PciRoot(0x0)/Pci(0x2,0x0)
12
+ try:
13
+ domain = int(device_slot.split(":")[0], 16)
14
+ pci_path = f"PciRoot({hex(domain)})"
15
+ except (IndexError, ValueError):
16
+ return None
17
+
18
+ # Collect path components (current device and parents)
19
+ paths = []
20
+
21
+ # Add current device
22
+ current_components = _get_address_components(device_slot)
23
+ if current_components:
24
+ paths.append(",".join(current_components))
25
+
26
+ # Find parent bridges
27
+ # Check if 'slot' is listed in the directory of other devices
28
+ parent_components = _get_address_components(device_slot)
29
+ if parent_components:
30
+ paths.append(",".join(parent_components))
31
+
32
+ # Sort paths and append to pci_path
33
+ # Note: Sorting logic preserved from original code
34
+ for comp in sorted(paths, reverse=True):
35
+ pci_path += f"/Pci({comp})"
36
+
37
+ return pci_path
38
+
39
+
40
+ def _get_address_components(slot_name):
41
+ """
42
+ :param slot_name: format: <domain>:<bus>:<slot>.<function>
43
+ :return: Tuple of address components
44
+ """
45
+ try:
46
+ # slot_name example: 0000:00:1f.3
47
+ # split(":")[-1] -> 1f.3
48
+ # split(".") -> ['1f', '3']
49
+ device_func = slot_name.split(":")[-1]
50
+ return tuple(hex(int(n, 16)) for n in device_func.split("."))
51
+ except (ValueError, IndexError, AttributeError):
52
+ return None