pyhw 0.7.4__tar.gz → 0.8.0__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {pyhw-0.7.4/src/pyhw.egg-info → pyhw-0.8.0}/PKG-INFO +6 -3
- {pyhw-0.7.4 → pyhw-0.8.0}/README.md +4 -1
- {pyhw-0.7.4 → pyhw-0.8.0}/pyproject.toml +2 -2
- pyhw-0.8.0/src/pyhw/__init__.py +1 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/__main__.py +2 -2
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/cpu/cpuBase.py +6 -3
- pyhw-0.8.0/src/pyhw/backend/cpu/windows.py +48 -0
- pyhw-0.8.0/src/pyhw/backend/gpu/gpuBase.py +22 -0
- pyhw-0.8.0/src/pyhw/backend/gpu/windows.py +41 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/host/hostBase.py +5 -5
- pyhw-0.8.0/src/pyhw/backend/host/hostInfo.py +22 -0
- pyhw-0.8.0/src/pyhw/backend/host/windows.py +36 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/kernel/kernelBase.py +3 -2
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/kernel/kernelInfo.py +6 -0
- pyhw-0.8.0/src/pyhw/backend/kernel/windows.py +29 -0
- pyhw-0.8.0/src/pyhw/backend/memory/memoryBase.py +22 -0
- pyhw-0.8.0/src/pyhw/backend/memory/windows.py +36 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/nic/nicBase.py +8 -4
- pyhw-0.8.0/src/pyhw/backend/nic/windows.py +44 -0
- pyhw-0.8.0/src/pyhw/backend/npu/npuBase.py +22 -0
- pyhw-0.8.0/src/pyhw/backend/npu/windows.py +40 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/os/osBase.py +6 -3
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/os/osInfo.py +6 -0
- pyhw-0.8.0/src/pyhw/backend/os/windows.py +35 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/shell/shellBase.py +4 -1
- pyhw-0.8.0/src/pyhw/backend/shell/shellInfo.py +10 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/shell/unix.py +2 -10
- pyhw-0.8.0/src/pyhw/backend/shell/windows.py +29 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/title/titleBase.py +2 -2
- pyhw-0.8.0/src/pyhw/backend/title/titleInfo.py +9 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/title/unix.py +2 -9
- pyhw-0.8.0/src/pyhw/backend/title/windows.py +17 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/uptime/linux.py +3 -3
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/uptime/macos.py +3 -3
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/uptime/uptimeBase.py +6 -3
- pyhw-0.8.0/src/pyhw/backend/uptime/windows.py +49 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/frontend/color/colorConfig.py +52 -0
- pyhw-0.8.0/src/pyhw/frontend/logo/ascii/windows_10.pyhw +19 -0
- pyhw-0.8.0/src/pyhw/frontend/logo/ascii/windows_11.pyhw +17 -0
- pyhw-0.8.0/src/pyhw/frontend/logo/ascii/windows_2025.pyhw +17 -0
- pyhw-0.8.0/src/pyhw/frontend/logo/ascii/windows_old.pyhw +16 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/pyhwUtil/pyhwUtil.py +10 -3
- {pyhw-0.7.4 → pyhw-0.8.0/src/pyhw.egg-info}/PKG-INFO +6 -3
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw.egg-info/SOURCES.txt +14 -0
- pyhw-0.8.0/src/pyhw.egg-info/requires.txt +1 -0
- pyhw-0.7.4/src/pyhw/__init__.py +0 -1
- pyhw-0.7.4/src/pyhw/backend/gpu/gpuBase.py +0 -18
- pyhw-0.7.4/src/pyhw/backend/host/hostInfo.py +0 -13
- pyhw-0.7.4/src/pyhw/backend/host/windows.py +0 -5
- pyhw-0.7.4/src/pyhw/backend/kernel/windows.py +0 -7
- pyhw-0.7.4/src/pyhw/backend/memory/memoryBase.py +0 -18
- pyhw-0.7.4/src/pyhw/backend/npu/npuBase.py +0 -20
- pyhw-0.7.4/src/pyhw/backend/title/windows.py +0 -8
- pyhw-0.7.4/src/pyhw.egg-info/requires.txt +0 -1
- {pyhw-0.7.4 → pyhw-0.8.0}/LICENSE +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/setup.cfg +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/__init__.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/backendBase.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/cpu/__init__.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/cpu/bsd.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/cpu/cpuInfo.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/cpu/linux.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/cpu/macos.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/gpu/__init__.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/gpu/bsd.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/gpu/gpuInfo.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/gpu/linux.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/gpu/macos.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/host/__init__.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/host/bsd.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/host/linux.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/host/macos.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/kernel/__init__.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/kernel/unix.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/memory/__init__.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/memory/bsd.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/memory/linux.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/memory/macos.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/memory/memoryInfo.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/metal/t.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/nic/__init__.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/nic/bsd.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/nic/linux.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/nic/macos.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/nic/nicInfo.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/npu/__init__.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/npu/bsd.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/npu/linux.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/npu/macos.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/npu/npuInfo.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/os/__init__.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/os/bsd.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/os/linux.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/os/macos.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/shell/__init__.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/title/__init__.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/uptime/__init__.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/uptime/bsd.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/backend/uptime/uptimeInfo.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/frontend/__init__.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/frontend/color/__init__.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/frontend/color/colorSet.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/frontend/color/colorUtil.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/frontend/frontendBase.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/frontend/logo/__init__.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/alpine.pyhw +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/arch.pyhw +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/armbian.pyhw +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/centos.pyhw +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/debian.pyhw +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/fedora.pyhw +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/fedora_small.pyhw +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/freebsd.pyhw +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/linux.pyhw +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/macOS.pyhw +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/raspbian.pyhw +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/ubuntu.pyhw +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/frontend/logo/ascii/ubuntu_small.pyhw +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/frontend/logo/logoBase.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/library/lib/iokitGPULib.dylib +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/pyhwException/__init__.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/pyhwException/pyhwException.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/pyhwUtil/__init__.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw/pyhwUtil/sysctlUtil.py +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw.egg-info/dependency_links.txt +0 -0
- {pyhw-0.7.4 → pyhw-0.8.0}/src/pyhw.egg-info/entry_points.txt +0 -0
- {pyhw-0.7.4 → 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.
|
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,21 +13,23 @@ 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.
|
16
|
+
Requires-Dist: pypci-ng>=0.1.2
|
17
17
|
|
18
18
|
# PyHw
|
19
19
|
[](https://pepy.tech/project/pyhw)
|
20
20
|

|
21
|
+

|
21
22
|
|
22
23
|

|
23
24
|

|
24
25
|

|
26
|
+

|
25
27
|
|
26
28
|

|
27
29
|

|
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
|
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
|
|
@@ -96,6 +98,7 @@ 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
|
|
100
103
|
## Add Logo
|
101
104
|
1. Create a file named **\<os>.pyhw** in **logo/ascii** folder
|
@@ -1,16 +1,18 @@
|
|
1
1
|
# PyHw
|
2
2
|
[](https://pepy.tech/project/pyhw)
|
3
3
|

|
4
|
+

|
4
5
|
|
5
6
|

|
6
7
|

|
7
8
|

|
9
|
+

|
8
10
|
|
9
11
|

|
10
12
|

|
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
|
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
|
|
@@ -79,6 +81,7 @@ 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
|
|
83
86
|
## Add Logo
|
84
87
|
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
|
+
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.
|
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
|
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
|
-
|
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
|
-
|
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
|
+
|
@@ -1,6 +1,4 @@
|
|
1
|
-
from
|
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
|
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,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
|
+
|
@@ -1,6 +1,3 @@
|
|
1
|
-
from .linux import OSDetectLinux
|
2
|
-
from .macos import OSDetectMacOS
|
3
|
-
from .bsd import OSDetectBSD
|
4
1
|
from ...pyhwException import OSUnsupportedException
|
5
2
|
|
6
3
|
|
@@ -10,10 +7,16 @@ class OSDetect:
|
|
10
7
|
|
11
8
|
def getOSInfo(self):
|
12
9
|
if self.__OS == "linux":
|
10
|
+
from .linux import OSDetectLinux
|
13
11
|
return OSDetectLinux().getOSInfo()
|
14
12
|
elif self.__OS == "macos":
|
13
|
+
from .macos import OSDetectMacOS
|
15
14
|
return OSDetectMacOS().getOSInfo()
|
16
15
|
elif self.__OS == "freebsd":
|
16
|
+
from .bsd import OSDetectBSD
|
17
17
|
return OSDetectBSD().getOSInfo()
|
18
|
+
elif self.__OS == "windows":
|
19
|
+
from .windows import OSDetectWindows
|
20
|
+
return OSDetectWindows().getOSInfo()
|
18
21
|
else:
|
19
22
|
raise OSUnsupportedException("Unsupported operating system")
|
@@ -3,7 +3,13 @@ from dataclasses import dataclass
|
|
3
3
|
|
4
4
|
@dataclass
|
5
5
|
class OSInfo:
|
6
|
+
"""
|
7
|
+
Dataclass to hold the OS information
|
8
|
+
"""
|
6
9
|
def __init__(self):
|
10
|
+
"""
|
11
|
+
Initialize the dataclass, prettyName and id attributes are required.
|
12
|
+
"""
|
7
13
|
self.prettyName = ""
|
8
14
|
self.name = ""
|
9
15
|
self.id = ""
|
@@ -0,0 +1,35 @@
|
|
1
|
+
from .osInfo import OSInfo
|
2
|
+
from ...pyhwException import BackendException
|
3
|
+
import platform
|
4
|
+
import winreg
|
5
|
+
|
6
|
+
|
7
|
+
class OSDetectWindows:
|
8
|
+
def __init__(self):
|
9
|
+
self._osInfo = OSInfo()
|
10
|
+
|
11
|
+
def getOSInfo(self):
|
12
|
+
system = platform.system()
|
13
|
+
release = platform.release()
|
14
|
+
edition = platform.win32_edition()
|
15
|
+
machine = platform.machine()
|
16
|
+
display = self.__get_windows_version()
|
17
|
+
self._osInfo.prettyName = f"{system} {release} {display} ({edition}) {machine}"
|
18
|
+
if release == "10":
|
19
|
+
self._osInfo.id = "windows_10"
|
20
|
+
elif release == "11":
|
21
|
+
self._osInfo.id = "windows_11"
|
22
|
+
else:
|
23
|
+
self._osInfo.id = "windows_old"
|
24
|
+
return self._osInfo
|
25
|
+
|
26
|
+
@staticmethod
|
27
|
+
def __get_windows_version():
|
28
|
+
try:
|
29
|
+
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows NT\CurrentVersion")
|
30
|
+
display_version, _ = winreg.QueryValueEx(key, "DisplayVersion")
|
31
|
+
winreg.CloseKey(key)
|
32
|
+
return str(display_version)
|
33
|
+
except:
|
34
|
+
raise BackendException("Unable to determine Windows kernel version.")
|
35
|
+
|