pyhw 0.6.7__tar.gz → 0.7.0__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {pyhw-0.6.7/src/pyhw.egg-info → pyhw-0.7.0}/PKG-INFO +15 -7
- {pyhw-0.6.7 → pyhw-0.7.0}/README.md +14 -6
- {pyhw-0.6.7 → pyhw-0.7.0}/pyproject.toml +1 -1
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/__main__.py +2 -2
- pyhw-0.7.0/src/pyhw/backend/cpu/bsd.py +12 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/cpu/cpuBase.py +3 -0
- pyhw-0.7.0/src/pyhw/backend/gpu/bsd.py +7 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/gpu/gpuBase.py +3 -0
- pyhw-0.7.0/src/pyhw/backend/host/bsd.py +13 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/host/hostBase.py +3 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/host/linux.py +21 -21
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/kernel/kernelBase.py +1 -3
- pyhw-0.7.0/src/pyhw/backend/memory/bsd.py +11 -0
- pyhw-0.7.0/src/pyhw/backend/memory/linux.py +24 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/memory/memoryBase.py +3 -0
- pyhw-0.7.0/src/pyhw/backend/nic/bsd.py +7 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/nic/linux.py +12 -12
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/nic/nicBase.py +5 -0
- pyhw-0.7.0/src/pyhw/backend/npu/bsd.py +6 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/npu/linux.py +14 -18
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/npu/npuBase.py +3 -0
- pyhw-0.7.0/src/pyhw/backend/os/bsd.py +7 -0
- pyhw-0.7.0/src/pyhw/backend/os/linux.py +52 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/os/osBase.py +3 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/shell/shellBase.py +1 -1
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/shell/unix.py +0 -1
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/title/titleBase.py +1 -1
- pyhw-0.7.0/src/pyhw/backend/uptime/bsd.py +7 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/uptime/macos.py +12 -12
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/uptime/uptimeBase.py +3 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/frontend/color/colorConfig.py +10 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/frontend/frontendBase.py +8 -1
- pyhw-0.7.0/src/pyhw/frontend/logo/ascii/freebsd.pyhw +15 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/pyhwUtil/pyhwUtil.py +18 -8
- {pyhw-0.6.7 → pyhw-0.7.0/src/pyhw.egg-info}/PKG-INFO +15 -7
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw.egg-info/SOURCES.txt +9 -1
- pyhw-0.6.7/src/pyhw/backend/memory/linux.py +0 -24
- pyhw-0.6.7/src/pyhw/backend/os/linux.py +0 -52
- pyhw-0.6.7/src/pyhw/macos.py +0 -146
- {pyhw-0.6.7 → pyhw-0.7.0}/LICENSE +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/setup.cfg +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/__init__.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/__init__.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/backendBase.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/cpu/__init__.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/cpu/cpuInfo.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/cpu/linux.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/cpu/macos.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/gpu/__init__.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/gpu/gpuInfo.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/gpu/linux.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/gpu/macos.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/host/__init__.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/host/hostInfo.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/host/macos.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/host/windows.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/kernel/__init__.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/kernel/kernelInfo.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/kernel/unix.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/kernel/windows.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/memory/__init__.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/memory/macos.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/memory/memoryInfo.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/metal/t.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/nic/__init__.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/nic/macos.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/nic/nicInfo.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/npu/__init__.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/npu/macos.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/npu/npuInfo.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/os/__init__.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/os/macos.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/os/osInfo.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/shell/__init__.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/title/__init__.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/title/unix.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/title/windows.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/uptime/__init__.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/uptime/linux.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/backend/uptime/uptimeInfo.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/frontend/__init__.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/frontend/color/__init__.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/frontend/color/colorSet.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/frontend/color/colorUtil.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/frontend/logo/__init__.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/frontend/logo/ascii/alpine.pyhw +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/frontend/logo/ascii/arch.pyhw +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/frontend/logo/ascii/armbian.pyhw +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/frontend/logo/ascii/centos.pyhw +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/frontend/logo/ascii/debian.pyhw +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/frontend/logo/ascii/fedora.pyhw +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/frontend/logo/ascii/fedora_small.pyhw +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/frontend/logo/ascii/linux.pyhw +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/frontend/logo/ascii/macOS.pyhw +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/frontend/logo/ascii/raspbian.pyhw +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/frontend/logo/ascii/ubuntu.pyhw +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/frontend/logo/ascii/ubuntu_small.pyhw +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/frontend/logo/logoBase.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/library/lib/iokitGPULib.dylib +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/pyhwException/__init__.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/pyhwException/pyhwException.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/pyhwUtil/__init__.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw/pyhwUtil/sysctlUtil.py +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw.egg-info/dependency_links.txt +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw.egg-info/entry_points.txt +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw.egg-info/requires.txt +0 -0
- {pyhw-0.6.7 → pyhw-0.7.0}/src/pyhw.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pyhw
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.7.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
|
@@ -22,9 +22,10 @@ Requires-Dist: pypci-ng>=0.0.8
|
|
22
22
|

