pyhw 0.9.0__py3-none-any.whl → 0.10.0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
pyhw/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = '0.9.0'
1
+ __version__ = '0.10.0'
pyhw/__main__.py CHANGED
@@ -13,33 +13,122 @@ from .backend.nic import NICDetect
13
13
  from .backend.npu import NPUDetect
14
14
  from .pyhwUtil import createDataString
15
15
  from .pyhwUtil import getOS, selectOSLogo
16
+ import multiprocessing
17
+
18
+
19
+ def detect_title(os, result_dict):
20
+ result_dict["title"] = TitleDetect(os=os).getTitle().title
21
+
22
+
23
+ def detect_host(os, result_dict):
24
+ result_dict["Host"] = HostDetect(os=os).getHostInfo().model
25
+
26
+
27
+ def detect_kernel(os, result_dict):
28
+ result_dict["Kernel"] = KernelDetect(os=os).getKernelInfo().kernel
29
+
30
+
31
+ def detect_shell(os, result_dict):
32
+ result_dict["Shell"] = ShellDetect(os=os).getShellInfo().info
33
+
34
+
35
+ def detect_uptime(os, result_dict):
36
+ result_dict["Uptime"] = UptimeDetect(os=os).getUptime().uptime
37
+
38
+
39
+ def detect_os(os, result_dict):
40
+ result_dict["OS"] = OSDetect(os=os).getOSInfo().prettyName
41
+
42
+
43
+ def detect_cpu(os, result_dict):
44
+ result_dict["CPU"] = CPUDetect(os=os).getCPUInfo().cpu
45
+
46
+
47
+ def detect_gpu(os, result_dict):
48
+ gpu_info = GPUDetect(os=os).getGPUInfo()
49
+ if gpu_info.number > 0:
50
+ result_dict["GPU"] = gpu_info.gpus
51
+
52
+
53
+ def detect_memory(os, result_dict):
54
+ result_dict["Memory"] = MemoryDetect(os=os).getMemoryInfo().memory
55
+
56
+
57
+ def detect_nic(os, result_dict):
58
+ nic_info = NICDetect(os=os).getNICInfo()
59
+ if nic_info.number > 0:
60
+ result_dict["NIC"] = nic_info.nics
61
+
62
+
63
+ def detect_npu(os, result_dict):
64
+ npu_info = NPUDetect(os=os).getNPUInfo()
65
+ if npu_info.number > 0:
66
+ result_dict["NPU"] = npu_info.npus
16
67
 
17
68
 
18
69
  def main():
19
70
  current_os = getOS()
20
71
  if current_os not in ["linux", "macos", "freebsd", "windows"]:
21
- print(f"Only Linux, macOS, FreeBSD and Windows are supported for now. Current OS: {current_os}")
72
+ print(f"Only Linux, macOS, FreeBSD, and Windows are supported for now. Current OS: {current_os}")
22
73
  return
74
+
23
75
  data = Data()
24
- data.title = TitleDetect(os=current_os).getTitle().title
25
- data.Host = HostDetect(os=current_os).getHostInfo().model
26
- data.Kernel = KernelDetect(os=current_os).getKernelInfo().kernel
27
- data.Shell = ShellDetect(os=current_os).getShellInfo().info
28
- data.Uptime = UptimeDetect(os=current_os).getUptime().uptime
29
- data.OS = OSDetect(os=current_os).getOSInfo().prettyName
30
- data.CPU = CPUDetect(os=current_os).getCPUInfo().cpu
31
- gpu_info = GPUDetect(os=current_os).getGPUInfo()
32
- if gpu_info.number > 0:
33
- data.GPU = gpu_info.gpus
34
- data.Memory = MemoryDetect(os=current_os).getMemoryInfo().memory
35
- nic_info = NICDetect(os=current_os).getNICInfo()
36
- if nic_info.number > 0:
37
- data.NIC = nic_info.nics
38
- npu_info = NPUDetect(os=current_os).getNPUInfo()
39
- if npu_info.number > 0:
40
- data.NPU = npu_info.npus
41
76
 
