pyhw 0.7.4__tar.gz → 0.9.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. {pyhw-0.7.4/src/pyhw.egg-info → pyhw-0.9.0}/PKG-INFO +8 -4
  2. {pyhw-0.7.4 → pyhw-0.9.0}/README.md +6 -2
  3. {pyhw-0.7.4 → pyhw-0.9.0}/pyproject.toml +2 -2
  4. pyhw-0.9.0/src/pyhw/__init__.py +1 -0
  5. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/__main__.py +2 -2
  6. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/cpu/cpuBase.py +6 -3
  7. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/cpu/linux.py +3 -0
  8. pyhw-0.9.0/src/pyhw/backend/cpu/windows.py +48 -0
  9. pyhw-0.9.0/src/pyhw/backend/gpu/gpuBase.py +22 -0
  10. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/gpu/linux.py +1 -1
  11. pyhw-0.9.0/src/pyhw/backend/gpu/windows.py +41 -0
  12. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/host/hostBase.py +5 -5
  13. pyhw-0.9.0/src/pyhw/backend/host/hostInfo.py +22 -0
  14. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/host/linux.py +1 -1
  15. pyhw-0.9.0/src/pyhw/backend/host/windows.py +36 -0
  16. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/kernel/kernelBase.py +3 -2
  17. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/kernel/kernelInfo.py +6 -0
  18. pyhw-0.9.0/src/pyhw/backend/kernel/windows.py +38 -0
  19. pyhw-0.9.0/src/pyhw/backend/memory/memoryBase.py +22 -0
  20. pyhw-0.9.0/src/pyhw/backend/memory/windows.py +36 -0
  21. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/nic/linux.py +2 -0
  22. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/nic/nicBase.py +8 -4
  23. pyhw-0.9.0/src/pyhw/backend/nic/windows.py +44 -0
  24. pyhw-0.9.0/src/pyhw/backend/npu/linux.py +54 -0
  25. pyhw-0.9.0/src/pyhw/backend/npu/npuBase.py +22 -0
  26. pyhw-0.7.4/src/pyhw/backend/npu/linux.py → pyhw-0.9.0/src/pyhw/backend/npu/windows.py +3 -1
  27. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/os/osBase.py +6 -3
  28. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/os/osInfo.py +6 -0
  29. pyhw-0.9.0/src/pyhw/backend/os/windows.py +43 -0
  30. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/shell/shellBase.py +4 -1
  31. pyhw-0.9.0/src/pyhw/backend/shell/shellInfo.py +10 -0
  32. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/shell/unix.py +2 -10
  33. pyhw-0.9.0/src/pyhw/backend/shell/windows.py +29 -0
  34. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/title/titleBase.py +2 -2
  35. pyhw-0.9.0/src/pyhw/backend/title/titleInfo.py +9 -0
  36. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/title/unix.py +2 -9
  37. pyhw-0.9.0/src/pyhw/backend/title/windows.py +17 -0
  38. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/uptime/linux.py +3 -3
  39. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/uptime/macos.py +3 -3
  40. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/uptime/uptimeBase.py +6 -3
  41. pyhw-0.9.0/src/pyhw/backend/uptime/windows.py +49 -0
  42. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/frontend/color/colorConfig.py +52 -0
  43. pyhw-0.9.0/src/pyhw/frontend/logo/ascii/windows_10.pyhw +19 -0
  44. pyhw-0.9.0/src/pyhw/frontend/logo/ascii/windows_11.pyhw +17 -0
  45. pyhw-0.9.0/src/pyhw/frontend/logo/ascii/windows_2025.pyhw +17 -0
  46. pyhw-0.9.0/src/pyhw/frontend/logo/ascii/windows_old.pyhw +16 -0
  47. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/pyhwUtil/pyhwUtil.py +13 -4
  48. {pyhw-0.7.4 → pyhw-0.9.0/src/pyhw.egg-info}/PKG-INFO +8 -4
  49. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw.egg-info/SOURCES.txt +14 -0
  50. pyhw-0.9.0/src/pyhw.egg-info/requires.txt +1 -0
  51. pyhw-0.7.4/src/pyhw/__init__.py +0 -1
  52. pyhw-0.7.4/src/pyhw/backend/gpu/gpuBase.py +0 -18
  53. pyhw-0.7.4/src/pyhw/backend/host/hostInfo.py +0 -13
  54. pyhw-0.7.4/src/pyhw/backend/host/windows.py +0 -5
  55. pyhw-0.7.4/src/pyhw/backend/kernel/windows.py +0 -7
  56. pyhw-0.7.4/src/pyhw/backend/memory/memoryBase.py +0 -18
  57. pyhw-0.7.4/src/pyhw/backend/npu/npuBase.py +0 -20
  58. pyhw-0.7.4/src/pyhw/backend/title/windows.py +0 -8
  59. pyhw-0.7.4/src/pyhw.egg-info/requires.txt +0 -1
  60. {pyhw-0.7.4 → pyhw-0.9.0}/LICENSE +0 -0
  61. {pyhw-0.7.4 → pyhw-0.9.0}/setup.cfg +0 -0
  62. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/__init__.py +0 -0
  63. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/backendBase.py +0 -0
  64. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/cpu/__init__.py +0 -0
  65. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/cpu/bsd.py +0 -0
  66. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/cpu/cpuInfo.py +0 -0
  67. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/cpu/macos.py +0 -0
  68. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/gpu/__init__.py +0 -0
  69. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/gpu/bsd.py +0 -0
  70. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/gpu/gpuInfo.py +0 -0
  71. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/gpu/macos.py +0 -0
  72. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/host/__init__.py +0 -0
  73. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/host/bsd.py +0 -0
  74. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/host/macos.py +0 -0
  75. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/kernel/__init__.py +0 -0
  76. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/kernel/unix.py +0 -0
  77. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/memory/__init__.py +0 -0
  78. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/memory/bsd.py +0 -0
  79. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/memory/linux.py +0 -0
  80. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/memory/macos.py +0 -0
  81. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/memory/memoryInfo.py +0 -0
  82. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/metal/t.py +0 -0
  83. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/nic/__init__.py +0 -0
  84. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/nic/bsd.py +0 -0
  85. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/nic/macos.py +0 -0
  86. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/nic/nicInfo.py +0 -0
  87. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/npu/__init__.py +0 -0
  88. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/npu/bsd.py +0 -0
  89. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/npu/macos.py +0 -0
  90. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/npu/npuInfo.py +0 -0
  91. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/os/__init__.py +0 -0
  92. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/os/bsd.py +0 -0
  93. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/os/linux.py +0 -0
  94. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/os/macos.py +0 -0
  95. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/shell/__init__.py +0 -0
  96. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/title/__init__.py +0 -0
  97. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/uptime/__init__.py +0 -0
  98. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/uptime/bsd.py +0 -0
  99. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/backend/uptime/uptimeInfo.py +0 -0
  100. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/frontend/__init__.py +0 -0
  101. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/frontend/color/__init__.py +0 -0
  102. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/frontend/color/colorSet.py +0 -0
  103. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/frontend/color/colorUtil.py +0 -0
  104. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/frontend/frontendBase.py +0 -0
  105. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/frontend/logo/__init__.py +0 -0
  106. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/frontend/logo/ascii/alpine.pyhw +0 -0
  107. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/frontend/logo/ascii/arch.pyhw +0 -0
  108. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/frontend/logo/ascii/armbian.pyhw +0 -0
  109. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/frontend/logo/ascii/centos.pyhw +0 -0
  110. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/frontend/logo/ascii/debian.pyhw +0 -0
  111. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/frontend/logo/ascii/fedora.pyhw +0 -0
  112. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/frontend/logo/ascii/fedora_small.pyhw +0 -0
  113. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/frontend/logo/ascii/freebsd.pyhw +0 -0
  114. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/frontend/logo/ascii/linux.pyhw +0 -0
  115. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/frontend/logo/ascii/macOS.pyhw +0 -0
  116. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/frontend/logo/ascii/raspbian.pyhw +0 -0
  117. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/frontend/logo/ascii/ubuntu.pyhw +0 -0
  118. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/frontend/logo/ascii/ubuntu_small.pyhw +0 -0
  119. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/frontend/logo/logoBase.py +0 -0
  120. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/library/lib/iokitGPULib.dylib +0 -0
  121. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/pyhwException/__init__.py +0 -0
  122. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/pyhwException/pyhwException.py +0 -0
  123. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/pyhwUtil/__init__.py +0 -0
  124. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw/pyhwUtil/sysctlUtil.py +0 -0
  125. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw.egg-info/dependency_links.txt +0 -0
  126. {pyhw-0.7.4 → pyhw-0.9.0}/src/pyhw.egg-info/entry_points.txt +0 -0
  127. {pyhw-0.7.4 → pyhw-0.9.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.4
3
+ Version: 0.9.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,21 +13,24 @@ 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)
30
+ ![Static Badge](https://img.shields.io/badge/riscv64-%238A2BE2)
28
31
 
29
32
 
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.**
33
+ 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
34
 
32
35
  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
36
 
@@ -94,8 +97,9 @@ This is due to the fact that system python is not supposed to be managed by pip.
94
97
 
95
98
  ## Tested OS
96
99
  * macOS arm64, x86_64
97
- * Linux arm64, x86_64
100
+ * Linux arm64, x86_64, riscv64
98
101
  * FreeBSD arm64
102
+ * Windows 10 X86_64
99
103
 
100
104
  ## Add Logo
101
105
  1. Create a file named **\<os>.pyhw** in **logo/ascii** folder
@@ -1,16 +1,19 @@
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)
13
+ ![Static Badge](https://img.shields.io/badge/riscv64-%238A2BE2)
11
14
 
12
15
 
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.**
16
+ 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
17
 
15
18
  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
19
 
@@ -77,8 +80,9 @@ This is due to the fact that system python is not supposed to be managed by pip.
77
80
 
78
81
  ## Tested OS
79
82
  * macOS arm64, x86_64
80
- * Linux arm64, x86_64
83
+ * Linux arm64, x86_64, riscv64
81
84
  * FreeBSD arm64
85
+ * Windows 10 X86_64
82
86
 
83
87
  ## Add Logo
84
88
  1. Create a file named **\<os>.pyhw** in **logo/ascii** folder
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pyhw"
7
- version = "0.7.4"
7
+ version = "0.9.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.9.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")
@@ -73,6 +73,9 @@ class CPUDetectLinux:
73
73
  model = compatible.split(",")[-1]
