pyhw 0.2.0b0__py3-none-any.whl → 0.7.4__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- pyhw/__init__.py +1 -1
- pyhw/__main__.py +10 -3
- pyhw/backend/backendBase.py +2 -0
- pyhw/backend/cpu/bsd.py +12 -0
- pyhw/backend/cpu/cpuBase.py +3 -0
- pyhw/backend/cpu/linux.py +26 -0
- pyhw/backend/cpu/macos.py +3 -1
- pyhw/backend/gpu/bsd.py +7 -0
- pyhw/backend/gpu/gpuBase.py +3 -0
- pyhw/backend/gpu/linux.py +20 -11
- pyhw/backend/gpu/macos.py +54 -17
- pyhw/backend/host/bsd.py +13 -0
- pyhw/backend/host/hostBase.py +3 -0
- pyhw/backend/host/linux.py +48 -21
- pyhw/backend/host/macos.py +11 -1
- pyhw/backend/kernel/kernelBase.py +1 -3
- pyhw/backend/memory/bsd.py +11 -0
- pyhw/backend/memory/linux.py +8 -8
- pyhw/backend/memory/memoryBase.py +3 -0
- pyhw/backend/nic/__init__.py +4 -0
- pyhw/backend/nic/bsd.py +7 -0
- pyhw/backend/nic/linux.py +58 -0
- pyhw/backend/nic/macos.py +27 -0
- pyhw/backend/nic/nicBase.py +25 -0
- pyhw/backend/nic/nicInfo.py +8 -0
- pyhw/backend/npu/__init__.py +5 -0
- pyhw/backend/npu/bsd.py +6 -0
- pyhw/backend/npu/linux.py +38 -0
- pyhw/backend/npu/macos.py +65 -0
- pyhw/backend/npu/npuBase.py +20 -0
- pyhw/backend/npu/npuInfo.py +10 -0
- pyhw/backend/os/bsd.py +7 -0
- pyhw/backend/os/linux.py +20 -15
- pyhw/backend/os/macos.py +21 -3
- pyhw/backend/os/osBase.py +3 -0
- pyhw/backend/shell/shellBase.py +1 -1
- pyhw/backend/shell/unix.py +20 -2
- pyhw/backend/title/titleBase.py +1 -1
- pyhw/backend/uptime/bsd.py +7 -0
- pyhw/backend/uptime/macos.py +12 -12
- pyhw/backend/uptime/uptimeBase.py +3 -0
- pyhw/frontend/color/colorConfig.py +70 -1
- pyhw/frontend/frontendBase.py +41 -2
- pyhw/frontend/logo/ascii/alpine.pyhw +6 -0
- pyhw/frontend/logo/ascii/arch.pyhw +19 -0
- pyhw/frontend/logo/ascii/armbian.pyhw +14 -0
- pyhw/frontend/logo/ascii/centos.pyhw +19 -0
- pyhw/frontend/logo/ascii/freebsd.pyhw +15 -0
- pyhw/frontend/logo/ascii/raspbian.pyhw +10 -0
- pyhw/library/lib/iokitGPULib.dylib +0 -0
- pyhw/pyhwUtil/__init__.py +2 -2
- pyhw/pyhwUtil/pyhwUtil.py +137 -4
- pyhw-0.7.4.dist-info/METADATA +135 -0
- pyhw-0.7.4.dist-info/RECORD +99 -0
- {pyhw-0.2.0b0.dist-info → pyhw-0.7.4.dist-info}/WHEEL +1 -1
- pyhw/macos.py +0 -146
- pyhw-0.2.0b0.dist-info/METADATA +0 -50
- pyhw-0.2.0b0.dist-info/RECORD +0 -75
- {pyhw-0.2.0b0.dist-info → pyhw-0.7.4.dist-info}/LICENSE +0 -0
- {pyhw-0.2.0b0.dist-info → pyhw-0.7.4.dist-info}/entry_points.txt +0 -0
- {pyhw-0.2.0b0.dist-info → pyhw-0.7.4.dist-info}/top_level.txt +0 -0
Binary file
|
pyhw/pyhwUtil/__init__.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
from .pyhwUtil import getOS, getArch, createDataString, selectOSLogo
|
1
|
+
from .pyhwUtil import getOS, getArch, getDocker, createDataString, selectOSLogo
|
2
2
|
from .sysctlUtil import sysctlGetString, sysctlGetInt
|
3
3
|
|
4
|
-
__all__ = ["getOS", "getArch", "createDataString", "selectOSLogo", "sysctlGetString", "sysctlGetInt"]
|
4
|
+
__all__ = ["getOS", "getArch", "getDocker", "createDataString", "selectOSLogo", "sysctlGetString", "sysctlGetInt"]
|
pyhw/pyhwUtil/pyhwUtil.py
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
import platform
|
2
2
|
from ..backend import Data
|
3
3
|
import os
|
4
|
+
from dataclasses import dataclass
|
4
5
|
|
5
6
|
|
6
7
|
def getOS():
|
7
8
|
"""
|
8
9
|
Get the os type in lower case.
|
9
|
-
:return: str, os type, value in [windows, linux, macos, unknown].
|
10
|
+
:return: str, os type, value in [windows, linux, macos, freebsd, unknown].
|
10
11
|
"""
|
11
12
|
system = platform.system()
|
12
13
|
if system == "Windows":
|
@@ -15,6 +16,8 @@ def getOS():
|
|
15
16
|
return "linux"
|
16
17
|
elif system == "Darwin":
|
17
18
|
return "macos"
|
19
|
+
elif system == "FreeBSD":
|
20
|
+
return "freebsd"
|
18
21
|
else:
|
19
22
|
return "unknown"
|
20
23
|
|
@@ -37,7 +40,118 @@ def getArch():
|
|
37
40
|
return "unknown"
|
38
41
|
|
39
42
|
|
43
|
+
def getDocker() -> bool:
|
44
|
+
"""
|
45
|
+
Check if the current environment is running in Docker.
|
46
|
+
:return: bool, True if running in Docker, False otherwise.
|
47
|
+
"""
|
48
|
+
return os.path.exists("/.dockerenv")
|
49
|
+
|
50
|
+
|
51
|
+
class DataStringProcessor:
|
52
|
+
def __init__(self, data: Data):
|
53
|
+
self.data = data
|
54
|
+
self.columns = self.__getENV()
|
55
|
+
|
56
|
+
@staticmethod
|
57
|
+
def __getENV() -> int:
|
58
|
+
if getOS() == "linux":
|
59
|
+
try:
|
60
|
+
_, columns_str = os.popen('stty size', 'r').read().split()
|
61
|
+
columns = int(columns_str)
|
62
|
+
except:
|
63
|
+
columns = 80 # default terminal size is 80 columns
|
64
|
+
else:
|
65
|
+
# macOS default terminal size is 80 columns
|
66
|
+
columns = 80
|
67
|
+
return columns
|
68
|
+
|
69
|
+
def __dropLongString(self, string: str) -> str:
|
70
|
+
"""
|
71
|
+
Drop the string if it's too long to fit in the terminal.
|
72
|
+
:param string: str, the input string.
|
73
|
+
:return: str, the shortened string, do not include newline char.
|
74
|
+
"""
|
75
|
+
if len(string) >= self.columns:
|
76
|
+
return f"{string[:self.columns-1]}"
|
77
|
+
else:
|
78
|
+
return f"{string}"
|
79
|
+
|
80
|
+
def getTitle(self) -> str:
|
81
|
+
return f" {self.data.title}\n"
|
82
|
+
|
83
|
+
def getLine(self) -> str:
|
84
|
+
return f" {'-'*len(self.data.title)}\n"
|
85
|
+
|
86
|
+
def getOS(self) -> str:
|
87
|
+
os_str = f" OS: {self.data.OS}"
|
88
|
+
return f"{self.__dropLongString(os_str)}\n"
|
89
|
+
|
90
|
+
def getHost(self) -> str:
|
91
|
+
host_str = f" Host: {self.data.Host}"
|
92
|
+
return f"{self.__dropLongString(host_str)}\n"
|
93
|
+
|
94
|
+
def getKernel(self) -> str:
|
95
|
+
kernel_str = f" Kernel: {self.data.Kernel}"
|
96
|
+
return f"{self.__dropLongString(kernel_str)}\n"
|
97
|
+
|
98
|
+
def getUptime(self) -> str:
|
99
|
+
uptime_str = f" Uptime: {self.data.Uptime}"
|
100
|
+
return f"{self.__dropLongString(uptime_str)}\n"
|
101
|
+
|
102
|
+
def getShell(self) -> str:
|
103
|
+
shell_str = f" Shell: {self.data.Shell}"
|
104
|
+
return f"{self.__dropLongString(shell_str)}\n"
|
105
|
+
|
106
|
+
def getCPU(self) -> str:
|
107
|
+
cpu_str = f" CPU: {self.data.CPU}"
|
108
|
+
return f"{self.__dropLongString(cpu_str)}\n"
|
109
|
+
|
110
|
+
def getGPU(self) -> str:
|
111
|
+
ret_str = ""
|
112
|
+
for gpu in self.data.GPU:
|
113
|
+
gpu_str = f" GPU: {gpu}"
|
114
|
+
ret_str += f"{self.__dropLongString(gpu_str)}\n"
|
115
|
+
return ret_str
|
116
|
+
|
117
|
+
def getMemory(self) -> str:
|
118
|
+
memory_str = f" Memory: {self.data.Memory}"
|
119
|
+
return f"{self.__dropLongString(memory_str)}\n"
|
120
|
+
|
121
|
+
def getNIC(self) -> str:
|
122
|
+
ret_str = ""
|
123
|
+
for nic in self.data.NIC:
|
124
|
+
nic_str = f" NIC: {nic}"
|
125
|
+
ret_str += f"{self.__dropLongString(nic_str)}\n"
|
126
|
+
return ret_str
|
127
|
+
|
128
|
+
def getNPU(self) -> str:
|
129
|
+
ret_str = ""
|
130
|
+
for npu in self.data.NPU:
|
131
|
+
npu_str = f" NPU: {npu}"
|
132
|
+
ret_str += f"{self.__dropLongString(npu_str)}\n"
|
133
|
+
return ret_str
|
134
|
+
|
135
|
+
|
40
136
|
def createDataString(data: Data):
|
137
|
+
data_string_processor = DataStringProcessor(data)
|
138
|
+
data_string = ""
|
139
|
+
data_string += data_string_processor.getTitle()
|
140
|
+
data_string += data_string_processor.getLine()
|
141
|
+
data_string += data_string_processor.getOS()
|
142
|
+
data_string += data_string_processor.getHost()
|
143
|
+
data_string += data_string_processor.getKernel()
|
144
|
+
data_string += data_string_processor.getUptime()
|
145
|
+
data_string += data_string_processor.getShell()
|
146
|
+
data_string += data_string_processor.getCPU()
|
147
|
+
data_string += data_string_processor.getGPU()
|
148
|
+
data_string += data_string_processor.getNPU()
|
149
|
+
data_string += data_string_processor.getMemory()
|
150
|
+
data_string += data_string_processor.getNIC()
|
151
|
+
return data_string
|
152
|
+
|
153
|
+
|
154
|
+
def createDataStringOld(data: Data):
|
41
155
|
data_string = ""
|
42
156
|
data_string += f" {data.title}\n"
|
43
157
|
data_string += f" {'-'*len(data.title)}\n"
|
@@ -50,9 +164,19 @@ def createDataString(data: Data):
|
|
50
164
|
for gpu in data.GPU:
|
51
165
|
data_string += f" GPU: {gpu}\n"
|
52
166
|
data_string += f" Memory: {data.Memory}\n"
|
167
|
+
for nic in data.NIC:
|
168
|
+
data_string += f" NIC: {nic}\n"
|
169
|
+
for npu in data.NPU:
|
170
|
+
data_string += f" NPU: {npu}\n"
|
53
171
|
return data_string
|
54
172
|
|
55
173
|
|
174
|
+
@dataclass
|
175
|
+
class SupportedOS:
|
176
|
+
ColorConfig = ["armbian", "arch", "alpine", "centos", "debian", "fedora", "macOS", "raspbian", "ubuntu", "freebsd"]
|
177
|
+
AsciiLogo = ["armbian", "arch", "alpine", "centos", "debian", "fedora", "macOS", "raspbian", "ubuntu", "freebsd"]
|
178
|
+
|
179
|
+
|
56
180
|
def selectOSLogo(os_id: str):
|
57
181
|
"""
|
58
182
|
Select the logo based on the os id and terminal size.
|
@@ -61,9 +185,18 @@ def selectOSLogo(os_id: str):
|
|
61
185
|
"""
|
62
186
|
if getOS() == "macos":
|
63
187
|
return os_id
|
64
|
-
|
65
|
-
|
66
|
-
|
188
|
+
if os_id in SupportedOS.ColorConfig and os_id in SupportedOS.AsciiLogo:
|
189
|
+
pass
|
190
|
+
else:
|
191
|
+
return "linux"
|
192
|
+
try:
|
193
|
+
rows_str, columns_str = os.popen('stty size', 'r').read().split()
|
194
|
+
rows = int(rows_str)
|
195
|
+
columns = int(columns_str)
|
196
|
+
except:
|
197
|
+
# Default terminal size is 24 rows and 80 columns
|
198
|
+
rows = 24
|
199
|
+
columns = 80
|
67
200
|
if columns <= 80:
|
68
201
|
if os_id in ["fedora", "ubuntu"]:
|
69
202
|
return f"{os_id}_small"
|
@@ -0,0 +1,135 @@
|
|
1
|
+
Metadata-Version: 2.2
|
2
|
+
Name: pyhw
|
3
|
+
Version: 0.7.4
|
4
|
+
Summary: PyHw, a neofetch-like command line tool for fetching system information but written mostly in python.
|
5
|
+
Author-email: Xiao Ran <xiaoran.007@icloud.com>
|
6
|
+
License: BSD-3-Clause
|
7
|
+
Project-URL: homepage, https://github.com/xiaoran007/pyhw
|
8
|
+
Keywords: neofetch,system information,command line tool,python,hardware information,fastfetch,fetching
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
11
|
+
Classifier: License :: OSI Approved :: BSD License
|
12
|
+
Classifier: Operating System :: OS Independent
|
13
|
+
Requires-Python: >=3.9
|
14
|
+
Description-Content-Type: text/markdown
|
15
|
+
License-File: LICENSE
|
16
|
+
Requires-Dist: pypci-ng>=0.0.10
|
17
|
+
|
18
|
+
# PyHw
|
19
|
+
[](https://pepy.tech/project/pyhw)
|
20
|
+

|
21
|
+
|
22
|
+

|
23
|
+

|
24
|
+

|
25
|
+
|
26
|
+

|
27
|
+

|
28
|
+
|
29
|
+
|
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.**
|
31
|
+
|
32
|
+
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
|
+
|
34
|
+
|
35
|
+
[//]: # ()
|
36
|
+
[//]: # ()
|
37
|
+

|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
## Install
|
43
|
+
There are already a lot of similar tools so you can choose any of them; they're all essentially no different. If you want to try this tool, just install it directly by pip.
|
44
|
+
```shell
|
45
|
+
pip install pyhw
|
46
|
+
```
|
47
|
+
To upgrade pyhw:
|
48
|
+
```shell
|
49
|
+
pip install pyhw -U
|
50
|
+
# or
|
51
|
+
pip install pyhw --upgrade
|
52
|
+
```
|
53
|
+
You can then use this tool directly from the command line with the following command, just like neofetch.
|
54
|
+
```shell
|
55
|
+
pyhw
|
56
|
+
# or
|
57
|
+
python -m pyhw
|
58
|
+
```
|
59
|
+
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__.
|
60
|
+
|
61
|
+
### Install by pipx
|
62
|
+
**pipx** is an amazing tool to help you install and run applications written in Python. It is more like **brew** or **apt**. You can find more information about it here [pipx](https://github.com/pypa/pipx).
|
63
|
+
|
64
|
+
You can install pyhw by the following command:
|
65
|
+
```shell
|
66
|
+
pipx install pyhw
|
67
|
+
```
|
68
|
+
You can then use this tool directly from the command line with the following command, just like neofetch.
|
69
|
+
```shell
|
70
|
+
pyhw
|
71
|
+
```
|
72
|
+
|
73
|
+
### Important note about debian 12:
|
74
|
+
If you use system pip to install pyhw, you will encounter this problem on debian12 and some related distributions (like Ubuntu 24.04):
|
75
|
+
```text
|
76
|
+
error: externally-managed-environment
|
77
|
+
|
78
|
+
× This environment is externally managed
|
79
|
+
╰─> To install Python packages system-wide, try apt install
|
80
|
+
python3-xyz, where xyz is the package you are trying to
|
81
|
+
install.
|
82
|
+
|
83
|
+
If you wish to install a non-Debian-packaged Python package,
|
84
|
+
create a virtual environment using python3 -m venv path/to/venv.
|
85
|
+
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
|
86
|
+
sure you have python3-full installed.
|
87
|
+
|
88
|
+
For more information visit http://rptl.io/venv
|
89
|
+
|
90
|
+
note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
|
91
|
+
hint: See PEP 668 for the detailed specification.
|
92
|
+
```
|
93
|
+
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).
|
94
|
+
|
95
|
+
## Tested OS
|
96
|
+
* macOS arm64, x86_64
|
97
|
+
* Linux arm64, x86_64
|
98
|
+
* FreeBSD arm64
|
99
|
+
|
100
|
+
## Add Logo
|
101
|
+
1. Create a file named **\<os>.pyhw** in **logo/ascii** folder
|
102
|
+
2. Modify **colorConfig.py** file to add a new logo style
|
103
|
+
3. Update **pyhwUtil.py** to enable new logo style.
|
104
|
+
|
105
|
+
## Build from source
|
106
|
+
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.
|
107
|
+
|
108
|
+
### Dependencies
|
109
|
+
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).
|
110
|
+
|
111
|
+
### Build tools
|
112
|
+
Make sure the following Python build tools are already installed.
|
113
|
+
* setuptools
|
114
|
+
* build
|
115
|
+
* twine
|
116
|
+
|
117
|
+
### Build package
|
118
|
+
clone the project, and run:
|
119
|
+
```shell
|
120
|
+
python -m build
|
121
|
+
```
|
122
|
+
After the build process, the source package and the binary whl package can be found in the dist folder. Then you can use the following command to install the new package.
|
123
|
+
```shell
|
124
|
+
pip install dist/*.whl --force-reinstall
|
125
|
+
```
|
126
|
+
Or simply type:
|
127
|
+
```shell
|
128
|
+
make build
|
129
|
+
make install
|
130
|
+
```
|
131
|
+
If you have docker installed, you can test this package through docker by type:
|
132
|
+
```shell
|
133
|
+
make test # local build
|
134
|
+
make test-pypi # release version
|
135
|
+
```
|
@@ -0,0 +1,99 @@
|
|
1
|
+
pyhw/__init__.py,sha256=lBlBxbnftiADKPpC3XRA3jUPjRsVclCd3P95aQ33p_g,22
|
2
|
+
pyhw/__main__.py,sha256=A0t0jkcwdTXd6ca7POUfm8krjCn2FQaXTIss5gNmNcI,1775
|
3
|
+
pyhw/backend/__init__.py,sha256=knn_3Yroow1h0dqdrozk3zyy3vz-kQyNBRjR6OLmVoY,50
|
4
|
+
pyhw/backend/backendBase.py,sha256=mloo8mPEbgbIdmyQ3I4vdEXMSSjxWi_wnwACmzvHbEo,506
|
5
|
+
pyhw/backend/cpu/__init__.py,sha256=5YfANJVRwNwTRodG0ENOgusrdN592aaSnfq5ok4dKTo,56
|
6
|
+
pyhw/backend/cpu/bsd.py,sha256=Ls97NAsvZGVJj3_fBUcYXjY2gsZvFKhXYtkTHxVVXSs,288
|
7
|
+
pyhw/backend/cpu/cpuBase.py,sha256=u9kQORv8RJ9BLjG219wNTgBAivHy_lUll4Bkk6TBlXY,576
|
8
|
+
pyhw/backend/cpu/cpuInfo.py,sha256=A_nNGElq9W7oZ5DFJowLdFBE0ZvXKr5h29E6TGAvbRc,251
|
9
|
+
pyhw/backend/cpu/linux.py,sha256=zJ2cOwQHtolJrMMY1WXVbLLIRNPxeClUgzLAAkd7As4,3346
|
10
|
+
pyhw/backend/cpu/macos.py,sha256=pacU-yT7q-HKerkh2Q0BSdzSY6dKzHfSnRZBmimqqXk,2953
|
11
|
+
pyhw/backend/gpu/__init__.py,sha256=EpMjPvUaXt0LTNMvGmB8WgXbUB9keCxuOhu8NT3Re6o,56
|
12
|
+
pyhw/backend/gpu/bsd.py,sha256=hNFiCek770CXOh3DK3I3-g272-a1S5D7LolGJBsLXaU,124
|
13
|
+
pyhw/backend/gpu/gpuBase.py,sha256=DyY1bVrsaWczkbrrN6J7kG-Kh9yic3Lqww8yLZNCet8,521
|
14
|
+
pyhw/backend/gpu/gpuInfo.py,sha256=d_z_z5DiZAg85wP0VOBQEU0QHdaK3qFqA2Tp9Eq8-Zs,133
|
15
|
+
pyhw/backend/gpu/linux.py,sha256=E-evoL-spQbHB8JvbZXSq5ypc2SeePVUPnhEQrSPQpg,1619
|
16
|
+
pyhw/backend/gpu/macos.py,sha256=SmTqqTrIMRW-GVPmDs8xAiOX7HsCjrGh9qkxLQCdvO8,3850
|
17
|
+
pyhw/backend/host/__init__.py,sha256=Efaj7-Oya7H8HdpZHQCLrwn-mcfPb-d6yfh4dzsE_7I,58
|
18
|
+
pyhw/backend/host/bsd.py,sha256=9gKnM6yysHBKwS3EQvb0pCeylh3dzHvoEuPe14zo9wQ,382
|
19
|
+
pyhw/backend/host/hostBase.py,sha256=Dt3zZjkL6iUM9eOKkPUBAZ_2Lx-GQSIjsQhkLmjCUAk,678
|
20
|
+
pyhw/backend/host/hostInfo.py,sha256=Xvz0LugPiCSWMkcDsp4p2rrojYFZauL6Q-gCZ6NLz5k,184
|
21
|
+
pyhw/backend/host/linux.py,sha256=vGIl1b61vB-uilPk6awPOIWRaxnIsR43L20sNHeM5bI,2824
|
22
|
+
pyhw/backend/host/macos.py,sha256=KW-EJK9g1xHNrFsVxJv5GPLpc_ZevX0Zv1WjZUzRkzo,15369
|
23
|
+
pyhw/backend/host/windows.py,sha256=rjDJaIs-5zspzFsNCMCh6m2yZXEXI0vccqeBpmAdEBk,53
|
24
|
+
pyhw/backend/kernel/__init__.py,sha256=fGjwjpOhwA_PnsWbwoq102hwhTay2ufYKaTqxjSV2-I,65
|
25
|
+
pyhw/backend/kernel/kernelBase.py,sha256=ZUj5wqar9mLUlIYrTDzyCWjrwzGtP6WJIIAXy5v1zhM,490
|
26
|
+
pyhw/backend/kernel/kernelInfo.py,sha256=QQYni0IVeFZ2IVNDC06U728Q01Rq3R6qRDYCxMjtJrY,189
|
27
|
+
pyhw/backend/kernel/unix.py,sha256=XDV2GIjamERcmlrQFaKFZY-OJO1xj76Im_7lmg2uFzo,1192
|
28
|
+
pyhw/backend/kernel/windows.py,sha256=lxZ7T9Ea0Qbq3pf_TjSAHSM2YTozC6ivv7dKdLOTl3s,58
|
29
|
+
pyhw/backend/memory/__init__.py,sha256=zGBWxfPAAk8ivCBWPLJIpuD-lB7wUJT3x8u2jHiAoCY,65
|
30
|
+
pyhw/backend/memory/bsd.py,sha256=GKTCs6RocdoWj-5ZZRMB4xAWGWljor6leuwX-L-7bW0,251
|
31
|
+
pyhw/backend/memory/linux.py,sha256=kxP0LxXdTWYRtu9nDyKqZeIzZrQI84kVOPMeN1GwSOo,917
|
32
|
+
pyhw/backend/memory/macos.py,sha256=ur2HxmmmVkXmaxEcw_otphifVp_csfNMJdgt-idCq7M,2770
|
33
|
+
pyhw/backend/memory/memoryBase.py,sha256=wl6zN3-U_jRNsaWM9szWPvWjiq3Ca8Rcm-aMRdAJge8,554
|
34
|
+
pyhw/backend/memory/memoryInfo.py,sha256=OQF165uEyuapAsi7cKacQYDRnKdrQHeldfyFwzS9N2g,186
|
35
|
+
pyhw/backend/metal/t.py,sha256=52yv-JoXNfaIOfcxEEidIg0MoyFtzWvTRm550kQKPZA,391
|
36
|
+
pyhw/backend/nic/__init__.py,sha256=eP4eOYIvMF3LcTf954hJa6TnB8R4Qahss2g-UcgypKY,57
|
37
|
+
pyhw/backend/nic/bsd.py,sha256=lIXnPqzSA2qexUt0P9OHMmxoI5c5XBi2V80RY9S0wsM,135
|
38
|
+
pyhw/backend/nic/linux.py,sha256=3H91Nw87frzZA4P6Q5GbjHSaI7q4Q5-v6R8BgdvplgQ,1976
|
39
|
+
pyhw/backend/nic/macos.py,sha256=63gZjSmUGwGqfs41IWrEXmSz9O8eQy4G5oql3JLZmoo,855
|
40
|
+
pyhw/backend/nic/nicBase.py,sha256=cT_rxqIEcvvKFsvjKlkCJ8RIfp7QHxDE9_SImXDae0s,735
|
41
|
+
pyhw/backend/nic/nicInfo.py,sha256=wuBuL-aIzD441IUDPGz5e0xctcZ-opdpgqkVxgbvZLg,133
|
42
|
+
pyhw/backend/npu/__init__.py,sha256=PgLKbwpgT5vw9xpa294Zxb94McyxNXW46_vMbT2Iqyc,58
|
43
|
+
pyhw/backend/npu/bsd.py,sha256=eKkOWZ4MBybR_KOGGcsWUpzCGgghhvuBy5VNsnEE8cI,134
|
44
|
+
pyhw/backend/npu/linux.py,sha256=mXHSYRION3pghwk6_4vgHxjSkNxI68ksGLkFZstR0mc,1192
|
45
|
+
pyhw/backend/npu/macos.py,sha256=c-iSmGfBWYeoh7nXuCFmPlVH6bc6sil_yRsAlabl93k,2513
|
46
|
+
pyhw/backend/npu/npuBase.py,sha256=qiioBmHDeh2Et1F7lwmNight-2W32C0VmMtx2DIOCz4,523
|
47
|
+
pyhw/backend/npu/npuInfo.py,sha256=82dK6XvW_XKw4O5-RfR4-qQRR7Plh8qqJLj0YDzISmU,135
|
48
|
+
pyhw/backend/os/__init__.py,sha256=rPHQYdQK3qU6ZwwodqVoEWeqBnKffXlJyi4k3-8ViPY,53
|
49
|
+
pyhw/backend/os/bsd.py,sha256=5Q30mkFKdhuup1dRjTEVN58MEGcj7JzbUzh40ld6C14,131
|
50
|
+
pyhw/backend/os/linux.py,sha256=U7dIOKZaG5MSw0S65hAfDfFaBMvbwSCHFIHTwckU9iI,1957
|
51
|
+
pyhw/backend/os/macos.py,sha256=DwgpwRD1a2oTANR_XL3kkMzNawqrt23F79dqBw3ULK8,1906
|
52
|
+
pyhw/backend/os/osBase.py,sha256=IiyrA5IEtlcaR-xigi8SxD70BimFKCBMjgF0MLihSOk,573
|
53
|
+
pyhw/backend/os/osInfo.py,sha256=iLPc7INFHH3izascwooj4JBVgvBsSgVPXWBlFXG47mQ,378
|
54
|
+
pyhw/backend/shell/__init__.py,sha256=SeQ7OLNSl_V1JCCWnJGjLilAWiSe9e5kgsMEt63TMS0,62
|
55
|
+
pyhw/backend/shell/shellBase.py,sha256=U4HPg_iWhAqaLceBnEVMHFj4A-FNYu7JjsQyi2seEU4,377
|
56
|
+
pyhw/backend/shell/unix.py,sha256=Vt2wSxAIrzN679v0MjJwBoK6L12OqZOichociFZ9lw8,2109
|
57
|
+
pyhw/backend/title/__init__.py,sha256=l6_WqreSBeK7krapCrbrr4ndnydrXB1aZ50Ve-beV_w,62
|
58
|
+
pyhw/backend/title/titleBase.py,sha256=nzHcVJqAMZqWJP101YWgRwilSiZ_hHiK-jiI90Pm3r8,495
|
59
|
+
pyhw/backend/title/unix.py,sha256=9B-zLE8yhlWBnJ-6Aa-DmFmgMV9KdvvNU40drJIaNck,837
|
60
|
+
pyhw/backend/title/windows.py,sha256=5bXR6yxHk3diVx92sjxPeD6fUVR5sKZJG3K4aM3CGn8,82
|
61
|
+
pyhw/backend/uptime/__init__.py,sha256=X8RVhHWmHpyey0C4gcmrt_u1cHKowhAQRDMAxY3i7p0,65
|
62
|
+
pyhw/backend/uptime/bsd.py,sha256=XdLIvivr78Pr8PqSwQG3eLvjjaM52nK5QcWrwtuNZlg,147
|
63
|
+
pyhw/backend/uptime/linux.py,sha256=Sh05CgUjAOzPM8LSoZf4fCU-Cl5pwhSJSC7XJ-jFaHU,1027
|
64
|
+
pyhw/backend/uptime/macos.py,sha256=Io-JrFjmRWHgB7uh4mBTV4rnfJuUvepGh2uiKNhUZcc,1293
|
65
|
+
pyhw/backend/uptime/uptimeBase.py,sha256=PB0SWpsZyNz5GL5n39rC7DDSpKVAlH2K2eKqOuiEfy0,778
|
66
|
+
pyhw/backend/uptime/uptimeInfo.py,sha256=TobPEV3MBT3Fiv3W6TOzD3a4MNW-vz2Oi_Trlcihu7k,114
|
67
|
+
pyhw/frontend/__init__.py,sha256=xgv_iVv9w4cLXklbdtFWXu7J7KJxBCUw-ZcUQb_abFc,57
|
68
|
+
pyhw/frontend/frontendBase.py,sha256=rPAf7tE1u8uGgZ-mDTOw_O2S2-YsevEzGJsq34eJlXQ,4957
|
69
|
+
pyhw/frontend/color/__init__.py,sha256=xk511qWwdYWEVjk_zOaC4fs81HtwR4ELr3wi1tTL824,191
|
70
|
+
pyhw/frontend/color/colorConfig.py,sha256=6VADbaM_xwlYF4Ds38xvmRgxVSDWBB71WWDFhiLrQaI,4650
|
71
|
+
pyhw/frontend/color/colorSet.py,sha256=spH8PlRu7capouf-yUgDHgoPCnM5aJ_ncascISZfz2g,1421
|
72
|
+
pyhw/frontend/color/colorUtil.py,sha256=VhcPmAJmXGIiRBfVZE2jg_iy-SfbxqwOSvkRz-nbUOQ,94
|
73
|
+
pyhw/frontend/logo/__init__.py,sha256=mozEarHueBUgtDHKSd-RDaFysMLUiW3VQ8KcBtlKGCI,47
|
74
|
+
pyhw/frontend/logo/logoBase.py,sha256=NjRCg0CXjmW4_7UZp2ZBgy2PZOAqaR6SYHg9zd90kRo,634
|
75
|
+
pyhw/frontend/logo/ascii/alpine.pyhw,sha256=uolPBXOkWOtBDmfzTSD9NZLaJN-qGFymIn_NQQbzl_U,65
|
76
|
+
pyhw/frontend/logo/ascii/arch.pyhw,sha256=tnDJqb0-cUw6EujObkjhRTtTlD51pTSEYJwowbhEvKE,1078
|
77
|
+
pyhw/frontend/logo/ascii/armbian.pyhw,sha256=Cg8tFIMdHdHLMlQrKm902C4OStKKHnCkDykNxbaSpfA,773
|
78
|
+
pyhw/frontend/logo/ascii/centos.pyhw,sha256=t-pFKQslIAKN4Jl1ilKLzB79BHSi0_zaJUDGQYAVqc8,658
|
79
|
+
pyhw/frontend/logo/ascii/debian.pyhw,sha256=ZmO1fg3Uc_ofF-CZSOP0Qo298luDASh2Zt50UmY6DBQ,437
|
80
|
+
pyhw/frontend/logo/ascii/fedora.pyhw,sha256=IuFE6BByaNfVgn1pn7rKH7QVlIJyEmgGopCAOpXa6oM,742
|
81
|
+
pyhw/frontend/logo/ascii/fedora_small.pyhw,sha256=_LSBzuCJjMa8pzmiJ3KN7Ndi-TryYPmtEfKqxxPAFfE,601
|
82
|
+
pyhw/frontend/logo/ascii/freebsd.pyhw,sha256=Socjz8LCxWDpIaFjfISHX5TjlmWLtXTYqci6-m6hzJY,514
|
83
|
+
pyhw/frontend/logo/ascii/linux.pyhw,sha256=IMe6YNElwCjLtv6kgSkERbATyyJAK531vcrT-otaLWE,300
|
84
|
+
pyhw/frontend/logo/ascii/macOS.pyhw,sha256=HBGROtBb7wrNtRqAQ9ND7zxK0l17BRsmpgc2dMo_m6s,474
|
85
|
+
pyhw/frontend/logo/ascii/raspbian.pyhw,sha256=jEl6WMKF-FGx359ipQ1kzweUJS-NuauYQCFaYime4PQ,159
|
86
|
+
pyhw/frontend/logo/ascii/ubuntu.pyhw,sha256=l-Q0PfutxXYMwTojqeiM88063x4V0RBkZUHmi6YdsNc,833
|
87
|
+
pyhw/frontend/logo/ascii/ubuntu_small.pyhw,sha256=Xf8LSZdZUu9aEG3efhb1FUlUEuJ-3UztcIOJISpKhPw,229
|
88
|
+
pyhw/library/lib/iokitGPULib.dylib,sha256=DcJ0GZY79gTFckLFYtZgeKn1T0NFvdO_k_ccCa7od5Y,154808
|
89
|
+
pyhw/pyhwException/__init__.py,sha256=8JsFvtF13g0Y5t4z9fRndDXtfCzuBM59jDf6PhWSFSk,220
|
90
|
+
pyhw/pyhwException/pyhwException.py,sha256=wxuzFQa9g7XB1q9TUKO_55lw7wMEJMpzG8w1GVTFVa0,197
|
91
|
+
pyhw/pyhwUtil/__init__.py,sha256=diIqlNUBfuHu-2VAOJk5nipGLafnWxR3chAAOmX8QRo,250
|
92
|
+
pyhw/pyhwUtil/pyhwUtil.py,sha256=6aKYh7sEPkqrfevckJO7MGmehGwgu_QVniFjVOw4dYk,6297
|
93
|
+
pyhw/pyhwUtil/sysctlUtil.py,sha256=S-rUvqi7ZrMyMouIhxlyHEQ4agM7sCT1Y7uzs3Hu5-o,841
|
94
|
+
pyhw-0.7.4.dist-info/LICENSE,sha256=hJs6RBqSVCexbTsalkMLNFI5t06kekQEsSVaOt_-yLs,1497
|
95
|
+
pyhw-0.7.4.dist-info/METADATA,sha256=uRpLICG3Fl7YN7ofwJBnoD38B_D9T2_jE7yxN6Ive7M,5791
|
96
|
+
pyhw-0.7.4.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
97
|
+
pyhw-0.7.4.dist-info/entry_points.txt,sha256=q-AB8im_QahpmNrmy4aPTJRGi0LlbNlnI3kF7s6pKss,44
|
98
|
+
pyhw-0.7.4.dist-info/top_level.txt,sha256=7Inxvxt1TngEricKZEex9_WJZS3DbKYFUXDz4v5WHYU,5
|
99
|
+
pyhw-0.7.4.dist-info/RECORD,,
|
pyhw/macos.py
DELETED
@@ -1,146 +0,0 @@
|
|
1
|
-
import subprocess
|
2
|
-
import json
|
3
|
-
import platform
|
4
|
-
from pyhwException import GPUNotFoundException, BackendException
|
5
|
-
|
6
|
-
|
7
|
-
class GPUInfo:
|
8
|
-
def __init__(self, verbose=False):
|
9
|
-
self._gpus = list()
|
10
|
-
self._verbose = verbose
|
11
|
-
|
12
|
-
def init(self):
|
13
|
-
pass
|
14
|
-
|
15
|
-
def _get_gpu_info(self):
|
16
|
-
try:
|
17
|
-
gpus = json.loads(subprocess.check_output(["system_profiler", "SPDisplaysDataType", "-json"])).get('SPDisplaysDataType')
|
18
|
-
if gpus is not None:
|
19
|
-
if self._verbose:
|
20
|
-
print(f"Detected {len(gpus)} GPU(s).")
|
21
|
-
else:
|
22
|
-
raise GPUNotFoundException("No GPU information found.")
|
23
|
-
except Exception as e:
|
24
|
-
raise BackendException(f"An error occurred while getting GPU info: {e}")
|
25
|
-
|
26
|
-
gpu_info_list = list()
|
27
|
-
|
28
|
-
for i in range(len(gpus)):
|
29
|
-
gpu = gpus[i]
|
30
|
-
info = dict()
|
31
|
-
info["name"] = gpu.get("sppci_model")
|
32
|
-
if gpu.get("spdisplays_vendor") == "sppci_vendor_Apple":
|
33
|
-
info["vram"] = f"{get_mem_info()} (shared memory)"
|
34
|
-
else:
|
35
|
-
info["vram"] = gpu.get("spdisplays_vram")
|
36
|
-
info["vendor"] = gpu.get("spdisplays_vendor")
|
37
|
-
info["cores"] = gpu.get("sppci_cores")
|
38
|
-
info["metal"] = gpu.get("spdisplays_mtlgpufamilysupport")
|
39
|
-
info["bus"] = gpu.get("sppci_bus")
|
40
|
-
info["link"] = gpu.get("spdisplays_pcie_width")
|
41
|
-
gpu_info_list.append(info)
|
42
|
-
|
43
|
-
@staticmethod
|
44
|
-
def _handleVendor(vendor):
|
45
|
-
if vendor == "sppci_vendor_Apple":
|
46
|
-
return "Apple"
|
47
|
-
elif vendor == "sppci_vendor_intel":
|
48
|
-
return "Intel"
|
49
|
-
elif vendor == "sppci_vendor_amd":
|
50
|
-
return "AMD"
|
51
|
-
else:
|
52
|
-
return vendor
|
53
|
-
|
54
|
-
@staticmethod
|
55
|
-
def _handleVram(vram, vendor):
|
56
|
-
if vendor == "Apple":
|
57
|
-
return f"{get_mem_info()} (shared memory)"
|
58
|
-
else:
|
59
|
-
return vram
|
60
|
-
|
61
|
-
@staticmethod
|
62
|
-
def _getVramApple():
|
63
|
-
try:
|
64
|
-
return json.loads(subprocess.check_output(["system_profiler", "SPHardwareDataType", "-json"]))["SPHardwareDataType"][0]["physical_memory"]
|
65
|
-
except Exception as e:
|
66
|
-
raise BackendException(f"An error occurred while getting memory info: {e}")
|
67
|
-
|
68
|
-
|
69
|
-
class GPU:
|
70
|
-
def __init__(self):
|
71
|
-
self._name = str()
|
72
|
-
self._vram = str()
|
73
|
-
self._vendor = str()
|
74
|
-
self._cores = str()
|
75
|
-
self._metal = str()
|
76
|
-
self._bus = str()
|
77
|
-
self._bus_width = str()
|
78
|
-
self._id = int()
|
79
|
-
|
80
|
-
def init(self):
|
81
|
-
pass
|
82
|
-
|
83
|
-
def _get_gpu_info(self):
|
84
|
-
pass
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
def get_mem_info():
|
90
|
-
try:
|
91
|
-
mem_info_dict = json.loads(subprocess.check_output(["system_profiler", "SPHardwareDataType", "-json"]))
|
92
|
-
mem_info = mem_info_dict["SPHardwareDataType"][0]["physical_memory"]
|
93
|
-
return mem_info
|
94
|
-
except Exception as e:
|
95
|
-
print(f"An error occurred while getting memory info: {e}")
|
96
|
-
exit(-1)
|
97
|
-
|
98
|
-
|
99
|
-
def get_gpu_info():
|
100
|
-
gpus = list()
|
101
|
-
try:
|
102
|
-
gpu_info_dict = json.loads(subprocess.check_output(["system_profiler", "SPDisplaysDataType", "-json"]))
|
103
|
-
if 'SPDisplaysDataType' in gpu_info_dict:
|
104
|
-
gpus = gpu_info_dict['SPDisplaysDataType']
|
105
|
-
print(f"Detected {len(gpus)} GPU(s).")
|
106
|
-
else:
|
107
|
-
print("No GPU information found.")
|
108
|
-
except Exception as e:
|
109
|
-
print(f"An error occurred while getting GPU info: {e}")
|
110
|
-
exit(-1)
|
111
|
-
|
112
|
-
gpu_info_list = list()
|
113
|
-
|
114
|
-
for i in range(len(gpus)):
|
115
|
-
gpu = gpus[i]
|
116
|
-
info = dict()
|
117
|
-
info["name"] = gpu.get("sppci_model")
|
118
|
-
if gpu.get("spdisplays_vendor") == "sppci_vendor_Apple":
|
119
|
-
info["vram"] = f"{get_mem_info()} (shared memory)"
|
120
|
-
else:
|
121
|
-
info["vram"] = gpu.get("spdisplays_vram")
|
122
|
-
info["vendor"] = gpu.get("spdisplays_vendor")
|
123
|
-
info["cores"] = gpu.get("sppci_cores")
|
124
|
-
info["metal"] = gpu.get("spdisplays_mtlgpufamilysupport")
|
125
|
-
info["bus"] = gpu.get("sppci_bus")
|
126
|
-
info["link"] = gpu.get("spdisplays_pcie_width")
|
127
|
-
gpu_info_list.append(info)
|
128
|
-
return gpu_info_list
|
129
|
-
|
130
|
-
|
131
|
-
if __name__ == "__main__":
|
132
|
-
li = get_gpu_info()
|
133
|
-
for i in range(len(li)):
|
134
|
-
info = li[i]
|
135
|
-
print('----------')
|
136
|
-
print(f"GPU {i}:")
|
137
|
-
print(f'name: {info["name"]}')
|
138
|
-
print(f'vram: {info["vram"]}')
|
139
|
-
print(f'vendor: {info["vendor"]}')
|
140
|
-
print(f'cores: {info["cores"]}')
|
141
|
-
print(f'metal: {info["metal"]}')
|
142
|
-
print(f'bus: {info["bus"]}')
|
143
|
-
print(f'link: {info["link"]}')
|
144
|
-
|
145
|
-
print('----------')
|
146
|
-
|
pyhw-0.2.0b0.dist-info/METADATA
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.1
|
2
|
-
Name: pyhw
|
3
|
-
Version: 0.2.0b0
|
4
|
-
Summary: PyHw, a neofetch-like command line tool for fetching system information but written mostly in python.
|
5
|
-
Author-email: Xiao Ran <xiaoran.007@icloud.com>
|
6
|
-
License: BSD-3-Clause
|
7
|
-
Project-URL: homepage, https://github.com/xiaoran007/pyhw
|
8
|
-
Classifier: Programming Language :: Python :: 3
|
9
|
-
Classifier: License :: OSI Approved :: BSD License
|
10
|
-
Classifier: Operating System :: OS Independent
|
11
|
-
Requires-Python: >=3.9
|
12
|
-
Description-Content-Type: text/markdown
|
13
|
-
License-File: LICENSE
|
14
|
-
|
15
|
-
# PyHw
|
16
|
-

|
17
|
-

|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
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 part of the linux systems and macOS are supported.**
|
22
|
-
|
23
|
-
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 🤔)
|
24
|
-
|
25
|
-
There are already a lot of similar tools so you can choose any of them; they're all essentially no different. If you want to try this tool, just install it directly by pip.
|
26
|
-
```shell
|
27
|
-
pip install pyhw
|
28
|
-
```
|
29
|
-
You can then use this tool directly from the command line with the following command, just like neofetch.
|
30
|
-
```shell
|
31
|
-
pyhw
|
32
|
-
```
|
33
|
-
|
34
|
-
## Build from source
|
35
|
-
### Build tools
|
36
|
-
Make sure the following Python build tools are already installed.
|
37
|
-
* setuptools
|
38
|
-
* build
|
39
|
-
* twine
|
40
|
-
|
41
|
-
### Build package
|
42
|
-
clone the project, and run:
|
43
|
-
```shell
|
44
|
-
python -m build
|
45
|
-
```
|
46
|
-
or you can use the old setup.py style command:
|
47
|
-
```shell
|
48
|
-
python setup.py sdist bdist_wheel
|
49
|
-
```
|
50
|
-
After the build process, the source package and the binary whl package can be found in the dist folder.
|