42
- Printer(logo_os=selectOSLogo(OSDetect(os=current_os).getOSInfo().id), data=createDataString(data)).cPrint()
77
+ manager = multiprocessing.Manager()
78
+ result_dict = manager.dict()
79
+
80
+ processes = [
81
+ multiprocessing.Process(target=detect_title, args=(current_os, result_dict)),
82
+ multiprocessing.Process(target=detect_host, args=(current_os, result_dict)),
83
+ multiprocessing.Process(target=detect_kernel, args=(current_os, result_dict)),
84
+ multiprocessing.Process(target=detect_shell, args=(current_os, result_dict)),
85
+ multiprocessing.Process(target=detect_uptime, args=(current_os, result_dict)),
86
+ multiprocessing.Process(target=detect_os, args=(current_os, result_dict)),
87
+ multiprocessing.Process(target=detect_cpu, args=(current_os, result_dict)),
88
+ multiprocessing.Process(target=detect_gpu, args=(current_os, result_dict)),
89
+ multiprocessing.Process(target=detect_memory, args=(current_os, result_dict)),
90
+ multiprocessing.Process(target=detect_nic, args=(current_os, result_dict)),
91
+ multiprocessing.Process(target=detect_npu, args=(current_os, result_dict)),
92
+ ]
93
+
94
+ for process in processes:
95
+ process.start()
96
+
97
+ for process in processes:
98
+ process.join()
99
+
100
+ for key, value in result_dict.items():
101
+ setattr(data, key, value)
102
+
103
+ logo_os = selectOSLogo(OSDetect(os=current_os).getOSInfo().id)
104
+ Printer(logo_os=logo_os, data=createDataString(data)).cPrint()
105
+
106
+
107
+ # def main():
108
+ # current_os = getOS()
109
+ # if current_os not in ["linux", "macos", "freebsd", "windows"]:
110
+ # print(f"Only Linux, macOS, FreeBSD and Windows are supported for now. Current OS: {current_os}")
111
+ # return
112
+ # data = Data()
113
+ # data.title = TitleDetect(os=current_os).getTitle().title
114
+ # data.Host = HostDetect(os=current_os).getHostInfo().model
115
+ # data.Kernel = KernelDetect(os=current_os).getKernelInfo().kernel
116
+ # data.Shell = ShellDetect(os=current_os).getShellInfo().info
117
+ # data.Uptime = UptimeDetect(os=current_os).getUptime().uptime
118
+ # data.OS = OSDetect(os=current_os).getOSInfo().prettyName
119
+ # data.CPU = CPUDetect(os=current_os).getCPUInfo().cpu
120
+ # gpu_info = GPUDetect(os=current_os).getGPUInfo()
121
+ # if gpu_info.number > 0:
122
+ # data.GPU = gpu_info.gpus
123
+ # data.Memory = MemoryDetect(os=current_os).getMemoryInfo().memory
124
+ # nic_info = NICDetect(os=current_os).getNICInfo()
125
+ # if nic_info.number > 0:
126
+ # data.NIC = nic_info.nics
127
+ # npu_info = NPUDetect(os=current_os).getNPUInfo()
128
+ # if npu_info.number > 0:
129
+ # data.NPU = npu_info.npus
130
+ #
131
+ # Printer(logo_os=selectOSLogo(OSDetect(os=current_os).getOSInfo().id), data=createDataString(data)).cPrint()
43
132
 
44
133
 
45
134
  if __name__ == "__main__":
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pyhw
3
- Version: 0.9.0
3
+ Version: 0.10.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
@@ -10,10 +10,10 @@ Classifier: Development Status :: 4 - Beta
10
10
  Classifier: Programming Language :: Python :: 3
11
11
  Classifier: License :: OSI Approved :: BSD License
12
12
  Classifier: Operating System :: OS Independent
13
- Requires-Python: >=3.9
13
+ Requires-Python: >=3.8
14
14
  Description-Content-Type: text/markdown