74
74
  if model.startswith("sun"):
75
75
  self.__cpuInfo.model = f"Allwinner {model.split('-')[-1].upper()} ({model})"
76
+ elif "cvitek" in compatible:
77
+ model = compatible.split(",")[-1]
78
+ self.__cpuInfo.model = f"Cvitek {model}"
76
79
  else:
77
80
  pass
78
81
 
@@ -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")
@@ -29,7 +29,7 @@ class GPUDetectLinux:
29
29
 
30
30
  def __handleNonePciDevices(self):
31
31
  # if detector can't find any VGA/Display/3D GPUs, assume the host is a sbc device, this function is a placeholder for a more advanced method.
32
- if getArch() == "aarch64" or getArch() == "arm32":
32
+ if getArch() in ["aarch64", "arm32", "riscv64"]:
33
33
  self.__gpuInfo.number = 1
34
34
  self.__gpuInfo.gpus.append(f"{CPUDetect(os='linux').getCPUInfo().model} [SOC Integrated]")
35
35
  else:
@@ -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
+
@@ -39,7 +39,7 @@ class HostDetectLinux:
39
39
  self._hostInfo.model = self._hostInfo.name + " " + self._hostInfo.version
40
40
  except FileNotFoundError:
41
41
  pass
42
- elif self._arch in ["aarch64", "arm32"]:
42
+ elif self._arch in ["aarch64", "arm32", "riscv64"]:
43
43
  # try to find dmi folder since some arm based desktops and servers may have same structure as x86_64 machines.
