pyhw 0.6.4__tar.gz → 0.6.6__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {pyhw-0.6.4/src/pyhw.egg-info → pyhw-0.6.6}/PKG-INFO +14 -2
- {pyhw-0.6.4 → pyhw-0.6.6}/README.md +13 -1
- {pyhw-0.6.4 → pyhw-0.6.6}/pyproject.toml +1 -1
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/cpu/macos.py +3 -1
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/host/linux.py +10 -2
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/frontend/frontendBase.py +32 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/library/lib/iokitGPULib.dylib +0 -0
- pyhw-0.6.6/src/pyhw/pyhwUtil/pyhwUtil.py +189 -0
- {pyhw-0.6.4 → pyhw-0.6.6/src/pyhw.egg-info}/PKG-INFO +14 -2
- pyhw-0.6.4/src/pyhw/pyhwUtil/pyhwUtil.py +0 -89
- {pyhw-0.6.4 → pyhw-0.6.6}/LICENSE +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/setup.cfg +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/__init__.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/__main__.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/__init__.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/backendBase.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/cpu/__init__.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/cpu/cpuBase.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/cpu/cpuInfo.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/cpu/linux.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/gpu/__init__.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/gpu/gpuBase.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/gpu/gpuInfo.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/gpu/linux.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/gpu/macos.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/host/__init__.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/host/hostBase.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/host/hostInfo.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/host/macos.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/host/windows.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/kernel/__init__.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/kernel/kernelBase.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/kernel/kernelInfo.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/kernel/unix.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/kernel/windows.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/memory/__init__.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/memory/linux.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/memory/macos.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/memory/memoryBase.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/memory/memoryInfo.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/metal/t.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/nic/__init__.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/nic/linux.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/nic/macos.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/nic/nicBase.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/nic/nicInfo.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/npu/__init__.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/npu/linux.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/npu/macos.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/npu/npuBase.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/npu/npuInfo.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/os/__init__.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/os/linux.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/os/macos.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/os/osBase.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/os/osInfo.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/shell/__init__.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/shell/shellBase.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/shell/unix.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/title/__init__.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/title/titleBase.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/title/unix.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/title/windows.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/uptime/__init__.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/uptime/linux.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/uptime/macos.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/uptime/uptimeBase.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/backend/uptime/uptimeInfo.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/frontend/__init__.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/frontend/color/__init__.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/frontend/color/colorConfig.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/frontend/color/colorSet.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/frontend/color/colorUtil.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/frontend/logo/__init__.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/frontend/logo/ascii/alpine.pyhw +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/frontend/logo/ascii/arch.pyhw +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/frontend/logo/ascii/armbian.pyhw +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/frontend/logo/ascii/centos.pyhw +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/frontend/logo/ascii/debian.pyhw +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/frontend/logo/ascii/fedora.pyhw +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/frontend/logo/ascii/fedora_small.pyhw +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/frontend/logo/ascii/linux.pyhw +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/frontend/logo/ascii/macOS.pyhw +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/frontend/logo/ascii/raspbian.pyhw +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/frontend/logo/ascii/ubuntu.pyhw +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/frontend/logo/ascii/ubuntu_small.pyhw +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/frontend/logo/logoBase.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/macos.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/pyhwException/__init__.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/pyhwException/pyhwException.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/pyhwUtil/__init__.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw/pyhwUtil/sysctlUtil.py +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw.egg-info/SOURCES.txt +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw.egg-info/dependency_links.txt +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw.egg-info/entry_points.txt +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/src/pyhw.egg-info/requires.txt +0 -0
- {pyhw-0.6.4 → pyhw-0.6.6}/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.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
|
@@ -36,6 +36,18 @@ pyhw
|
|
36
36
|
```
|
37
37
|
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
38
|
|
39
|
+
### Install by pipx
|
40
|
+
**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).
|
41
|
+
|
42
|
+
You can install pyhw by the following command:
|
43
|
+
```shell
|
44
|
+
pipx install pyhw
|
45
|
+
```
|
46
|
+
You can then use this tool directly from the command line with the following command, just like neofetch.
|
47
|
+
```shell
|
48
|
+
pyhw
|
49
|
+
```
|
50
|
+
|
39
51
|
### Important note about debian 12:
|
40
52
|
If you use system pip to install pyhw, you will encounter this problem on debian12 and some related distributions:
|
41
53
|
```text
|
@@ -56,7 +68,7 @@ error: externally-managed-environment
|
|
56
68
|
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.
|
57
69
|
hint: See PEP 668 for the detailed specification.
|
58
70
|
```
|
59
|
-
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).
|
71
|
+
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).
|
60
72
|
|
61
73
|
## Supported (Tested) OS
|
62
74
|
* macOS arm64, x86_64
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "pyhw"
|
7
|
-
version = "0.6.
|
7
|
+
version = "0.6.6"
|
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 = [
|
@@ -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")
|
@@ -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
|
@@ -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
|
@@ -0,0 +1,189 @@
|
|
1
|
+
import platform
|
2
|
+
from ..backend import Data
|
3
|
+
import os
|
4
|
+
from dataclasses import dataclass
|
5
|
+
|
6
|
+
|
7
|
+
def getOS():
|
8
|
+
"""
|
9
|
+
Get the os type in lower case.
|
10
|
+
:return: str, os type, value in [windows, linux, macos, unknown].
|
11
|
+
"""
|
12
|
+
system = platform.system()
|
13
|
+
if system == "Windows":
|
14
|
+
return "windows"
|
15
|
+
elif system == "Linux":
|
16
|
+
return "linux"
|
17
|
+
elif system == "Darwin":
|
18
|
+
return "macos"
|
19
|
+
else:
|
20
|
+
return "unknown"
|
21
|
+
|
22
|
+
|
23
|
+
def getArch():
|
24
|
+
"""
|
25
|
+
Get the machine architecture.
|
26
|
+
:return: str, value in [x86_64, x86, aarch64, arm32].
|
27
|
+
"""
|
28
|
+
arch = platform.machine()
|
29
|
+
if arch == "x86_64" or arch == "AMD64" or arch == "amd64":
|
30
|
+
return "x86_64"
|
31
|
+
elif arch == "i386" or arch == "i686" or arch == "x86":
|
32
|
+
return "x86"
|
33
|
+
elif arch == "aarch64" or arch == "arm64":
|
34
|
+
return "aarch64"
|
35
|
+
elif arch.find("arm") != -1:
|
36
|
+
return "arm32"
|
37
|
+
else:
|
38
|
+
return "unknown"
|
39
|
+
|
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
|
+
|
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):
|
142
|
+
data_string = ""
|
143
|
+
data_string += f" {data.title}\n"
|
144
|
+
data_string += f" {'-'*len(data.title)}\n"
|
145
|
+
data_string += f" OS: {data.OS}\n"
|
146
|
+
data_string += f" Host: {data.Host}\n"
|
147
|
+
data_string += f" Kernel: {data.Kernel}\n"
|
148
|
+
data_string += f" Uptime: {data.Uptime}\n"
|
149
|
+
data_string += f" Shell: {data.Shell}\n"
|
150
|
+
data_string += f" CPU: {data.CPU}\n"
|
151
|
+
for gpu in data.GPU:
|
152
|
+
data_string += f" GPU: {gpu}\n"
|
153
|
+
data_string += f" Memory: {data.Memory}\n"
|
154
|
+
for nic in data.NIC:
|
155
|
+
data_string += f" NIC: {nic}\n"
|
156
|
+
for npu in data.NPU:
|
157
|
+
data_string += f" NPU: {npu}\n"
|
158
|
+
return data_string
|
159
|
+
|
160
|
+
|
161
|
+
@dataclass
|
162
|
+
class SupportedOS:
|
163
|
+
ColorConfig = ["armbian", "arch", "alpine", "centos", "debian", "fedora", "macOS", "raspbian", "ubuntu"]
|
164
|
+
AsciiLogo = ["armbian", "arch", "alpine", "centos", "debian", "fedora", "macOS", "raspbian", "ubuntu"]
|
165
|
+
|
166
|
+
|
167
|
+
def selectOSLogo(os_id: str):
|
168
|
+
"""
|
169
|
+
Select the logo based on the os id and terminal size.
|
170
|
+
:param os_id: str, os id.
|
171
|
+
:return: str, logo id.
|
172
|
+
"""
|
173
|
+
if getOS() == "macos":
|
174
|
+
return os_id
|
175
|
+
if os_id in SupportedOS.ColorConfig and os_id in SupportedOS.AsciiLogo:
|
176
|
+
pass
|
177
|
+
else:
|
178
|
+
return "linux"
|
179
|
+
rows_str, columns_str = os.popen('stty size', 'r').read().split()
|
180
|
+
rows = int(rows_str)
|
181
|
+
columns = int(columns_str)
|
182
|
+
if columns <= 80:
|
183
|
+
if os_id in ["fedora", "ubuntu"]:
|
184
|
+
return f"{os_id}_small"
|
185
|
+
else:
|
186
|
+
return os_id
|
187
|
+
else:
|
188
|
+
return os_id
|
189
|
+
|
@@ -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
|
@@ -1,89 +0,0 @@
|
|
1
|
-
import platform
|
2
|
-
from ..backend import Data
|
3
|
-
import os
|
4
|
-
from dataclasses import dataclass
|
5
|
-
|
6
|
-
|
7
|
-
def getOS():
|
8
|
-
"""
|
9
|
-
Get the os type in lower case.
|
10
|
-
:return: str, os type, value in [windows, linux, macos, unknown].
|
11
|
-
"""
|
12
|
-
system = platform.system()
|
13
|
-
if system == "Windows":
|
14
|
-
return "windows"
|
15
|
-
elif system == "Linux":
|
16
|
-
return "linux"
|
17
|
-
elif system == "Darwin":
|
18
|
-
return "macos"
|
19
|
-
else:
|
20
|
-
return "unknown"
|
21
|
-
|
22
|
-
|
23
|
-
def getArch():
|
24
|
-
"""
|
25
|
-
Get the machine architecture.
|
26
|
-
:return: str, value in [x86_64, x86, aarch64, arm32].
|
27
|
-
"""
|
28
|
-
arch = platform.machine()
|
29
|
-
if arch == "x86_64" or arch == "AMD64" or arch == "amd64":
|
30
|
-
return "x86_64"
|
31
|
-
elif arch == "i386" or arch == "i686" or arch == "x86":
|
32
|
-
return "x86"
|
33
|
-
elif arch == "aarch64" or arch == "arm64":
|
34
|
-
return "aarch64"
|
35
|
-
elif arch.find("arm") != -1:
|
36
|
-
return "arm32"
|
37
|
-
else:
|
38
|
-
return "unknown"
|
39
|
-
|
40
|
-
|
41
|
-
def createDataString(data: Data):
|
42
|
-
data_string = ""
|
43
|
-
data_string += f" {data.title}\n"
|
44
|
-
data_string += f" {'-'*len(data.title)}\n"
|
45
|
-
data_string += f" OS: {data.OS}\n"
|
46
|
-
data_string += f" Host: {data.Host}\n"
|
47
|
-
data_string += f" Kernel: {data.Kernel}\n"
|
48
|
-
data_string += f" Uptime: {data.Uptime}\n"
|
49
|
-
data_string += f" Shell: {data.Shell}\n"
|
50
|
-
data_string += f" CPU: {data.CPU}\n"
|
51
|
-
for gpu in data.GPU:
|
52
|
-
data_string += f" GPU: {gpu}\n"
|
53
|
-
data_string += f" Memory: {data.Memory}\n"
|
54
|
-
for nic in data.NIC:
|
55
|
-
data_string += f" NIC: {nic}\n"
|
56
|
-
for npu in data.NPU:
|
57
|
-
data_string += f" NPU: {npu}\n"
|
58
|
-
return data_string
|
59
|
-
|
60
|
-
|
61
|
-
@dataclass
|
62
|
-
class SupportedOS:
|
63
|
-
ColorConfig = ["armbian", "arch", "alpine", "centos", "debian", "fedora", "macOS", "raspbian", "ubuntu"]
|
64
|
-
AsciiLogo = ["armbian", "arch", "alpine", "centos", "debian", "fedora", "macOS", "raspbian", "ubuntu"]
|
65
|
-
|
66
|
-
|
67
|
-
def selectOSLogo(os_id: str):
|
68
|
-
"""
|
69
|
-
Select the logo based on the os id and terminal size.
|
70
|
-
:param os_id: str, os id.
|
71
|
-
:return: str, logo id.
|
72
|
-
"""
|
73
|
-
if getOS() == "macos":
|
74
|
-
return os_id
|
75
|
-
if os_id in SupportedOS.ColorConfig and os_id in SupportedOS.AsciiLogo:
|
76
|
-
pass
|
77
|
-
else:
|
78
|
-
return "linux"
|
79
|
-
rows_str, columns_str = os.popen('stty size', 'r').read().split()
|
80
|
-
rows = int(rows_str)
|
81
|
-
columns = int(columns_str)
|
82
|
-
if columns <= 80:
|
83
|
-
if os_id in ["fedora", "ubuntu"]:
|
84
|
-
return f"{os_id}_small"
|
85
|
-
else:
|
86
|
-
return os_id
|
87
|
-
else:
|
88
|
-
return os_id
|
89
|
-
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|