pyhw 0.6.4__py3-none-any.whl → 0.6.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyhw/backend/cpu/macos.py +3 -1
- pyhw/backend/host/linux.py +10 -2
- pyhw/frontend/frontendBase.py +32 -0
- pyhw/library/lib/iokitGPULib.dylib +0 -0
- pyhw/pyhwUtil/pyhwUtil.py +100 -0
- {pyhw-0.6.4.dist-info → pyhw-0.6.6.dist-info}/METADATA +14 -2
- {pyhw-0.6.4.dist-info → pyhw-0.6.6.dist-info}/RECORD +11 -11
- {pyhw-0.6.4.dist-info → pyhw-0.6.6.dist-info}/WHEEL +1 -1
- {pyhw-0.6.4.dist-info → pyhw-0.6.6.dist-info}/LICENSE +0 -0
- {pyhw-0.6.4.dist-info → pyhw-0.6.6.dist-info}/entry_points.txt +0 -0
- {pyhw-0.6.4.dist-info → pyhw-0.6.6.dist-info}/top_level.txt +0 -0
pyhw/backend/cpu/macos.py
CHANGED
@@ -64,6 +64,8 @@ class CPUDetectMacOS:
|
|
64
64
|
"Apple M3": "4.05 GHz",
|
65
65
|
"Apple M3 Pro": "4.05 GHz",
|
66
66
|
"Apple M3 Max": "4.05 GHz",
|
67
|
-
"Apple M4": "4.40 GHz"
|
67
|
+
"Apple M4": "4.40 GHz",
|
68
|
+
"Apple M4 Pro": "4.40 GHz",
|
69
|
+
"Apple M4 Max": "4.40 GHz"
|
68
70
|
}
|
69
71
|
self.__cpuInfo.frequency = freq.get(self.__cpuInfo.model, "Unknown")
|
pyhw/backend/host/linux.py
CHANGED
@@ -19,9 +19,17 @@ class HostDetectLinux:
|
|
19
19
|
if self.__arch in ["x86_64", "x86"]:
|
20
20
|
try:
|
21
21
|
with open("/sys/devices/virtual/dmi/id/product_name", "r") as f:
|
22
|
-
|
22
|
+
product_name = f.read().strip()
|
23
|
+
if product_name.startswith("To be filled by O.E.M."):
|
24
|
+
self.__hostInfo.name = f"General {self.__arch} Host"
|
25
|
+
else:
|
26
|
+
self.__hostInfo.name = product_name
|
23
27
|
with open("/sys/devices/virtual/dmi/id/product_version", "r") as f:
|
24
|
-
|
28
|
+
version = f.read().strip()
|
29
|
+
if version.startswith("To be filled by O.E.M."):
|
30
|
+
self.__hostInfo.version = ""
|
31
|
+
else:
|
32
|
+
self.__hostInfo.version = version
|
25
33
|
self.__hostInfo.model = self.__hostInfo.name + " " + self.__hostInfo.version
|
26
34
|
except FileNotFoundError:
|
27
35
|
pass
|
pyhw/frontend/frontendBase.py
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
from .logo import Logo
|
2
2
|
from .color import ColorConfigSet, colorPrefix, colorSuffix, ColorSet
|
3
|
+
from ..pyhwUtil import getOS
|
4
|
+
import os
|
3
5
|
import re
|
4
6
|
|
5
7
|
|
@@ -16,6 +18,7 @@ class Printer:
|
|
16
18
|
self.__combined_lines = []
|
17
19
|
self.__logo_color_indexes = {}
|
18
20
|
self.__reg = r'\$(\d)'
|
21
|
+
self.__columns = self.__getColumns()
|
19
22
|
|
20
23
|
def cPrint(self):
|
21
24
|
self.__LogoPreprocess()
|
@@ -31,8 +34,37 @@ class Printer:
|
|
31
34
|
for data_line in self.__processed_data_lines[len(self.__processed_logo_lines):]:
|
32
35
|
self.__combined_lines.append(" " * (max_len_logo + 1) + data_line)
|
33
36
|
|
37
|
+
self.__dropLongString()
|
38
|
+
|
34
39
|
print("\n".join(self.__combined_lines))
|
35
40
|
|
41
|
+
def __dropLongString(self):
|
42
|
+
# Need more accurate way to drop long strings
|
43
|
+
if getOS() == "linux":
|
44
|
+
fixed_lines = list()
|
45
|
+
for line in self.__combined_lines:
|
46
|
+
if len(line) > self.__columns+20:
|
47
|
+
fixed_lines.append(line[:self.__columns+20])
|
48
|
+
else:
|
49
|
+
fixed_lines.append(line)
|
50
|
+
self.__combined_lines = fixed_lines
|
51
|
+
else:
|
52
|
+
pass
|
53
|
+
|
54
|
+
|
55
|
+
@staticmethod
|
56
|
+
def __getColumns() -> int:
|
57
|
+
if getOS() == "linux":
|
58
|
+
try:
|
59
|
+
_, columns_str = os.popen('stty size', 'r').read().split()
|
60
|
+
columns = int(columns_str)
|
61
|
+
except:
|
62
|
+
columns = 80 # default terminal size is 80 columns
|
63
|
+
else:
|
64
|
+
# macOS default terminal size is 80 columns
|
65
|
+
columns = 80
|
66
|
+
return columns
|
67
|
+
|
36
68
|
def __LogoPreprocess(self):
|
37
69
|
global_color = self.__config.get("colors")[0]
|
38
70
|
for logo_line in self.__logo_lines:
|
Binary file
|
pyhw/pyhwUtil/pyhwUtil.py
CHANGED
@@ -38,7 +38,107 @@ def getArch():
|
|
38
38
|
return "unknown"
|
39
39
|
|
40
40
|
|
41
|
+
class DataStringProcessor:
|
42
|
+
def __init__(self, data: Data):
|
43
|
+
self.data = data
|
44
|
+
self.columns = self.__getENV()
|
45
|
+
|
46
|
+
@staticmethod
|
47
|
+
def __getENV() -> int:
|
48
|
+
if getOS() == "linux":
|
49
|
+
_, columns_str = os.popen('stty size', 'r').read().split()
|
50
|
+
columns = int(columns_str)
|
51
|
+
else:
|
52
|
+
# macOS default terminal size is 80 columns
|
53
|
+
columns = 80
|
54
|
+
return columns
|
55
|
+
|
56
|
+
def __dropLongString(self, string: str) -> str:
|
57
|
+
"""
|
58
|
+
Drop the string if it's too long to fit in the terminal.
|
59
|
+
:param string: str, the input string.
|
60
|
+
:return: str, the shortened string, do not include newline char.
|
61
|
+
"""
|
62
|
+
if len(string) >= self.columns:
|
63
|
+
return f"{string[:self.columns-1]}"
|
64
|
+
else:
|
65
|
+
return f"{string}"
|
66
|
+
|
67
|
+
def getTitle(self) -> str:
|
68
|
+
return f" {self.data.title}\n"
|
69
|
+
|
70
|
+
def getLine(self) -> str:
|
71
|
+
return f" {'-'*len(self.data.title)}\n"
|
72
|
+
|
73
|
+
def getOS(self) -> str:
|
74
|
+
os_str = f" OS: {self.data.OS}"
|
75
|
+
return f"{self.__dropLongString(os_str)}\n"
|
76
|
+
|
77
|
+
def getHost(self) -> str:
|
78
|
+
host_str = f" Host: {self.data.Host}"
|
79
|
+
return f"{self.__dropLongString(host_str)}\n"
|
80
|
+
|
81
|
+
def getKernel(self) -> str:
|
82
|
+
kernel_str = f" Kernel: {self.data.Kernel}"
|
83
|
+
return f"{self.__dropLongString(kernel_str)}\n"
|
84
|
+
|
85
|
+
def getUptime(self) -> str:
|
86
|
+
uptime_str = f" Uptime: {self.data.Uptime}"
|
87
|
+
return f"{self.__dropLongString(uptime_str)}\n"
|
88
|
+
|
89
|
+
def getShell(self) -> str:
|
90
|
+
shell_str = f" Shell: {self.data.Shell}"
|
91
|
+
return f"{self.__dropLongString(shell_str)}\n"
|
92
|
+
|
93
|
+
def getCPU(self) -> str:
|
94
|
+
cpu_str = f" CPU: {self.data.CPU}"
|
95
|
+
return f"{self.__dropLongString(cpu_str)}\n"
|
96
|
+
|
97
|
+
def getGPU(self) -> str:
|
98
|
+
ret_str = ""
|
99
|
+
for gpu in self.data.GPU:
|
100
|
+
gpu_str = f" GPU: {gpu}"
|
101
|
+
ret_str += f"{self.__dropLongString(gpu_str)}\n"
|
102
|
+
return ret_str
|
103
|
+
|
104
|
+
def getMemory(self) -> str:
|
105
|
+
memory_str = f" Memory: {self.data.Memory}"
|
106
|
+
return f"{self.__dropLongString(memory_str)}\n"
|
107
|
+
|
108
|
+
def getNIC(self) -> str:
|
109
|
+
ret_str = ""
|
110
|
+
for nic in self.data.NIC:
|
111
|
+
nic_str = f" NIC: {nic}"
|
112
|
+
ret_str += f"{self.__dropLongString(nic_str)}\n"
|
113
|
+
return ret_str
|
114
|
+
|
115
|
+
def getNPU(self) -> str:
|
116
|
+
ret_str = ""
|
117
|
+
for npu in self.data.NPU:
|
118
|
+
npu_str = f" NPU: {npu}"
|
119
|
+
ret_str += f"{self.__dropLongString(npu_str)}\n"
|
120
|
+
return ret_str
|
121
|
+
|
122
|
+
|
41
123
|
def createDataString(data: Data):
|
124
|
+
data_string_processor = DataStringProcessor(data)
|
125
|
+
data_string = ""
|
126
|
+
data_string += data_string_processor.getTitle()
|
127
|
+
data_string += data_string_processor.getLine()
|
128
|
+
data_string += data_string_processor.getOS()
|
129
|
+
data_string += data_string_processor.getHost()
|
130
|
+
data_string += data_string_processor.getKernel()
|
131
|
+
data_string += data_string_processor.getUptime()
|
132
|
+
data_string += data_string_processor.getShell()
|
133
|
+
data_string += data_string_processor.getCPU()
|
134
|
+
data_string += data_string_processor.getGPU()
|
135
|
+
data_string += data_string_processor.getMemory()
|
136
|
+
data_string += data_string_processor.getNIC()
|
137
|
+
data_string += data_string_processor.getNPU()
|
138
|
+
return data_string
|
139
|
+
|
140
|
+
|
141
|
+
def createDataStringOld(data: Data):
|
42
142
|
data_string = ""
|
43
143
|
data_string += f" {data.title}\n"
|
44
144
|
data_string += f" {'-'*len(data.title)}\n"
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pyhw
|
3
|
-
Version: 0.6.
|
3
|
+
Version: 0.6.6
|
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
|
@@ -53,6 +53,18 @@ pyhw
|
|
53
53
|
```
|
54
54
|
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
55
|
|
56
|
+
### Install by pipx
|
57
|
+
**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).
|
58
|
+
|
59
|
+
You can install pyhw by the following command:
|
60
|
+
```shell
|
61
|
+
pipx install pyhw
|
62
|
+
```
|
63
|
+
You can then use this tool directly from the command line with the following command, just like neofetch.
|
64
|
+
```shell
|
65
|
+
pyhw
|
66
|
+
```
|
67
|
+
|
56
68
|
### Important note about debian 12:
|
57
69
|
If you use system pip to install pyhw, you will encounter this problem on debian12 and some related distributions:
|
58
70
|
```text
|
@@ -73,7 +85,7 @@ error: externally-managed-environment
|
|
73
85
|
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.
|
74
86
|
hint: See PEP 668 for the detailed specification.
|
75
87
|
```
|
76
|
-
This is due to the fact that system python is not supposed to be managed by pip. You can use a virtual environment (venv) or force remove this restriction (not recommended).
|
88
|
+
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).
|
77
89
|
|
78
90
|
## Supported (Tested) OS
|
79
91
|
* macOS arm64, x86_64
|
@@ -7,7 +7,7 @@ pyhw/backend/cpu/__init__.py,sha256=5YfANJVRwNwTRodG0ENOgusrdN592aaSnfq5ok4dKTo,
|
|
7
7
|
pyhw/backend/cpu/cpuBase.py,sha256=AGWqVjdvb82NiH4kxk3GERdBLwBNhkR23j2ei_l3S18,464
|
8
8
|
pyhw/backend/cpu/cpuInfo.py,sha256=A_nNGElq9W7oZ5DFJowLdFBE0ZvXKr5h29E6TGAvbRc,251
|
9
9
|
pyhw/backend/cpu/linux.py,sha256=zJ2cOwQHtolJrMMY1WXVbLLIRNPxeClUgzLAAkd7As4,3346
|
10
|
-
pyhw/backend/cpu/macos.py,sha256=
|
10
|
+
pyhw/backend/cpu/macos.py,sha256=pacU-yT7q-HKerkh2Q0BSdzSY6dKzHfSnRZBmimqqXk,2953
|
11
11
|
pyhw/backend/gpu/__init__.py,sha256=EpMjPvUaXt0LTNMvGmB8WgXbUB9keCxuOhu8NT3Re6o,56
|
12
12
|
pyhw/backend/gpu/gpuBase.py,sha256=Ge0DX2P8_EB7ovM7glmPUnVsPJL3OUHV2t_1T5mimR0,409
|
13
13
|
pyhw/backend/gpu/gpuInfo.py,sha256=d_z_z5DiZAg85wP0VOBQEU0QHdaK3qFqA2Tp9Eq8-Zs,133
|
@@ -16,7 +16,7 @@ pyhw/backend/gpu/macos.py,sha256=SmTqqTrIMRW-GVPmDs8xAiOX7HsCjrGh9qkxLQCdvO8,385
|
|
16
16
|
pyhw/backend/host/__init__.py,sha256=Efaj7-Oya7H8HdpZHQCLrwn-mcfPb-d6yfh4dzsE_7I,58
|
17
17
|
pyhw/backend/host/hostBase.py,sha256=POyDW3f5JSWtEKyCfrVSBEddSwoywe_OBgUExCEuje8,563
|
18
18
|
pyhw/backend/host/hostInfo.py,sha256=Xvz0LugPiCSWMkcDsp4p2rrojYFZauL6Q-gCZ6NLz5k,184
|
19
|
-
pyhw/backend/host/linux.py,sha256=
|
19
|
+
pyhw/backend/host/linux.py,sha256=wp65o_BJUxq-rkts_1UVP6IuK6U54Cl066G3QfZksiQ,2424
|
20
20
|
pyhw/backend/host/macos.py,sha256=KW-EJK9g1xHNrFsVxJv5GPLpc_ZevX0Zv1WjZUzRkzo,15369
|
21
21
|
pyhw/backend/host/windows.py,sha256=rjDJaIs-5zspzFsNCMCh6m2yZXEXI0vccqeBpmAdEBk,53
|
22
22
|
pyhw/backend/kernel/__init__.py,sha256=fGjwjpOhwA_PnsWbwoq102hwhTay2ufYKaTqxjSV2-I,65
|
@@ -58,7 +58,7 @@ pyhw/backend/uptime/macos.py,sha256=8lTlR0WUzgGqUNspqegg4dP_j5ySOCTyFlXpyRBJ-Jw,
|
|
58
58
|
pyhw/backend/uptime/uptimeBase.py,sha256=cP6aTPnFe6XQHgBX7YcDuuGHARI11ctMlyrrtsU-Opc,657
|
59
59
|
pyhw/backend/uptime/uptimeInfo.py,sha256=TobPEV3MBT3Fiv3W6TOzD3a4MNW-vz2Oi_Trlcihu7k,114
|
60
60
|
pyhw/frontend/__init__.py,sha256=xgv_iVv9w4cLXklbdtFWXu7J7KJxBCUw-ZcUQb_abFc,57
|
61
|
-
pyhw/frontend/frontendBase.py,sha256=
|
61
|
+
pyhw/frontend/frontendBase.py,sha256=t_lq2mvBet3l8Kn7bvab1bvfwCaD7PZ6dzN8fMCzHOI,4713
|
62
62
|
pyhw/frontend/color/__init__.py,sha256=xk511qWwdYWEVjk_zOaC4fs81HtwR4ELr3wi1tTL824,191
|
63
63
|
pyhw/frontend/color/colorConfig.py,sha256=3k6aMoU7ymThG3yytzKqQDDxz8xL5wfZL_2cDiPusXI,4353
|
64
64
|
pyhw/frontend/color/colorSet.py,sha256=spH8PlRu7capouf-yUgDHgoPCnM5aJ_ncascISZfz2g,1421
|
@@ -77,15 +77,15 @@ pyhw/frontend/logo/ascii/macOS.pyhw,sha256=HBGROtBb7wrNtRqAQ9ND7zxK0l17BRsmpgc2d
|
|
77
77
|
pyhw/frontend/logo/ascii/raspbian.pyhw,sha256=jEl6WMKF-FGx359ipQ1kzweUJS-NuauYQCFaYime4PQ,159
|
78
78
|
pyhw/frontend/logo/ascii/ubuntu.pyhw,sha256=l-Q0PfutxXYMwTojqeiM88063x4V0RBkZUHmi6YdsNc,833
|
79
79
|
pyhw/frontend/logo/ascii/ubuntu_small.pyhw,sha256=Xf8LSZdZUu9aEG3efhb1FUlUEuJ-3UztcIOJISpKhPw,229
|
80
|
-
pyhw/library/lib/iokitGPULib.dylib,sha256=
|
80
|
+
pyhw/library/lib/iokitGPULib.dylib,sha256=DcJ0GZY79gTFckLFYtZgeKn1T0NFvdO_k_ccCa7od5Y,154808
|
81
81
|
pyhw/pyhwException/__init__.py,sha256=8JsFvtF13g0Y5t4z9fRndDXtfCzuBM59jDf6PhWSFSk,220
|
82
82
|
pyhw/pyhwException/pyhwException.py,sha256=wxuzFQa9g7XB1q9TUKO_55lw7wMEJMpzG8w1GVTFVa0,197
|
83
83
|
pyhw/pyhwUtil/__init__.py,sha256=PzeP9fXsIhvr3sUpJ4DxW9_H25DEIasBFfXd_NztfR4,226
|
84
|
-
pyhw/pyhwUtil/pyhwUtil.py,sha256=
|
84
|
+
pyhw/pyhwUtil/pyhwUtil.py,sha256=0Pn-0MqgloQV_p5HrM3HwrGsA_eB-P2eW2hLJrHWmhk,5762
|
85
85
|
pyhw/pyhwUtil/sysctlUtil.py,sha256=S-rUvqi7ZrMyMouIhxlyHEQ4agM7sCT1Y7uzs3Hu5-o,841
|
86
|
-
pyhw-0.6.
|
87
|
-
pyhw-0.6.
|
88
|
-
pyhw-0.6.
|
89
|
-
pyhw-0.6.
|
90
|
-
pyhw-0.6.
|
91
|
-
pyhw-0.6.
|
86
|
+
pyhw-0.6.6.dist-info/LICENSE,sha256=hJs6RBqSVCexbTsalkMLNFI5t06kekQEsSVaOt_-yLs,1497
|
87
|
+
pyhw-0.6.6.dist-info/METADATA,sha256=lDfujbVf0CPbvs5_n97qzeRBA5Y3xmjQ6hWAsuMIeV4,5225
|
88
|
+
pyhw-0.6.6.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
89
|
+
pyhw-0.6.6.dist-info/entry_points.txt,sha256=q-AB8im_QahpmNrmy4aPTJRGi0LlbNlnI3kF7s6pKss,44
|
90
|
+
pyhw-0.6.6.dist-info/top_level.txt,sha256=7Inxvxt1TngEricKZEex9_WJZS3DbKYFUXDz4v5WHYU,5
|
91
|
+
pyhw-0.6.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|