44
44
  if os.path.exists("/sys/devices/virtual/dmi/id"):
45
45
  try:
@@ -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,38 @@
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
+ if display != "":
19
+ self.__kernelInfo.kernel = f"{version} ({display}) {machine}"
20
+ else:
21
+ self.__kernelInfo.kernel = f"{version} {machine}"
22
+ return self.__kernelInfo
23
+
24
+ @staticmethod
25
+ def __get_windows_version():
26
+ try:
27
+ key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows NT\CurrentVersion")
28
+ display_version, _ = winreg.QueryValueEx(key, "DisplayVersion")
29
+ winreg.CloseKey(key)
30
+ return str(display_version)
31
+ except:
32
+ try:
33
+ key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows NT\CurrentVersion")
34
+ release_id, _ = winreg.QueryValueEx(key, "ReleaseId")
35
+ winreg.CloseKey(key)
36
+ return str(release_id)
37
+ except:
38
+ return ""
@@ -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
+
@@ -39,6 +39,8 @@ class NICDetectLinux:
39
39
  for interface in interfaces:
40
40
  try:
41
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
+ if if_ip == "":
43
+ continue
42
44
  self._nicInfo.nics.append(f"{interface} @ {if_ip}")
43
45
  self._nicInfo.number += 1
44
46
  except:
