pyhw 0.7.3__tar.gz → 0.8.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. {pyhw-0.7.3/src/pyhw.egg-info → pyhw-0.8.0}/PKG-INFO +12 -5
  2. {pyhw-0.7.3 → pyhw-0.8.0}/README.md +10 -3
  3. {pyhw-0.7.3 → pyhw-0.8.0}/pyproject.toml +2 -2
  4. pyhw-0.8.0/src/pyhw/__init__.py +1 -0
  5. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/__main__.py +2 -2
  6. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/cpu/cpuBase.py +6 -3
  7. pyhw-0.8.0/src/pyhw/backend/cpu/windows.py +48 -0
  8. pyhw-0.8.0/src/pyhw/backend/gpu/gpuBase.py +22 -0
  9. pyhw-0.8.0/src/pyhw/backend/gpu/windows.py +41 -0
  10. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/host/hostBase.py +5 -5
  11. pyhw-0.8.0/src/pyhw/backend/host/hostInfo.py +22 -0
  12. pyhw-0.8.0/src/pyhw/backend/host/windows.py +36 -0
  13. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/kernel/kernelBase.py +3 -2
  14. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/kernel/kernelInfo.py +6 -0
  15. pyhw-0.8.0/src/pyhw/backend/kernel/windows.py +29 -0
  16. pyhw-0.8.0/src/pyhw/backend/memory/memoryBase.py +22 -0
  17. pyhw-0.8.0/src/pyhw/backend/memory/windows.py +36 -0
  18. pyhw-0.8.0/src/pyhw/backend/nic/linux.py +58 -0
  19. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/nic/nicBase.py +8 -4
  20. pyhw-0.7.3/src/pyhw/backend/nic/linux.py → pyhw-0.8.0/src/pyhw/backend/nic/windows.py +5 -2
  21. pyhw-0.8.0/src/pyhw/backend/npu/npuBase.py +22 -0
  22. pyhw-0.8.0/src/pyhw/backend/npu/windows.py +40 -0
  23. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/os/osBase.py +6 -3
  24. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/os/osInfo.py +6 -0
  25. pyhw-0.8.0/src/pyhw/backend/os/windows.py +35 -0
  26. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/shell/shellBase.py +4 -1
  27. pyhw-0.8.0/src/pyhw/backend/shell/shellInfo.py +10 -0
  28. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/shell/unix.py +2 -10
  29. pyhw-0.8.0/src/pyhw/backend/shell/windows.py +29 -0
  30. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/title/titleBase.py +2 -2
  31. pyhw-0.8.0/src/pyhw/backend/title/titleInfo.py +9 -0
  32. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/title/unix.py +2 -9
  33. pyhw-0.8.0/src/pyhw/backend/title/windows.py +17 -0
  34. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/uptime/linux.py +3 -3
  35. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/uptime/macos.py +3 -3
  36. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/uptime/uptimeBase.py +6 -3
  37. pyhw-0.8.0/src/pyhw/backend/uptime/windows.py +49 -0
  38. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/frontend/color/colorConfig.py +52 -0
  39. pyhw-0.8.0/src/pyhw/frontend/logo/ascii/windows_10.pyhw +19 -0
  40. pyhw-0.8.0/src/pyhw/frontend/logo/ascii/windows_11.pyhw +17 -0
  41. pyhw-0.8.0/src/pyhw/frontend/logo/ascii/windows_2025.pyhw +17 -0
  42. pyhw-0.8.0/src/pyhw/frontend/logo/ascii/windows_old.pyhw +16 -0
  43. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/library/lib/iokitGPULib.dylib +0 -0
  44. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/pyhwUtil/pyhwUtil.py +10 -3
  45. {pyhw-0.7.3 → pyhw-0.8.0/src/pyhw.egg-info}/PKG-INFO +12 -5
  46. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw.egg-info/SOURCES.txt +14 -1
  47. pyhw-0.8.0/src/pyhw.egg-info/requires.txt +1 -0
  48. pyhw-0.7.3/src/pyhw/__init__.py +0 -1
  49. pyhw-0.7.3/src/pyhw/backend/gpu/gpuBase.py +0 -18
  50. pyhw-0.7.3/src/pyhw/backend/host/hostInfo.py +0 -13
  51. pyhw-0.7.3/src/pyhw/backend/host/windows.py +0 -5
  52. pyhw-0.7.3/src/pyhw/backend/kernel/windows.py +0 -7
  53. pyhw-0.7.3/src/pyhw/backend/memory/memoryBase.py +0 -18
  54. pyhw-0.7.3/src/pyhw/backend/npu/npuBase.py +0 -20
  55. pyhw-0.7.3/src/pyhw/backend/title/windows.py +0 -8
  56. pyhw-0.7.3/src/pyhw/library/lib/iokitHostLib.dylib +0 -0
  57. pyhw-0.7.3/src/pyhw.egg-info/requires.txt +0 -1
  58. {pyhw-0.7.3 → pyhw-0.8.0}/LICENSE +0 -0
  59. {pyhw-0.7.3 → pyhw-0.8.0}/setup.cfg +0 -0
  60. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/__init__.py +0 -0
  61. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/backendBase.py +0 -0
  62. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/cpu/__init__.py +0 -0
  63. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/cpu/bsd.py +0 -0
  64. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/cpu/cpuInfo.py +0 -0
  65. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/cpu/linux.py +0 -0
  66. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/cpu/macos.py +0 -0
  67. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/gpu/__init__.py +0 -0
  68. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/gpu/bsd.py +0 -0
  69. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/gpu/gpuInfo.py +0 -0
  70. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/gpu/linux.py +0 -0
  71. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/gpu/macos.py +0 -0
  72. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/host/__init__.py +0 -0
  73. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/host/bsd.py +0 -0
  74. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/host/linux.py +0 -0
  75. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/host/macos.py +0 -0
  76. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/kernel/__init__.py +0 -0
  77. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/kernel/unix.py +0 -0
  78. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/memory/__init__.py +0 -0
  79. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/memory/bsd.py +0 -0
  80. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/memory/linux.py +0 -0
  81. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/memory/macos.py +0 -0
  82. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/memory/memoryInfo.py +0 -0
  83. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/metal/t.py +0 -0
  84. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/nic/__init__.py +0 -0
  85. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/nic/bsd.py +0 -0
  86. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/nic/macos.py +0 -0
  87. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/nic/nicInfo.py +0 -0
  88. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/npu/__init__.py +0 -0
  89. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/npu/bsd.py +0 -0
  90. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/npu/linux.py +0 -0
  91. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/npu/macos.py +0 -0
  92. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/npu/npuInfo.py +0 -0
  93. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/os/__init__.py +0 -0
  94. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/os/bsd.py +0 -0
  95. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/os/linux.py +0 -0
  96. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/os/macos.py +0 -0
  97. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/shell/__init__.py +0 -0
  98. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/title/__init__.py +0 -0
  99. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/uptime/__init__.py +0 -0
  100. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/uptime/bsd.py +0 -0
  101. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/backend/uptime/uptimeInfo.py +0 -0
  102. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/frontend/__init__.py +0 -0
  103. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/frontend/color/__init__.py +0 -0
  104. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/frontend/color/colorSet.py +0 -0
  105. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/frontend/color/colorUtil.py +0 -0
  106. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/frontend/frontendBase.py +0 -0
  107. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/frontend/logo/__init__.py +0 -0
  108. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/alpine.pyhw +0 -0
  109. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/arch.pyhw +0 -0
  110. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/armbian.pyhw +0 -0
  111. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/centos.pyhw +0 -0
  112. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/debian.pyhw +0 -0
  113. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/fedora.pyhw +0 -0
  114. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/fedora_small.pyhw +0 -0
  115. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/freebsd.pyhw +0 -0
  116. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/linux.pyhw +0 -0
  117. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/macOS.pyhw +0 -0
  118. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/raspbian.pyhw +0 -0
  119. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/ubuntu.pyhw +0 -0
  120. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/ubuntu_small.pyhw +0 -0
  121. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/frontend/logo/logoBase.py +0 -0
  122. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/pyhwException/__init__.py +0 -0
  123. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/pyhwException/pyhwException.py +0 -0
  124. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/pyhwUtil/__init__.py +0 -0
  125. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw/pyhwUtil/sysctlUtil.py +0 -0
  126. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw.egg-info/dependency_links.txt +0 -0
  127. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw.egg-info/entry_points.txt +0 -0
  128. {pyhw-0.7.3 → pyhw-0.8.0}/src/pyhw.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pyhw