|
24
24
|

|
25
|
+

|
25
26
|
|
26
27
|
|
27
|
-
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
|
28
|
+
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.**
|
28
29
|
|
29
30
|
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 🤔).
|
30
31
|
|
@@ -50,6 +51,8 @@ pip install pyhw --upgrade
|
|
50
51
|
You can then use this tool directly from the command line with the following command, just like neofetch.
|
51
52
|
```shell
|
52
53
|
pyhw
|
54
|
+
# or
|
55
|
+
python -m pyhw
|
53
56
|
```
|
54
57
|
Please note that the command line entry for __pyhw__ is created by pip, and depending on the user, this entry may not in the __system PATH__. If you encounter this problem, pip will give you a prompt, follow the prompts to add entry to the __system PATH__.
|
55
58
|
|
@@ -66,7 +69,7 @@ pyhw
|
|
66
69
|
```
|
67
70
|
|
68
71
|
### Important note about debian 12:
|
69
|
-
If you use system pip to install pyhw, you will encounter this problem on debian12 and some related distributions:
|
72
|
+
If you use system pip to install pyhw, you will encounter this problem on debian12 and some related distributions (like Ubuntu 24.04):
|
70
73
|
```text
|
71
74
|
error: externally-managed-environment
|
72
75
|
|
@@ -87,14 +90,14 @@ hint: See PEP 668 for the detailed specification.
|
|
87
90
|
```
|
88
91
|
This is due to the fact that system python is not supposed to be managed by pip. You can simply use **pipx** to install **pyhw**. Or you can use a virtual environment (venv) or force remove this restriction (not recommended).
|
89
92
|
|
90
|
-
##
|
93
|
+
## Tested OS
|
91
94
|
* macOS arm64, x86_64
|
92
|
-
*
|
93
|
-
*
|
95
|
+
* Linux arm64, x86_64
|
96
|
+
* FreeBSD arm64
|
94
97
|
|
95
98
|
|
96
99
|
## Build from source
|
97
|
-
Currently, build process relay on swiftc and macOS IOKit framework. To build package from source, you need a
|
100
|
+
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.
|
98
101
|
|
99
102
|
### Dependencies
|
100
103
|
This package was originally implemented in pure python and only depends on the python standard library. However, in subsequent development, the code for the pci part was separated into a separate package **pypci-ng**, which can be obtained using pip (or check out [this](https://github.com/xiaoran007/pypci) GitHub repository).
|
@@ -119,3 +122,8 @@ Or simply type:
|
|
119
122
|
make build
|
120
123
|
make install
|
121
124
|
```
|
125
|
+
If you have docker installed, you can test this package through docker by type:
|
126
|
+
```shell
|
127
|
+
make test # local build
|
128
|
+
make test-pypi # release version
|
129
|
+
```
|
@@ -5,9 +5,10 @@
|
|
5
5
|

|
7
7
|

|
8
|
+