@@ -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")
@@ -0,0 +1,44 @@
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 NICDetectWindows:
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
+ self._nicInfo.nics.append("Not found")
34
+ self._nicInfo.number = 1
35
+
36
+ @staticmethod
37
+ def _nicNameClean(nic_name: str):
38
+ nic_name_clean = nic_name.replace("Corporation ", "")
39
+ return nic_name_clean
40
+
41
+ def _sortNICList(self):
42
+ return self._nicInfo.nics.sort()
43
+
44
+
@@ -0,0 +1,54 @@
1
+ from .npuInfo import NPUInfo
2
+ import pypci
3
+ import os
4
+
5
+
6
+ class NPUDetectLinux:
7
+ def __init__(self):
8
+ self._npuInfo = NPUInfo()
9
+
10
+ def getNPUInfo(self):
11
+ self._getNPUInfo()
12
+ self._sortNPUList()
13
+ return self._npuInfo
14
+
15
+ def _getNPUInfo(self):
16
+ npu_devices = pypci.PCI().FindAllNPU()
17
+ if len(npu_devices) == 0:
18
+ self._handleNonePciDevices()
19
+ else:
20
+ for device in npu_devices:
21
+ if device.subsystem_device_name != "":
22
+ device_name = f"{device.vendor_name} {device.device_name} ({device.subsystem_device_name})"
23
+ else:
24
+ device_name = f"{device.vendor_name} {device.device_name}"
25
+ self._npuInfo.npus.append(self._npuNameClean(device_name))
26
+ self._npuInfo.number += 1
27
+
28
+ def _handleNonePciDevices(self):
29
+ if os.path.exists("/sys/firmware/devicetree/base/tpu/compatible"):
30
+ try:
31
+ with open("/sys/firmware/devicetree/base/tpu/compatible", "r") as f:
32
+ compatible = f.read().strip()
33
+ except FileNotFoundError:
34
+ compatible = ""
35
+ if "cvitek" in compatible:
36
+ model = compatible.split(",")[-1]
37
+ self._npuInfo.npus.append(f"Cvitek {model}")
38
+ self._npuInfo.number = 1
39
+ else:
40
+ pass
41
+ else:
42
+ pass
43
+ # Place Holder for unknown NPU
44
+ if self._npuInfo.number == 0:
45
+ self._npuInfo.number = 1
46
+ self._npuInfo.npus.append("Not found")
47
+
48
+ @staticmethod
49
+ def _npuNameClean(npu_name: str):
50
+ npu_name_clean = npu_name.replace("Corporation ", "")
51
+ return npu_name_clean
52
+
53
+ def _sortNPUList(self):
54
+ self._npuInfo.npus.sort()
@@ -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")