3
- Version: 0.7.3
3
+ Version: 0.8.0
4
4
  Summary: PyHw, a neofetch-like command line tool for fetching system information but written mostly in python.
5
5
  Author-email: Xiao Ran <xiaoran.007@icloud.com>
6
6
  License: BSD-3-Clause
@@ -13,28 +13,30 @@ Classifier: Operating System :: OS Independent
13
13
  Requires-Python: >=3.9
14
14
  Description-Content-Type: text/markdown
15
15
  License-File: LICENSE
16
- Requires-Dist: pypci-ng>=0.0.10
16
+ Requires-Dist: pypci-ng>=0.1.2
17
17
 
18
18
  # PyHw
19
19
  [![Downloads](https://static.pepy.tech/badge/pyhw)](https://pepy.tech/project/pyhw)
20
20
  ![PyPI - Version](https://img.shields.io/pypi/v/pyhw?label=version)
21
+ ![Static Badge](https://img.shields.io/badge/Python-3.9%2B-green)
21
22
 
22
23
  ![Static Badge](https://img.shields.io/badge/macOS-11%2B-green)
23
24
  ![Static Badge](https://img.shields.io/badge/Linux-blue)
24
25
  ![Static Badge](https://img.shields.io/badge/FreeBSD-red)
26
+ ![Static Badge](https://img.shields.io/badge/Windows-yellow)
25
27
 
26
28
  ![Static Badge](https://img.shields.io/badge/amd64-green)
27
29
  ![Static Badge](https://img.shields.io/badge/arm-blue)
28
30
 
29
31
 
30
- PyHw, a neofetch-like command line tool for fetching system information but written mostly in Python. **Currently, this project is still in the initial stage, only Linux, macOS, and FreeBSD are supported.**
32
+ PyHw, a neofetch-like command line tool for fetching system information but written mostly in Python. **Currently, this project is still in the initial stage, only Linux, macOS, FreeBSD and Windows are supported.**
31
33
 
32
34
  This project is a Python reimplementation of [neofetch](https://github.com/dylanaraps/neofetch) and references the [fastfetch](https://github.com/fastfetch-cli/fastfetch) project for logo style settings. Since this project is implemented in Python, it will be easier to maintain and extend than bash and c implementation. Also, this project only relies on the Python standard library, so you can run it on any device that has a Python environment (I hope so 🤔).
33
35
 
34
36
 
35
37
  [//]: # (![demo]&#40;https://i2.imgs.ovh/d/BQACAgUAAx0EUvSR8wACMvpmyFVohzKxLcUdLiJaEa3wlo_OrQACuw4AAoX-QVaSpG0-rTAeRTUE&#41;)
36
- ![demo](https://files.catbox.moe/xx58xy.jpg)
37
-
38
+ [//]: # (![demo]&#40;https://files.catbox.moe/xx58xy.jpg&#41;)
39
+ ![demo](https://files.catbox.moe/2d21fu.jpg)
38
40
 
39
41
 
40
42
 
@@ -96,7 +98,12 @@ This is due to the fact that system python is not supposed to be managed by pip.
96
98
  * macOS arm64, x86_64
97
99
  * Linux arm64, x86_64
98
100
  * FreeBSD arm64
101
+ * Windows 10 X86_64
99
102
 
103
+ ## Add Logo
104
+ 1. Create a file named **\<os>.pyhw** in **logo/ascii** folder
105
+ 2. Modify **colorConfig.py** file to add a new logo style
106
+ 3. Update **pyhwUtil.py** to enable new logo style.
100
107
 
101
108
  ## Build from source
102
109
  Currently, build process relay on swiftc and macOS IOKit framework. To build package from source, you need a Mac machine with macOS 11 and newer.
@@ -1,23 +1,25 @@
1
1
  # PyHw
2
2
  [![Downloads](https://static.pepy.tech/badge/pyhw)](https://pepy.tech/project/pyhw)
3
3
  ![PyPI - Version](https://img.shields.io/pypi/v/pyhw?label=version)
4
+ ![Static Badge](https://img.shields.io/badge/Python-3.9%2B-green)
4
5
 
5
6
  ![Static Badge](https://img.shields.io/badge/macOS-11%2B-green)
6
7
  ![Static Badge](https://img.shields.io/badge/Linux-blue)
7
8
  ![Static Badge](https://img.shields.io/badge/FreeBSD-red)
9
+ ![Static Badge](https://img.shields.io/badge/Windows-yellow)
8
10
 
9
11
  ![Static Badge](https://img.shields.io/badge/amd64-green)
10
12
  ![Static Badge](https://img.shields.io/badge/arm-blue)
11
13
 
12
14
 
13
- PyHw, a neofetch-like command line tool for fetching system information but written mostly in Python. **Currently, this project is still in the initial stage, only Linux, macOS, and FreeBSD are supported.**
15
+ PyHw, a neofetch-like command line tool for fetching system information but written mostly in Python. **Currently, this project is still in the initial stage, only Linux, macOS, FreeBSD and Windows are supported.**
14
16
 
15
17
  This project is a Python reimplementation of [neofetch](https://github.com/dylanaraps/neofetch) and references the [fastfetch](https://github.com/fastfetch-cli/fastfetch) project for logo style settings. Since this project is implemented in Python, it will be easier to maintain and extend than bash and c implementation. Also, this project only relies on the Python standard library, so you can run it on any device that has a Python environment (I hope so 🤔).
16
18
 
17
19
 
18
20
  [//]: # (![demo]&#40;https://i2.imgs.ovh/d/BQACAgUAAx0EUvSR8wACMvpmyFVohzKxLcUdLiJaEa3wlo_OrQACuw4AAoX-QVaSpG0-rTAeRTUE&#41;)
19
- ![demo](https://files.catbox.moe/xx58xy.jpg)
20
-
21
+ [//]: # (![demo]&#40;https://files.catbox.moe/xx58xy.jpg&#41;)
22
+ ![demo](https://files.catbox.moe/2d21fu.jpg)
21
23
 
22
24
 
23
25
 
@@ -79,7 +81,12 @@ This is due to the fact that system python is not supposed to be managed by pip.
79
81
  * macOS arm64, x86_64
80
82
  * Linux arm64, x86_64
81
83
  * FreeBSD arm64
84
+ * Windows 10 X86_64
82
85
 
86
+ ## Add Logo
87
+ 1. Create a file named **\<os>.pyhw** in **logo/ascii** folder
88
+ 2. Modify **colorConfig.py** file to add a new logo style
89
+ 3. Update **pyhwUtil.py** to enable new logo style.
83
90
 
84
91
  ## Build from source
85
92
  Currently, build process relay on swiftc and macOS IOKit framework. To build package from source, you need a Mac machine with macOS 11 and newer.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pyhw"
7
- version = "0.7.3"
7
+ version = "0.8.0"
8
8
  description = "PyHw, a neofetch-like command line tool for fetching system information but written mostly in python."
9
9
  keywords = ["neofetch", "system information", "command line tool", "python", "hardware information", "fastfetch", "fetching"]
10
10
  authors = [
@@ -14,7 +14,7 @@ readme = "README.md"
14
14
  license = {text = "BSD-3-Clause"}
15
15
  requires-python = ">=3.9"
16
16
  dependencies = [
17
- "pypci-ng>=0.0.10"
17
+ "pypci-ng>=0.1.2"
18
18
  ]
19
19
  classifiers = [
20
20
  "Development Status :: 4 - Beta",
@@ -0,0 +1 @@
1
+ __version__ = '0.8.0'
@@ -17,8 +17,8 @@ from .pyhwUtil import getOS, selectOSLogo
17
17
 
18
18
  def main():
19
19
  current_os = getOS()
20
- if current_os not in ["linux", "macos", "freebsd"]:
21
- print(f"Only Linux, macOS, and FreeBSD is supported for now. Current os: {current_os}")
20
+ if current_os not in ["linux", "macos", "freebsd", "windows"]:
21
+ print(f"Only Linux, macOS, FreeBSD and Windows are supported for now. Current OS: {current_os}")
22
22
  return
23
23
  data = Data()
24
24
  data.title = TitleDetect(os=current_os).getTitle().title
@@ -1,6 +1,3 @@
1
- from .linux import CPUDetectLinux
2
- from .macos import CPUDetectMacOS
3
- from .bsd import CPUDetectBSD
4
1
  from ...pyhwException import OSUnsupportedException
5
2
 
6
3
 
@@ -10,10 +7,16 @@ class CPUDetect:
10
7
 
11
8
  def getCPUInfo(self):
12
9
  if self.OS == "linux":
10
+ from .linux import CPUDetectLinux
13
11
  return CPUDetectLinux().getCPUInfo()
14
12
  elif self.OS == "macos":
13
+ from .macos import CPUDetectMacOS
15
14
  return CPUDetectMacOS().getCPUInfo()
16
15
  elif self.OS == "freebsd":
16
+ from .bsd import CPUDetectBSD
17
17
  return CPUDetectBSD().getCPUInfo()
18
+ elif self.OS == "windows":
19
+ from .windows import CPUDetectWindows
20
+ return CPUDetectWindows().getCPUInfo()
18
21
  else:
19
22
  raise OSUnsupportedException("Unsupported operating system")
@@ -0,0 +1,48 @@
1
+ import re
2
+ import os
3
+ import subprocess
4
+ from .cpuInfo import CPUInfo
5
+ import json
6
+
7
+
8
+ class CPUDetectWindows:
9
+ def __init__(self):
10
+ self.__cpuInfo = CPUInfo()
11
+
12
+ def getCPUInfo(self):
13
+ self.__getCPUInfo()
14
+ self.__modelClean()
15
+ if self.__cpuInfo.model == "":
16
+ self.__cpuInfo.model = "Unknown"
17
+ if self.__cpuInfo.model != "":
18
+ self.__cpuInfo.cpu = self.__cpuInfo.model
19
+ if self.__cpuInfo.cores != "":
20
+ self.__cpuInfo.cpu += f" ({self.__cpuInfo.cores})"
21
+ if self.__cpuInfo.frequency != "":
22
+ self.__cpuInfo.cpu += f" @ {self.__cpuInfo.frequency}"
23
+ return self.__cpuInfo
24
+
25
+ def __getCPUInfo(self):
26
+ COMMAND = "Get-CimInstance -ClassName Win32_Processor | Select-Object Name,NumberOfLogicalProcessors,MaxClockSpeed | ConvertTo-JSON"
27
+
28
+ try:
29
+ result = subprocess.run(["powershell", "-NoProfile", "-Command", COMMAND], capture_output=True, text=True)
30
+ except subprocess.SubprocessError:
31
+ exit(-1)
32
+
33
+ res = json.loads(result.stdout)
34
+ name = res["Name"]
35
+ cores = res["NumberOfLogicalProcessors"]
36
+ frequency = round(int(res["MaxClockSpeed"]) / 1000.0, 2) # GHz
37
+ if "@" in name:
38
+ self.__cpuInfo.model = name.split("@")[0].strip()
39
+ else:
40
+ self.__cpuInfo.model = name
41
+ self.__cpuInfo.cores = str(cores)
42
+ self.__cpuInfo.frequency = f"{frequency:.2f} GHz"
43
+
44
+ def __modelClean(self):
45
+ self.__cpuInfo.model = self.__cpuInfo.model.replace("(R)", "")
46
+ self.__cpuInfo.model = self.__cpuInfo.model.replace("(TM)", "")
47
+ self.__cpuInfo.model = self.__cpuInfo.model.replace("CPU ", "")
48
+
@@ -0,0 +1,22 @@
1
+ from ...pyhwException import OSUnsupportedException
2
+
3
+
4
+ class GPUDetect:
5
+ def __init__(self, os):
6
+ self.OS = os
7
+
8
+ def getGPUInfo(self):
9
+ if self.OS == "linux":
10
+ from .linux import GPUDetectLinux
11
+ return GPUDetectLinux().getGPUInfo()
12
+ elif self.OS == "macos":
13
+ from .macos import GPUDetectMacOS
14
+ return GPUDetectMacOS().getGPUInfo()
15
+ elif self.OS == "freebsd":
16
+ from .bsd import GPUDetectBSD
17
+ return GPUDetectBSD().getGPUInfo()
18
+ elif self.OS == "windows":
19
+ from .windows import GPUDetectWindows
20
+ return GPUDetectWindows().getGPUInfo()
21
+ else:
22
+ raise OSUnsupportedException("Unsupported operating system")
@@ -0,0 +1,41 @@
1
+ import subprocess
2
+ from .gpuInfo import GPUInfo
3
+ from ..cpu import CPUDetect
4
+ from ...pyhwUtil import getArch
5
+ import pypci
6
+
7
+
8
+ class GPUDetectWindows:
9
+ def __init__(self):
10
+ self.__gpuInfo = GPUInfo()
11
+
12
+ def getGPUInfo(self):
13
+ self.__getGPUInfo()
14
+ self.__sortGPUList()
15
+ return self.__gpuInfo
16
+
17
+ def __getGPUInfo(self):
18
+ gpu_devices = pypci.PCI().FindAllVGA()
19
+ if len(gpu_devices) == 0:
20
+ self.__handleNonePciDevices()
21
+ else:
22
+ for device in gpu_devices:
23
+ if device.subsystem_device_name != "":
24
+ device_name = f"{device.vendor_name} {device.device_name} ({device.subsystem_device_name})"
25
+ else:
26
+ device_name = f"{device.vendor_name} {device.device_name}"
27
+ self.__gpuInfo.gpus.append(self.__gpuNameClean(device_name))
28
+ self.__gpuInfo.number += 1
29
+
30
+ def __handleNonePciDevices(self):
31
+ self.__gpuInfo.gpus.append("Not found")
32
+ self.__gpuInfo.number = 1
33
+
34
+ @staticmethod
35
+ def __gpuNameClean(gpu_name: str):
36
+ gpu_name_clean = gpu_name.replace("Corporation ", "")
37
+ return gpu_name_clean
38
+
39
+ def __sortGPUList(self):
40
+ self.__gpuInfo.gpus.sort()
41
+
@@ -1,7 +1,3 @@
1
- from .linux import HostDetectLinux
2
- from .macos import HostDetectMacOS
3
- from .windows import HostDetectWindows
4
- from .bsd import HostDetectBSD
5
1
  from ...pyhwException import OSUnsupportedException
6
2
 
7
3
 
@@ -11,12 +7,16 @@ class HostDetect:
11
7
 
12
8
  def getHostInfo(self):
13
9
  if self.OS == "linux":
10
+ from .linux import HostDetectLinux
14
11
  return HostDetectLinux().getHostInfo()
15
12
  elif self.OS == "macos":
13
+ from .macos import HostDetectMacOS
16
14
  return HostDetectMacOS().getHostInfo()
17
15
  elif self.OS == "freebsd":
16
+ from .bsd import HostDetectBSD
18
17
  return HostDetectBSD().getHostInfo()
19
18
  elif self.OS == "windows":
20
- pass
19
+ from .windows import HostDetectWindows
20
+ return HostDetectWindows().getHostInfo()
21
21
  else:
22
22
  raise OSUnsupportedException("Unsupported operating system")
@@ -0,0 +1,22 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass
5
+ class HostInfo:
6
+ """
7
+ HostInfo class to store host information.
8
+ """
9
+ def __init__(self):
10
+ """
11
+ Initialize HostInfo class, model attribute is required.
12
+ """
13
+ self.os = ""
14
+ self.model = ""
15
+ self.family = ""
16
+ self.name = ""
17
+ self.version = ""
18
+ self.sku = ""
19
+ self.serial = ""
20
+ self.uuid = ""
21
+ self.vendor = ""
22
+
@@ -0,0 +1,36 @@
1
+ """
2
+ In dev.
3
+ """
4
+ from ...pyhwUtil import getArch
5
+ from ...pyhwException import BackendException
6
+ from .hostInfo import HostInfo
7
+ import winreg
8
+
9
+
10
+ class HostDetectWindows:
11
+ def __init__(self):
12
+ self._hostInfo = HostInfo()
13
+ self._arch = getArch()
14
+
15
+ def getHostInfo(self):
16
+ self._getModel()
17
+ return self._hostInfo
18
+
19
+ def _getModel(self):
20
+ try:
21
+ key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"HARDWARE\DESCRIPTION\System\BIOS")
22
+ manufacturer, _ = winreg.QueryValueEx(key, "SystemManufacturer")
23
+ name, _ = winreg.QueryValueEx(key, "SystemProductName")
24
+ version, _ = winreg.QueryValueEx(key, "SystemVersion")
25
+ winreg.CloseKey(key)
26
+ except FileNotFoundError:
27
+ raise BackendException("Unable to retrieve system information.")
28
+ self._hostInfo.name = name
29
+ self._hostInfo.version = version
30
+ self._hostInfo.vendor = manufacturer
31
+ self.__handleVM()
32
+ self._hostInfo.model = self._hostInfo.name + " " + self._hostInfo.version
33
+
34
+ def __handleVM(self):
35
+ if self._hostInfo.name.startswith("VMware"):
36
+ self._hostInfo.version = ""
@@ -1,4 +1,3 @@
1
- from .unix import KernelDetectUnix
2
1
  from ...pyhwException import OSUnsupportedException
3
2
 
4
3
 
@@ -8,8 +7,10 @@ class KernelDetect:
8
7
 
9
8
  def getKernelInfo(self):
10
9
  if self.OS in ["linux", "macos", "freebsd"]:
10
+ from .unix import KernelDetectUnix
11
11
  return KernelDetectUnix().getKernelInfo()
12
12
  elif self.OS == "windows":
13
- raise OSUnsupportedException("Unsupported operating system")
13
+ from .windows import KernelDetectWindows
14
+ return KernelDetectWindows().getKernelInfo()
14
15
  else:
15
16
  raise OSUnsupportedException("Unsupported operating system")
@@ -3,7 +3,13 @@ from dataclasses import dataclass
3
3
 
4
4
  @dataclass
5
5
  class KernelInfo:
6
+ """
7
+ Data class for storing kernel information.
8
+ """
6
9
  def __init__(self):
10
+ """
11
+ Initialize the data class, kernel attribute is required.
12
+ """
7
13
  self.name = ""
8
14
  self.version = ""
9
15
  self.machine = ""
@@ -0,0 +1,29 @@
1
+ """
2
+ In dev.
3
+ """
4
+ from .kernelInfo import KernelInfo
5
+ from ...pyhwException import BackendException
6
+ import platform
7
+ import winreg
8
+
9
+
10
+ class KernelDetectWindows:
11
+ def __init__(self):
12
+ self.__kernelInfo = KernelInfo()
13
+
14
+ def getKernelInfo(self):
15
+ version = platform.version()
16
+ machine = platform.machine()
17
+ display = self.__get_windows_version()
18
+ self.__kernelInfo.kernel = f"{version} ({display}) {machine}"
19
+ return self.__kernelInfo
20
+
21
+ @staticmethod
22
+ def __get_windows_version():
23
+ try:
24
+ key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows NT\CurrentVersion")
25
+ display_version, _ = winreg.QueryValueEx(key, "DisplayVersion")
26
+ winreg.CloseKey(key)
27
+ return str(display_version)
28
+ except:
29
+ raise BackendException("Unable to determine Windows kernel version.")
@@ -0,0 +1,22 @@
1
+ from ...pyhwException import OSUnsupportedException
2
+
3
+
4
+ class MemoryDetect:
5
+ def __init__(self, os):
6
+ self.OS = os
7
+
8
+ def getMemoryInfo(self):
9
+ if self.OS == "linux":
10
+ from .linux import MemoryDetectLinux
11
+ return MemoryDetectLinux().getMemoryInfo()
12
+ elif self.OS == "macos":
13
+ from .macos import MemoryDetectMacOS
14
+ return MemoryDetectMacOS().getMemoryInfo()
15
+ elif self.OS == "freebsd":
16
+ from .bsd import MemoryDetectBSD
17
+ return MemoryDetectBSD().getMemoryInfo()
18
+ elif self.OS == "windows":
19
+ from .windows import MemoryDetectWindows
20
+ return MemoryDetectWindows().getMemoryInfo()
21
+ else:
22
+ raise OSUnsupportedException("Unsupported operating system")
@@ -0,0 +1,36 @@
1
+ from ...pyhwException import BackendException
2
+ from .memoryInfo import MemoryInfo
3
+ import subprocess
4
+ import json
5
+
6
+
7
+ class MemoryDetectWindows:
8
+ def __init__(self):
9
+ self._memoryInfo = MemoryInfo()
10
+
11
+ def getMemoryInfo(self):
12
+ self._getMemory()
13
+ self._memoryInfo.memory = f"{self._memoryInfo.used} MiB / {self._memoryInfo.total} MiB"
14
+ return self._memoryInfo
15
+
16
+ def _getMemory(self):
17
+ COMMAND = 'Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object FreePhysicalMemory,TotalVisibleMemorySize | ConvertTo-JSON'
18
+ try:
19
+ result = subprocess.run(["powershell", "-NoProfile", "-Command", COMMAND], capture_output=True, text=True)
20
+ except subprocess.SubprocessError:
21
+ raise BackendException("Failed to get memory information on Windows.")
22
+
23
+ res = json.loads(result.stdout)
24
+ free_memory = int(res['FreePhysicalMemory']) / 1024
25
+ total_memory = int(res['TotalVisibleMemorySize']) / 1024
26
+ used_memory = total_memory - free_memory
27
+ self._memoryInfo.total = round(total_memory, 2)
28
+ self._memoryInfo.available = round(free_memory, 2)
29
+ self._memoryInfo.used = round(used_memory, 2)
30
+
31
+
32
+
33
+
34
+
35
+
36
+
@@ -0,0 +1,58 @@
1
+ import subprocess
2
+ from .nicInfo import NICInfo
3
+ from ...pyhwUtil import getArch
4
+ from ...pyhwException import BackendException
5
+ import pypci
6
+ import os
7
+
8
+
9
+ class NICDetectLinux:
10
+ def __init__(self):
11
+ self._nicInfo = NICInfo()
12
+
13
+ def getNICInfo(self):
14
+ self._getNICInfo()
15
+ self._sortNICList()
16
+ return self._nicInfo
17
+
18
+ def _getNICInfo(self):
19
+ nic_devices = pypci.PCI().FindAllNIC()
20
+ if len(nic_devices) == 0:
21
+ self.__handleNonePciDevices()
22
+ else:
23
+ for device in nic_devices:
24
+ if device.subsystem_device_name != "":
25
+ device_name = f"{device.vendor_name} {device.device_name} ({device.subsystem_device_name})"
26
+ else:
27
+ device_name = f"{device.vendor_name} {device.device_name}"
28
+ self._nicInfo.nics.append(self._nicNameClean(device_name))
29
+ self._nicInfo.number += 1
30
+
31
+ def __handleNonePciDevices(self):
32
+ # need to update
33
+ interfaces = list()
34
+ for i in os.listdir('/sys/class/net/'):
35
+ if i == "lo":
36
+ continue
37
+ interfaces.append(i)
38
+ if len(interfaces) > 0:
39
+ for interface in interfaces:
40
+ try:
41
+ if_ip = subprocess.run(["bash", "-c", f"ip -4 addr show {interface} | grep inet | awk '{{print $2}}'"], capture_output=True, text=True).stdout.strip().split("/")[0]
42
+ self._nicInfo.nics.append(f"{interface} @ {if_ip}")
43
+ self._nicInfo.number += 1
44
+ except:
45
+ pass
46
+ else:
47
+ pass
48
+ if self._nicInfo.number == 0:
49
+ self._nicInfo.nics.append("Not found")
50
+ self._nicInfo.number = 1
51
+
52
+ @staticmethod
53
+ def _nicNameClean(nic_name: str):
54
+ nic_name_clean = nic_name.replace("Corporation ", "")
55
+ return nic_name_clean
56
+
57
+ def _sortNICList(self):
58
+ return self._nicInfo.nics.sort()
@@ -1,6 +1,4 @@
1
- from .linux import NICDetectLinux
2
- from .macos import NICDetectMacOS
3
- from .bsd import NICDetectBSD
1
+ from ...pyhwException import OSUnsupportedException
4
2
 
5
3
 
6
4
  class NICDetect:
@@ -16,10 +14,16 @@ class NICDetect:
16
14
  :return: dataclass NICInfo, direct attr: nics
17
15
  """
18
16
  if self.OS == "linux":
17
+ from .linux import NICDetectLinux
19
18
  return NICDetectLinux().getNICInfo()
20
19
  elif self.OS == "macos":
20
+ from .macos import NICDetectMacOS
21
21
  return NICDetectMacOS().getNICInfo()
22
22
  elif self.OS == "freebsd":
23
+ from .bsd import NICDetectBSD
23
24
  return NICDetectBSD().getNICInfo()
25
+ elif self.OS == "windows":
26
+ from .windows import NICDetectWindows
27
+ return NICDetectWindows().getNICInfo()
24
28
  else:
25
- raise NotImplementedError("Unsupported operating system")
29
+ raise OSUnsupportedException("Unsupported operating system")
@@ -3,9 +3,10 @@ from .nicInfo import NICInfo
3
3
  from ...pyhwUtil import getArch
4
4
  from ...pyhwException import BackendException
5
5
  import pypci
6
+ import os
6
7
 
7
8
 
8
- class NICDetectLinux:
9
+ class NICDetectWindows:
9
10
  def __init__(self):
10
11
  self._nicInfo = NICInfo()
11
12
 
@@ -28,7 +29,7 @@ class NICDetectLinux:
28
29
  self._nicInfo.number += 1
29
30
 
30
31
  def __handleNonePciDevices(self):
31
- # placeholder for a more advanced method.
32
+ # need to update
32
33
  self._nicInfo.nics.append("Not found")
33
34
  self._nicInfo.number = 1
34
35
 
@@ -39,3 +40,5 @@ class NICDetectLinux:
39
40
 
40
41
  def _sortNICList(self):
41
42
  return self._nicInfo.nics.sort()
43
+
44
+
@@ -0,0 +1,22 @@
1
+ from ...pyhwException import OSUnsupportedException
2
+
3
+
4
+ class NPUDetect:
5
+ def __init__(self, os):
6
+ self.OS = os
7
+
8
+ def getNPUInfo(self):
9
+ if self.OS == "linux":
10
+ from .linux import NPUDetectLinux
11
+ return NPUDetectLinux().getNPUInfo()
12
+ elif self.OS == "macos":
13
+ from .macos import NPUDetectMacOS
14
+ return NPUDetectMacOS().getNPUInfo()
15
+ elif self.OS == "freebsd":
16
+ from .bsd import NPUDetectBSD
17
+ return NPUDetectBSD().getNPUInfo()
18
+ elif self.OS == "windows":
19
+ from .windows import NPUDetectWindows
20
+ return NPUDetectWindows().getNPUInfo()
21
+ else:
22
+ raise OSUnsupportedException("Unsupported operating system")
@@ -0,0 +1,40 @@
1
+ from .npuInfo import NPUInfo
2
+ import pypci
3
+
4
+
5
+ class NPUDetectWindows:
6
+ def __init__(self):
7
+ self._npuInfo = NPUInfo()
8
+
9
+ def getNPUInfo(self):
10
+ self._getNPUInfo()
11
+ self._sortNPUList()
12
+ return self._npuInfo
13
+
14
+ def _getNPUInfo(self):
15
+ npu_devices = pypci.PCI().FindAllNPU()
16
+ if len(npu_devices) == 0:
17
+ self._handleNonePciDevices()
18
+ else:
19
+ for device in npu_devices:
20
+ if device.subsystem_device_name != "":
21
+ device_name = f"{device.vendor_name} {device.device_name} ({device.subsystem_device_name})"
22
+ else:
23
+ device_name = f"{device.vendor_name} {device.device_name}"
24
+ self._npuInfo.npus.append(self._npuNameClean(device_name))
25
+ self._npuInfo.number += 1
26
+
27
+ def _handleNonePciDevices(self):
28
+ # Place Holder for unknown NPU
29
+ self._npuInfo.number = 1
30
+ self._npuInfo.npus.append("Not found")
31
+
32
+ @staticmethod
33
+ def _npuNameClean(npu_name: str):
34
+ npu_name_clean = npu_name.replace("Corporation ", "")
35
+ return npu_name_clean
36
+
37
+ def _sortNPUList(self):
38
+ self._npuInfo.npus.sort()
39
+
40
+