15
15
  License-File: LICENSE
16
- Requires-Dist: pypci-ng>=0.1.2
16
+ Requires-Dist: pypci-ng>=0.1.3
17
17
 
18
18
  # PyHw
19
19
  [![Downloads](https://static.pepy.tech/badge/pyhw)](https://pepy.tech/project/pyhw)
@@ -42,8 +42,23 @@ This project is a Python reimplementation of [neofetch](https://github.com/dylan
42
42
 
43
43
 
44
44
 
45
- ## Install
46
- 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.
45
+ ## 1. Install
46
+ 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, There are two convenient ways to install it.
47
+
48
+ ### 1.1 Install by pipx
49
+ **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). **pipx** is available on almost all major platforms and is usually provided by the corresponding package manager. If you haven't used pipx before, you can refer to this [document](https://pipx.pypa.io/stable/installation/) to install it.
50
+
51
+ You can install pyhw by the following command:
52
+ ```shell
53
+ pipx install pyhw
54
+ ```
55
+ You can then use this tool directly from the command line with the following command, just like neofetch.
56
+ ```shell
57
+ pyhw
58
+ ```
59
+
60
+ ### 1.2 Install by pip
61
+ In any case, pip is always available, so if you can't install this program using **pipx**, you can install pyhw by the following command:
47
62
  ```shell
48
63
  pip install pyhw
49
64
  ```
@@ -61,19 +76,8 @@ python -m pyhw
61
76
  ```
62
77
  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__.
63
78
 
64
- ### Install by pipx
65
- **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).
66
-
67
- You can install pyhw by the following command:
68
- ```shell
69
- pipx install pyhw
70
- ```
71
- You can then use this tool directly from the command line with the following command, just like neofetch.
72
- ```shell
73
- pyhw
74
- ```
75
79
 
76
- ### Important note about debian 12:
80
+ ### 1.3 Important note about debian 12:
77
81
  If you use system pip to install pyhw, you will encounter this problem on debian12 and some related distributions (like Ubuntu 24.04):
78
82
  ```text
79
83
  error: externally-managed-environment
@@ -93,32 +97,34 @@ error: externally-managed-environment
93
97
  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.
94
98
  hint: See PEP 668 for the detailed specification.
95
99
  ```
96
- 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).
100
+ 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), conda environment or force remove this restriction (not recommended).
97
101
 
98
- ## Tested OS
102
+ ## 2. Tested OS
99
103
  * macOS arm64, x86_64
100
104
  * Linux arm64, x86_64, riscv64
101
105
  * FreeBSD arm64
102
- * Windows 10 X86_64
106
+ * Windows 10 x86_64
107
+ * Windows 11 arm64, x86_64
108
+
109
+ For more detailed information, please refer to [Tested Platform](docs/tested_platform.md).
103
110
 
104
- ## Add Logo
111
+ ## 3. Add Logo
105
112
  1. Create a file named **\<os>.pyhw** in **logo/ascii** folder
106
113
  2. Modify **colorConfig.py** file to add a new logo style
107
114
  3. Update **pyhwUtil.py** to enable new logo style.
108
115
 
109
- ## Build from source
110
- 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.
116
+ ## 4. Build from source
111
117
 
112
- ### Dependencies
118
+ ### 4.1 Dependencies
113
119
  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).
114
120
 
115
- ### Build tools
121
+ ### 4.2 Build tools
116
122
  Make sure the following Python build tools are already installed.
117
123
  * setuptools
118
124
  * build
119
125
  * twine
120
126
 
121
- ### Build package
127
+ ### 4.3 Build package
122
128
  clone the project, and run:
123
129
  ```shell
124
130
  python -m build
@@ -127,11 +133,17 @@ After the build process, the source package and the binary whl package can be fo
127
133
  ```shell
128
134
  pip install dist/*.whl --force-reinstall
129
135
  ```
130
- Or simply type:
136
+
137
+ ### 4.4 Build Full Feature package
138
+ Currently, build process relay on swiftc and macOS IOKit framework. To build Full Feature Package from source, you need a Mac machine with macOS 11 and newer.
139
+
140
+ Simply type:
131
141
  ```shell
132
142
  make build
133
143
  make install
134
144
  ```
145
+
146
+ ## 5. Test Package
135
147
  If you have docker installed, you can test this package through docker by type:
136
148
  ```shell
137
149
  make test # local build
@@ -1,5 +1,5 @@
1
- pyhw/__init__.py,sha256=_DlwPNmTZTKflLiAF8YIqSr2ao66CTjj4bQtA6hz0jM,22
2
- pyhw/__main__.py,sha256=AYSSricHPScjYNF-LgFHfQUqKcxq8FruDW2a89FAXfA,1795
1
+ pyhw/__init__.py,sha256=RYs3cR49NZ5Zwt0avo2mYyRcdWjLbrKBCHRHpqCJx24,23
2
+ pyhw/__main__.py,sha256=Gp50LaRF9vl_czdLNJRoa0OIzctLKhcZU0XH3EjNVjM,4741
3
3
  pyhw/backend/__init__.py,sha256=knn_3Yroow1h0dqdrozk3zyy3vz-kQyNBRjR6OLmVoY,50
4
4
  pyhw/backend/backendBase.py,sha256=mloo8mPEbgbIdmyQ3I4vdEXMSSjxWi_wnwACmzvHbEo,506
5
5
  pyhw/backend/cpu/__init__.py,sha256=5YfANJVRwNwTRodG0ENOgusrdN592aaSnfq5ok4dKTo,56
@@ -105,9 +105,9 @@ pyhw/pyhwException/pyhwException.py,sha256=wxuzFQa9g7XB1q9TUKO_55lw7wMEJMpzG8w1G
105
105
  pyhw/pyhwUtil/__init__.py,sha256=diIqlNUBfuHu-2VAOJk5nipGLafnWxR3chAAOmX8QRo,250
106
106
  pyhw/pyhwUtil/pyhwUtil.py,sha256=h4Xz0heMrBoj2ViHyWmWUNcWmIZlxAmMhqZXskEHpTU,6765
107
107
  pyhw/pyhwUtil/sysctlUtil.py,sha256=S-rUvqi7ZrMyMouIhxlyHEQ4agM7sCT1Y7uzs3Hu5-o,841
108
- pyhw-0.9.0.dist-info/LICENSE,sha256=hJs6RBqSVCexbTsalkMLNFI5t06kekQEsSVaOt_-yLs,1497
109
- pyhw-0.9.0.dist-info/METADATA,sha256=oC2iJ9uHoQJAB03GK4V6JelRcshwC5zjZPIGC2K7wdU,6018
110
- pyhw-0.9.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
111
- pyhw-0.9.0.dist-info/entry_points.txt,sha256=q-AB8im_QahpmNrmy4aPTJRGi0LlbNlnI3kF7s6pKss,44
112
- pyhw-0.9.0.dist-info/top_level.txt,sha256=7Inxvxt1TngEricKZEex9_WJZS3DbKYFUXDz4v5WHYU,5
113
- pyhw-0.9.0.dist-info/RECORD,,
108
+ pyhw-0.10.0.dist-info/LICENSE,sha256=hJs6RBqSVCexbTsalkMLNFI5t06kekQEsSVaOt_-yLs,1497
109
+ pyhw-0.10.0.dist-info/METADATA,sha256=CCpHUPKmL57ySsW9fPxag_Ef-Mkv8ClP7k_Z2gT8HKc,6669
110
+ pyhw-0.10.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
111
+ pyhw-0.10.0.dist-info/entry_points.txt,sha256=q-AB8im_QahpmNrmy4aPTJRGi0LlbNlnI3kF7s6pKss,44
112
+ pyhw-0.10.0.dist-info/top_level.txt,sha256=7Inxvxt1TngEricKZEex9_WJZS3DbKYFUXDz4v5WHYU,5
113
+ pyhw-0.10.0.dist-info/RECORD,,
File without changes
File without changes