|
8
9
|
|
9
10
|
|
10
|
-
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
|
11
|
+
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.**
|
11
12
|
|
12
13
|
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 🤔).
|
13
14
|
|
@@ -33,6 +34,8 @@ pip install pyhw --upgrade
|
|
33
34
|
You can then use this tool directly from the command line with the following command, just like neofetch.
|
34
35
|
```shell
|
35
36
|
pyhw
|
37
|
+
# or
|
38
|
+
python -m pyhw
|
36
39
|
```
|
37
40
|
Please note that the command line entry for __pyhw__ is created by pip, and depending on the user, this entry may not in the __system PATH__. If you encounter this problem, pip will give you a prompt, follow the prompts to add entry to the __system PATH__.
|
38
41
|
|
@@ -49,7 +52,7 @@ pyhw
|
|
49
52
|
```
|
50
53
|
|
51
54
|
### Important note about debian 12:
|
52
|
-
If you use system pip to install pyhw, you will encounter this problem on debian12 and some related distributions:
|
55
|
+
If you use system pip to install pyhw, you will encounter this problem on debian12 and some related distributions (like Ubuntu 24.04):
|
53
56
|
```text
|
54
57
|
error: externally-managed-environment
|
55
58
|
|
@@ -70,14 +73,14 @@ hint: See PEP 668 for the detailed specification.
|
|
70
73
|
```
|
71
74
|
This is due to the fact that system python is not supposed to be managed by pip. You can simply use **pipx** to install **pyhw**. Or you can use a virtual environment (venv) or force remove this restriction (not recommended).
|
72
75
|
|
73
|
-
##
|
76
|
+
## Tested OS
|
74
77
|
* macOS arm64, x86_64
|
75
|
-
*
|
76
|
-
*
|
78
|
+
* Linux arm64, x86_64
|
79
|
+
* FreeBSD arm64
|
77
80
|
|
78
81
|
|
79
82
|
## Build from source
|
80
|
-
Currently, build process relay on swiftc and macOS IOKit framework. To build package from source, you need a
|
83
|
+
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.
|
81
84
|
|
82
85
|
### Dependencies
|
83
86
|
This package was originally implemented in pure python and only depends on the python standard library. However, in subsequent development, the code for the pci part was separated into a separate package **pypci-ng**, which can be obtained using pip (or check out [this](https://github.com/xiaoran007/pypci) GitHub repository).
|
@@ -102,3 +105,8 @@ Or simply type:
|
|
102
105
|
make build
|
103
106
|
make install
|
104
107
|
```
|
108
|
+
If you have docker installed, you can test this package through docker by type:
|
109
|
+
```shell
|
110
|
+
make test # local build
|
111
|
+
make test-pypi # release version
|
112
|
+
```
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "pyhw"
|
7
|
-
version = "0.
|
7
|
+
version = "0.7.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 = [
|
@@ -17,8 +17,8 @@ from .pyhwUtil import getOS, selectOSLogo
|
|
17
17
|
|
18
18
|
def main():
|
19
19
|
current_os = getOS()
|
20
|
-
if current_os
|
21
|
-
print(f"Only Linux and
|
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}")
|
22
22
|
return
|
23
23
|
data = Data()
|
24
24
|
data.title = TitleDetect(os=current_os).getTitle().title
|
@@ -0,0 +1,12 @@
|
|
1
|
+
from .cpuInfo import CPUInfo
|
2
|
+
from ...pyhwUtil import sysctlGetString, sysctlGetInt, getArch
|
3
|
+
|
4
|
+
|
5
|
+
class CPUDetectBSD:
|
6
|
+
def __init__(self):
|
7
|
+
self.__cpuInfo = CPUInfo()
|
8
|
+
|
9
|
+
def getCPUInfo(self):
|
10
|
+
self.__cpuInfo.cpu = sysctlGetString("hw.model")
|
11
|
+
return self.__cpuInfo
|
12
|
+
|
@@ -1,5 +1,6 @@
|
|
1
1
|
from .linux import CPUDetectLinux
|
2
2
|
from .macos import CPUDetectMacOS
|
3
|
+
from .bsd import CPUDetectBSD
|
3
4
|
from ...pyhwException import OSUnsupportedException
|
4
5
|
|
5
6
|
|
@@ -12,5 +13,7 @@ class CPUDetect:
|
|
12
13
|
return CPUDetectLinux().getCPUInfo()
|
13
14
|
elif self.OS == "macos":
|
14
15
|
return CPUDetectMacOS().getCPUInfo()
|
16
|
+
elif self.OS == "freebsd":
|
17
|
+
return CPUDetectBSD().getCPUInfo()
|
15
18
|
else:
|
16
19
|
raise OSUnsupportedException("Unsupported operating system")
|
@@ -1,5 +1,6 @@
|
|
1
1
|
from .linux import GPUDetectLinux
|
2
2
|
from .macos import GPUDetectMacOS
|
3
|
+
from .bsd import GPUDetectBSD
|
3
4
|
|
4
5
|
|
5
6
|
class GPUDetect:
|
@@ -11,5 +12,7 @@ class GPUDetect:
|
|
11
12
|
return GPUDetectLinux().getGPUInfo()
|
12
13
|
elif self.OS == "macos":
|
13
14
|
return GPUDetectMacOS().getGPUInfo()
|
15
|
+
elif self.OS == "freebsd":
|
16
|
+
return GPUDetectBSD().getGPUInfo()
|
14
17
|
else:
|
15
18
|
raise NotImplementedError("Unsupported operating system")
|
@@ -0,0 +1,13 @@
|
|
1
|
+
from .linux import HostDetectLinux
|
2
|
+
|
3
|
+
|
4
|
+
class HostDetectBSD(HostDetectLinux):
|
5
|
+
def __init__(self):
|
6
|
+
HostDetectLinux.__init__(self)
|
7
|
+
|
8
|
+
def getHostInfo(self):
|
9
|
+
self._hostInfo.name = f"General {self._arch} FreeBSD Host"
|
10
|
+
self._hostInfo.version = ""
|
11
|
+
self._hostInfo.model = self._hostInfo.name + " " + self._hostInfo.version
|
12
|
+
return self._hostInfo
|
13
|
+
|
@@ -1,6 +1,7 @@
|
|
1
1
|
from .linux import HostDetectLinux
|
2
2
|
from .macos import HostDetectMacOS
|
3
3
|
from .windows import HostDetectWindows
|
4
|
+
from .bsd import HostDetectBSD
|
4
5
|
from ...pyhwException import OSUnsupportedException
|
5
6
|
|
6
7
|
|
@@ -13,6 +14,8 @@ class HostDetect:
|
|
13
14
|
return HostDetectLinux().getHostInfo()
|
14
15
|
elif self.OS == "macos":
|
15
16
|
return HostDetectMacOS().getHostInfo()
|
17
|
+
elif self.OS == "freebsd":
|
18
|
+
return HostDetectBSD().getHostInfo()
|
16
19
|
elif self.OS == "windows":
|
17
20
|
pass
|
18
21
|
else:
|
@@ -8,53 +8,53 @@ import os
|
|
8
8
|
|
9
9
|
class HostDetectLinux:
|
10
10
|
def __init__(self):
|
11
|
-
self.
|
12
|
-
self.
|
13
|
-
self.
|
11
|
+
self._hostInfo = HostInfo()
|
12
|
+
self._arch = getArch()
|
13
|
+
self._docker = getDocker()
|
14
14
|
|
15
15
|
def getHostInfo(self):
|
16
|
-
self.
|
17
|
-
return self.
|
16
|
+
self._getModel()
|
17
|
+
return self._hostInfo
|
18
18
|
|
19
|
-
def
|
20
|
-
if self.
|
21
|
-
self.
|
22
|
-
self.
|
23
|
-
self.
|
19
|
+
def _getModel(self):
|
20
|
+
if self._docker:
|
21
|
+
self._hostInfo.name = f"General {self._arch} Docker Host"
|
22
|
+
self._hostInfo.version = ""
|
23
|
+
self._hostInfo.model = self._hostInfo.name + " " + self._hostInfo.version
|
24
24
|
else:
|
25
|
-
if self.
|
25
|
+
if self._arch in ["x86_64", "x86"]:
|
26
26
|
try:
|
27
27
|
with open("/sys/devices/virtual/dmi/id/product_name", "r") as f:
|
28
28
|
product_name = f.read().strip()
|
29
29
|
if product_name.startswith("To be filled by O.E.M."):
|
30
|
-
self.
|
30
|
+
self._hostInfo.name = f"General {self._arch} Host"
|
31
31
|
else:
|
32
|
-
self.
|
32
|
+
self._hostInfo.name = product_name
|
33
33
|
with open("/sys/devices/virtual/dmi/id/product_version", "r") as f:
|
34
34
|
version = f.read().strip()
|
35
35
|
if version.startswith("To be filled by O.E.M."):
|
36
|
-
self.
|
36
|
+
self._hostInfo.version = ""
|
37
37
|
else:
|
38
|
-
self.
|
39
|
-
self.
|
38
|
+
self._hostInfo.version = version
|
39
|
+
self._hostInfo.model = self._hostInfo.name + " " + self._hostInfo.version
|
40
40
|
except FileNotFoundError:
|
41
41
|
pass
|
42
|
-
elif self.
|
42
|
+
elif self._arch in ["aarch64", "arm32"]:
|
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:
|
46
46
|
with open("/sys/devices/virtual/dmi/id/product_name", "r") as f:
|
47
|
-
self.
|
47
|
+
self._hostInfo.name = f.read().strip()
|
48
48
|
with open("/sys/devices/virtual/dmi/id/product_version", "r") as f:
|
49
|
-
self.
|
50
|
-
self.
|
49
|
+
self._hostInfo.version = f.read().strip()
|
50
|
+
self._hostInfo.model = self._hostInfo.name + " " + self._hostInfo.version
|
51
51
|
except FileNotFoundError:
|
52
52
|
pass
|
53
53
|
else:
|
54
54
|
# some single board computers may not have dmi folder, try to find model name in device tree.
|
55
55
|
try:
|
56
56
|
with open("/sys/firmware/devicetree/base/model", "r") as f:
|
57
|
-
self.
|
57
|
+
self._hostInfo.model = f.read().strip()
|
58
58
|
except FileNotFoundError:
|
59
59
|
pass
|
60
60
|
|
@@ -7,9 +7,7 @@ class KernelDetect:
|
|
7
7
|
self.OS = os
|
8
8
|
|
9
9
|
def getKernelInfo(self):
|
10
|
-
if self.OS
|
11
|
-
return KernelDetectUnix().getKernelInfo()
|
12
|
-
elif self.OS == "macos":
|
10
|
+
if self.OS in ["linux", "macos", "freebsd"]:
|
13
11
|
return KernelDetectUnix().getKernelInfo()
|
14
12
|
elif self.OS == "windows":
|
15
13
|
raise OSUnsupportedException("Unsupported operating system")
|
@@ -0,0 +1,24 @@
|
|
1
|
+
from .memoryInfo import MemoryInfo
|
2
|
+
|
3
|
+
|
4
|
+
class MemoryDetectLinux:
|
5
|
+
def __init__(self):
|
6
|
+
self._memoryInfo = MemoryInfo()
|
7
|
+
|
8
|
+
def getMemoryInfo(self):
|
9
|
+
self._getMemory()
|
10
|
+
self._memoryInfo.memory = f"{self._memoryInfo.used} MiB / {self._memoryInfo.total} MiB"
|
11
|
+
return self._memoryInfo
|
12
|
+
|
13
|
+
def _getMemory(self):
|
14
|
+
try:
|
15
|
+
with open("/proc/meminfo", "r") as file:
|
16
|
+
for line in file:
|
17
|
+
if line.startswith("MemTotal:"):
|
18
|
+
self._memoryInfo.total = round(float(line.split(":")[1].strip()[:-3]) / 1024, 2)
|
19
|
+
elif line.startswith("MemAvailable:"):
|
20
|
+
self._memoryInfo.available = round(float(line.split(":")[1].strip()[:-3]) / 1024, 2)
|
21
|
+
self._memoryInfo.used = round(self._memoryInfo.total - self._memoryInfo.available, 2)
|
22
|
+
except FileNotFoundError:
|
23
|
+
pass
|
24
|
+
|
@@ -1,5 +1,6 @@
|
|
1
1
|
from .linux import MemoryDetectLinux
|
2
2
|
from .macos import MemoryDetectMacOS
|
3
|
+
from .bsd import MemoryDetectBSD
|
3
4
|
|
4
5
|
|
5
6
|
class MemoryDetect:
|
@@ -11,5 +12,7 @@ class MemoryDetect:
|
|
11
12
|
return MemoryDetectLinux().getMemoryInfo()
|
12
13
|
elif self.OS == "macos":
|
13
14
|
return MemoryDetectMacOS().getMemoryInfo()
|
15
|
+
elif self.OS == "freebsd":
|
16
|
+
return MemoryDetectBSD().getMemoryInfo()
|
14
17
|
else:
|
15
18
|
raise NotImplementedError("Unsupported operating system")
|
@@ -7,14 +7,14 @@ import pypci
|
|
7
7
|
|
8
8
|
class NICDetectLinux:
|
9
9
|
def __init__(self):
|
10
|
-
self.
|
10
|
+
self._nicInfo = NICInfo()
|
11
11
|
|
12
12
|
def getNICInfo(self):
|
13
|
-
self.
|
14
|
-
self.
|
15
|
-
return self.
|
13
|
+
self._getNICInfo()
|
14
|
+
self._sortNICList()
|
15
|
+
return self._nicInfo
|
16
16
|
|
17
|
-
def
|
17
|
+
def _getNICInfo(self):
|
18
18
|
nic_devices = pypci.PCI().FindAllNIC()
|
19
19
|
if len(nic_devices) == 0:
|
20
20
|
self.__handleNonePciDevices()
|
@@ -24,18 +24,18 @@ class NICDetectLinux:
|
|
24
24
|
device_name = f"{device.vendor_name} {device.device_name} ({device.subsystem_device_name})"
|
25
25
|
else:
|
26
26
|
device_name = f"{device.vendor_name} {device.device_name}"
|
27
|
-
self.
|
28
|
-
self.
|
27
|
+
self._nicInfo.nics.append(self._nicNameClean(device_name))
|
28
|
+
self._nicInfo.number += 1
|
29
29
|
|
30
30
|
def __handleNonePciDevices(self):
|
31
31
|
# placeholder for a more advanced method.
|
32
|
-
self.
|
33
|
-
self.
|
32
|
+
self._nicInfo.nics.append("Not found")
|
33
|
+
self._nicInfo.number = 1
|
34
34
|
|
35
35
|
@staticmethod
|
36
|
-
def
|
36
|
+
def _nicNameClean(nic_name: str):
|
37
37
|
nic_name_clean = nic_name.replace("Corporation ", "")
|
38
38
|
return nic_name_clean
|
39
39
|
|
40
|
-
def
|
41
|
-
return self.
|
40
|
+
def _sortNICList(self):
|
41
|
+
return self._nicInfo.nics.sort()
|
@@ -1,5 +1,6 @@
|
|
1
1
|
from .linux import NICDetectLinux
|
2
2
|
from .macos import NICDetectMacOS
|
3
|
+
from .bsd import NICDetectBSD
|
3
4
|
|
4
5
|
|
5
6
|
class NICDetect:
|
@@ -18,3 +19,7 @@ class NICDetect:
|
|
18
19
|
return NICDetectLinux().getNICInfo()
|
19
20
|
elif self.OS == "macos":
|
20
21
|
return NICDetectMacOS().getNICInfo()
|
22
|
+
elif self.OS == "freebsd":
|
23
|
+
return NICDetectBSD().getNICInfo()
|
24
|
+
else:
|
25
|
+
raise NotImplementedError("Unsupported operating system")
|
@@ -1,42 +1,38 @@
|
|
1
|
-
import subprocess
|
2
1
|
from .npuInfo import NPUInfo
|
3
|
-
from ..cpu import CPUDetect
|
4
|
-
from ...pyhwUtil import getArch
|
5
2
|
import pypci
|
6
3
|
|
7
4
|
|
8
5
|
class NPUDetectLinux:
|
9
6
|
def __init__(self):
|
10
|
-
self.
|
7
|
+
self._npuInfo = NPUInfo()
|
11
8
|
|
12
9
|
def getNPUInfo(self):
|
13
|
-
self.
|
14
|
-
self.
|
15
|
-
return self.
|
10
|
+
self._getNPUInfo()
|
11
|
+
self._sortNPUList()
|
12
|
+
return self._npuInfo
|
16
13
|
|
17
|
-
def
|
14
|
+
def _getNPUInfo(self):
|
18
15
|
npu_devices = pypci.PCI().FindAllNPU()
|
19
16
|
if len(npu_devices) == 0:
|
20
|
-
self.
|
17
|
+
self._handleNonePciDevices()
|
21
18
|
else:
|
22
19
|
for device in npu_devices:
|
23
20
|
if device.subsystem_device_name != "":
|
24
21
|
device_name = f"{device.vendor_name} {device.device_name} ({device.subsystem_device_name})"
|
25
22
|
else:
|
26
23
|
device_name = f"{device.vendor_name} {device.device_name}"
|
27
|
-
self.
|
28
|
-
self.
|
24
|
+
self._npuInfo.npus.append(self._npuNameClean(device_name))
|
25
|
+
self._npuInfo.number += 1
|
29
26
|
|
30
|
-
def
|
27
|
+
def _handleNonePciDevices(self):
|
31
28
|
# Place Holder for unknown NPU
|
32
|
-
self.
|
33
|
-
self.
|
29
|
+
self._npuInfo.number = 1
|
30
|
+
self._npuInfo.npus.append("Not found")
|
34
31
|
|
35
32
|
@staticmethod
|
36
|
-
def
|
33
|
+
def _npuNameClean(npu_name: str):
|
37
34
|
npu_name_clean = npu_name.replace("Corporation ", "")
|
38
35
|
return npu_name_clean
|
39
36
|
|
40
|
-
def
|
41
|
-
self.
|
42
|
-
|
37
|
+
def _sortNPUList(self):
|
38
|
+
self._npuInfo.npus.sort()
|
@@ -1,5 +1,6 @@
|
|
1
1
|
from .linux import NPUDetectLinux
|
2
2
|
from .macos import NPUDetectMacOS
|
3
|
+
from .bsd import NPUDetectBSD
|
3
4
|
|
4
5
|
|
5
6
|
class NPUDetect:
|
@@ -11,6 +12,8 @@ class NPUDetect:
|
|
11
12
|
return NPUDetectLinux().getNPUInfo()
|
12
13
|
elif self.OS == "macos":
|
13
14
|
return NPUDetectMacOS().getNPUInfo()
|
15
|
+
elif self.OS == "freebsd":
|
16
|
+
return NPUDetectBSD().getNPUInfo()
|
14
17
|
else:
|
15
18
|
raise NotImplementedError("Unsupported operating system")
|
16
19
|
|
@@ -0,0 +1,52 @@
|
|
1
|
+
"""
|
2
|
+
In dev.
|
3
|
+
"""
|
4
|
+
from .osInfo import OSInfo
|
5
|
+
|
6
|
+
|
7
|
+
class OSDetectLinux:
|
8
|
+
def __init__(self):
|
9
|
+
self._osInfo = OSInfo()
|
10
|
+
|
11
|
+
def getOSInfo(self):
|
12
|
+
"""
|
13
|
+
Detects the os distribution and its version.
|
14
|
+
:return: dataclass OSInfoLinux, direct attrs: prettyName
|
15
|
+
"""
|
16
|
+
self._getOSInfo()
|
17
|
+
self._handleArmbian()
|
18
|
+
return self._osInfo
|
19
|
+
|
20
|
+
def _getOSInfo(self):
|
21
|
+
try:
|
22
|
+
with open("/etc/os-release", "r") as f:
|
23
|
+
for line in f:
|
24
|
+
key, value = line.strip().split("=")
|
25
|
+
if key == "PRETTY_NAME":
|
26
|
+
self._osInfo.prettyName = value.strip('"')
|
27
|
+
elif key == "NAME":
|
28
|
+
self._osInfo.name = value.strip('"')
|
29
|
+
elif key == "ID":
|
30
|
+
self._osInfo.id = value.strip('"')
|
31
|
+
elif key == "ID_LIKE":
|
32
|
+
self._osInfo.idLike = value.strip('"')
|
33
|
+
elif key == "VARIANT":
|
34
|
+
self._osInfo.variant = value.strip('"')
|
35
|
+
elif key == "VARIANT_ID":
|
36
|
+
self._osInfo.variantID = value.strip('"')
|
37
|
+
elif key == "VERSION":
|
38
|
+
self._osInfo.version = value.strip('"')
|
39
|
+
elif key == "VERSION_ID":
|
40
|
+
self._osInfo.versionID = value.strip('"')
|
41
|
+
elif key == "VERSION_CODENAME":
|
42
|
+
self._osInfo.versionCodename = value.strip('"')
|
43
|
+
elif key == "CODE_NAME":
|
44
|
+
self._osInfo.codeName = value.strip('"')
|
45
|
+
elif key == "BUILD_ID":
|
46
|
+
self._osInfo.buildID = value.strip('"')
|
47
|
+
except Exception:
|
48
|
+
pass
|
49
|
+
|
50
|
+
def _handleArmbian(self):
|
51
|
+
if "Armbian" in self._osInfo.prettyName or "armbian" in self._osInfo.prettyName:
|
52
|
+
self._osInfo.id = "armbian"
|
@@ -1,5 +1,6 @@
|
|
1
1
|
from .linux import OSDetectLinux
|
2
2
|
from .macos import OSDetectMacOS
|
3
|
+
from .bsd import OSDetectBSD
|
3
4
|
from ...pyhwException import OSUnsupportedException
|
4
5
|
|
5
6
|
|
@@ -12,5 +13,7 @@ class OSDetect:
|
|
12
13
|
return OSDetectLinux().getOSInfo()
|
13
14
|
elif self.__OS == "macos":
|
14
15
|
return OSDetectMacOS().getOSInfo()
|
16
|
+
elif self.__OS == "freebsd":
|
17
|
+
return OSDetectBSD().getOSInfo()
|
15
18
|
else:
|
16
19
|
raise OSUnsupportedException("Unsupported operating system")
|
@@ -7,7 +7,7 @@ class ShellDetect:
|
|
7
7
|
self.OS = os
|
8
8
|
|
9
9
|
def getShellInfo(self):
|
10
|
-
if self.OS
|
10
|
+
if self.OS in ["linux", "macos", "freebsd"]:
|
11
11
|
return ShellDetectUnix().getShellInfo()
|
12
12
|
else:
|
13
13
|
raise OSUnsupportedException("Unsupported operating system")
|
@@ -8,7 +8,7 @@ class TitleDetect:
|
|
8
8
|
self.OS = os
|
9
9
|
|
10
10
|
def getTitle(self):
|
11
|
-
if self.OS
|
11
|
+
if self.OS in ["linux", "macos", "freebsd"]:
|
12
12
|
return TitleDetectUnix().getTitle()
|
13
13
|
elif self.OS == "windows":
|
14
14
|
return TitleDetectWindows().getTitle()
|