pyhw 0.2.1b0__py3-none-any.whl → 0.2.3b0__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
pyhw/backend/cpu/linux.py CHANGED
@@ -10,6 +10,7 @@ class CPUDetectLinux:
10
10
  def getCPUInfo(self):
11
11
  self.__getCPUInfo()
12
12
  self.__modelClean()
13
+ self.__handleSBC()
13
14
  if self.__cpuInfo.model == "":
14
15
  self.__cpuInfo.model = "Unknown"
15
16
  if self.__cpuInfo.model != "":
@@ -53,3 +54,30 @@ class CPUDetectLinux:
53
54
  def __modelClean(self):
54
55
  self.__cpuInfo.model = self.__cpuInfo.model.replace("(R)", "")
55
56
  self.__cpuInfo.model = self.__cpuInfo.model.replace("(TM)", "")
57
+
58
+ def __handleSBC(self):
59
+ # some values should be double-checked
60
+ # Info source: https://github.com/raspberrypi/firmware/tree/master/boot
61
+ raspberry_pi_soc_map = {
62
+ "Raspberry Pi 2 Model B Rev 1.1": "BCM2836",
63
+ "Raspberry Pi 2 Model B Rev 1.2": "BCM2837",
64
+ "Raspberry Pi 3 Model B": "BCM2837",
65
+ "Raspberry Pi 3 Model B+": "BCM2837",
66
+ "Raspberry Pi 4 Model B": "BCM2711",
67
+ "Raspberry Pi 5": "BCM2712",
68
+ }
69
+ if os.path.exists("/sys/firmware/devicetree/base/model"):
70
+ try:
71
+ with open("/sys/firmware/devicetree/base/model", "r") as f:
72
+ model = f.read().strip().replace("\x00", "")
73
+ except FileNotFoundError:
74
+ model = ""
75
+ if "Raspberry Pi" in model:
76
+ map_cpu = raspberry_pi_soc_map.get(model, "Unknown")
77
+ if map_cpu != "Unknown":
78
+ self.__cpuInfo.model = map_cpu
79
+ else:
80
+ pass
81
+ else:
82
+ pass
83
+
@@ -21,13 +21,23 @@ class ColorConfigSet:
21
21
  return ColorConfigSetU.ubuntu
22
22
  elif self.__os_name == "ubuntu_small":
23
23
  return ColorConfigSetU.ubuntu_small
24
+ elif self.__os_name == "raspbian":
25
+ return ColorConfigSetR.raspbian
26
+ elif self.__os_name == "armbian":
27
+ return ColorConfigSetA.armbian
24
28
  else:
25
29
  return ColorConfigSetL.linux # default to Linux
26
30
 
27
31
 
28
32
  @dataclass
29
33
  class ColorConfigSetA:
30
- pass
34
+ armbian = {
35
+ "colors": [
36
+ ColorSet.COLOR_FG_RED
37
+ ],
38
+ "colorKeys": ColorSet.COLOR_FG_YELLOW,
39
+ "colorTitle": ColorSet.COLOR_FG_YELLOW
40
+ }
31
41
 
32
42
 
33
43
  @dataclass
@@ -90,6 +100,18 @@ class ColorConfigSetM:
90
100
  }
91
101
 
92
102
 
103
+ @dataclass
104
+ class ColorConfigSetR:
105
+ raspbian = {
106
+ "colors": [
107
+ ColorSet.COLOR_FG_RED,
108
+ ColorSet.COLOR_FG_GREEN
109
+ ],
110
+ "colorKeys": ColorSet.COLOR_FG_RED,
111
+ "colorTitle": ColorSet.COLOR_FG_GREEN
112
+ }
113
+
114
+
93
115
  @dataclass
94
116
  class ColorConfigSetU:
95
117
  ubuntu = {
@@ -0,0 +1,14 @@
1
+ █ █ █ █ █ █ █ █ █ █ █
2
+ ███████████████████████
3
+ ▄▄██ ██▄▄
4
+ ▄▄██ ███████████ ██▄▄
5
+ ▄▄██ ██ ██ ██▄▄
6
+ ▄▄██ ██ ██ ██▄▄
7
+ ▄▄██ ██ ██ ██▄▄
8
+ ▄▄██ █████████████ ██▄▄
9
+ ▄▄██ ██ ██ ██▄▄
10
+ ▄▄██ ██ ██ ██▄▄
11
+ ▄▄██ ██ ██ ██▄▄
12
+ ▄▄██ ██▄▄
13
+ ███████████████████████
14
+ █ █ █ █ █ █ █ █ █ █ █
@@ -0,0 +1,23 @@
1
+ $2`.::///+:/-. --///+//-:`
2
+ `+oooooooooooo: `+oooooooooooo:
3
+ /oooo++//ooooo: ooooo+//+ooooo.
4
+ `+ooooooo:-:oo- +o+::/ooooooo:
5
+ `:oooooooo+`` `.oooooooo+-
6
+ `:++ooo/. :+ooo+/.`$1
7
+ ...` `.----.` ``..
8
+ .::::-``:::::::::.`-:::-`
9
+ -:::-` .:::::::-` `-:::-
10
+ `::. `.--.` `` `.---.``.::`
11
+ .::::::::` -::::::::` `
12
+ .::` .:::::::::- `::::::::::``::.
13
+ -:::` ::::::::::. ::::::::::.`:::-
14
+ :::: -::::::::. `-:::::::: ::::
15
+ -::- .-:::-.``....``.-::-. -::-
16
+ .. `` .::::::::. `..`..
17
+ -:::-` -::::::::::` .:::::`
18
+ :::::::` -::::::::::` :::::::.
19
+ .::::::: -::::::::. ::::::::
20
+ `-:::::` ..--.` ::::::.
21
+ `...` `...--..` `...`
22
+ .::::::::::
23
+ `.-::::-`
pyhw/pyhwUtil/pyhwUtil.py CHANGED
@@ -1,6 +1,7 @@
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():
@@ -53,6 +54,12 @@ def createDataString(data: Data):
53
54
  return data_string
54
55
 
55
56
 
57
+ @dataclass
58
+ class SupportedOS:
59
+ ColorConfig = ["armbian", "debian", "fedora", "macOS", "raspbian", "ubuntu"]
60
+ AsciiLogo = ["armbian", "debian", "fedora", "macOS", "raspbian", "ubuntu"]
61
+
62
+
56
63
  def selectOSLogo(os_id: str):
57
64
  """
58
65
  Select the logo based on the os id and terminal size.
@@ -61,7 +68,7 @@ def selectOSLogo(os_id: str):
61
68
  """
62
69
  if getOS() == "macos":
63
70
  return os_id
64
- if os_id in ["debian", "ubuntu", "macOS", "fedora"]:
71
+ if os_id in SupportedOS.ColorConfig and os_id in SupportedOS.AsciiLogo:
65
72
  pass
66
73
  else:
67
74
  return "linux"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyhw
3
- Version: 0.2.1b0
3
+ Version: 0.2.3b0
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
@@ -26,6 +26,7 @@ PyHw, a neofetch-like command line tool for fetching system information but writ
26
26
 
27
27
  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 🤔).
28
28
 
29
+ ## Install
29
30
  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.
30
31
  ```shell
31
32
  pip install pyhw
@@ -38,6 +39,29 @@ You can then use this tool directly from the command line with the following com
38
39
  ```shell
39
40
  pyhw
40
41
  ```
42
+ 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__.
43
+
44
+ ### Important note about debian 12:
45
+ If you use system pip to install pyhw, you will encounter this problem on debian12 and some related distributions:
46
+ ```text
47
+ error: externally-managed-environment
48
+
49
+ × This environment is externally managed
50
+ ╰─> To install Python packages system-wide, try apt install
51
+ python3-xyz, where xyz is the package you are trying to
52
+ install.
53
+
54
+ If you wish to install a non-Debian-packaged Python package,
55
+ create a virtual environment using python3 -m venv path/to/venv.
56
+ Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
57
+ sure you have python3-full installed.
58
+
59
+ For more information visit http://rptl.io/venv
60
+
61
+ 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.
62
+ hint: See PEP 668 for the detailed specification.
63
+ ```
64
+ 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).
41
65
 
42
66
  ## Supported (Tested) OS
43
67
  * macOS arm64, x86_64
@@ -6,7 +6,7 @@ pyhw/backend/backendBase.py,sha256=t9FKQPdK7yFZF0vrsXpjIUJNKrB-cXYeL5MDohlgguA,4
6
6
  pyhw/backend/cpu/__init__.py,sha256=5YfANJVRwNwTRodG0ENOgusrdN592aaSnfq5ok4dKTo,56
7
7
  pyhw/backend/cpu/cpuBase.py,sha256=AGWqVjdvb82NiH4kxk3GERdBLwBNhkR23j2ei_l3S18,464
8
8
  pyhw/backend/cpu/cpuInfo.py,sha256=A_nNGElq9W7oZ5DFJowLdFBE0ZvXKr5h29E6TGAvbRc,251
9
- pyhw/backend/cpu/linux.py,sha256=sbhgzhunzQEI3gXzfmk7-al3P7tKYoTn_yOlAS2vJCM,2355
9
+ pyhw/backend/cpu/linux.py,sha256=xJNvGzKPZJ0KFtSHtf_cH8gU2TtxjfeUAIOyA4hu4T4,3444
10
10
  pyhw/backend/cpu/macos.py,sha256=mnnH9ABiBgAiyA8-H9_tq2PC5OeneVLj67nMGoLDXh4,2873
11
11
  pyhw/backend/gpu/__init__.py,sha256=EpMjPvUaXt0LTNMvGmB8WgXbUB9keCxuOhu8NT3Re6o,56
12
12
  pyhw/backend/gpu/gpuBase.py,sha256=Ge0DX2P8_EB7ovM7glmPUnVsPJL3OUHV2t_1T5mimR0,409
@@ -50,26 +50,28 @@ pyhw/backend/uptime/uptimeInfo.py,sha256=TobPEV3MBT3Fiv3W6TOzD3a4MNW-vz2Oi_Trlci
50
50
  pyhw/frontend/__init__.py,sha256=xgv_iVv9w4cLXklbdtFWXu7J7KJxBCUw-ZcUQb_abFc,57
51
51
  pyhw/frontend/frontendBase.py,sha256=VjZ-_sV-awDJVLHBzG8z3YK3W92-SS_Q5-_Q0PgyB3w,3708
52
52
  pyhw/frontend/color/__init__.py,sha256=xk511qWwdYWEVjk_zOaC4fs81HtwR4ELr3wi1tTL824,191
53
- pyhw/frontend/color/colorConfig.py,sha256=jPjLzv67haEr6rNC2hoNLJLWHO5LQx4zBbLTy3FHA0E,2718
53
+ pyhw/frontend/color/colorConfig.py,sha256=bC-UUStINoWqig3ieHE91wUa4PG1EzkAaMx5HxwjJrU,3313
54
54
  pyhw/frontend/color/colorSet.py,sha256=spH8PlRu7capouf-yUgDHgoPCnM5aJ_ncascISZfz2g,1421
55
55
  pyhw/frontend/color/colorUtil.py,sha256=VhcPmAJmXGIiRBfVZE2jg_iy-SfbxqwOSvkRz-nbUOQ,94
56
56
  pyhw/frontend/logo/__init__.py,sha256=mozEarHueBUgtDHKSd-RDaFysMLUiW3VQ8KcBtlKGCI,47
57
57
  pyhw/frontend/logo/logoBase.py,sha256=NjRCg0CXjmW4_7UZp2ZBgy2PZOAqaR6SYHg9zd90kRo,634
58
+ pyhw/frontend/logo/ascii/armbian.pyhw,sha256=Cg8tFIMdHdHLMlQrKm902C4OStKKHnCkDykNxbaSpfA,773
58
59
  pyhw/frontend/logo/ascii/debian.pyhw,sha256=ZmO1fg3Uc_ofF-CZSOP0Qo298luDASh2Zt50UmY6DBQ,437
59
60
  pyhw/frontend/logo/ascii/fedora.pyhw,sha256=IuFE6BByaNfVgn1pn7rKH7QVlIJyEmgGopCAOpXa6oM,742
60
61
  pyhw/frontend/logo/ascii/fedora_small.pyhw,sha256=_LSBzuCJjMa8pzmiJ3KN7Ndi-TryYPmtEfKqxxPAFfE,601
61
62
  pyhw/frontend/logo/ascii/linux.pyhw,sha256=IMe6YNElwCjLtv6kgSkERbATyyJAK531vcrT-otaLWE,300
62
63
  pyhw/frontend/logo/ascii/macOS.pyhw,sha256=HBGROtBb7wrNtRqAQ9ND7zxK0l17BRsmpgc2dMo_m6s,474
64
+ pyhw/frontend/logo/ascii/raspbian.pyhw,sha256=DLxiMzxBbO6siqSrw7bPGAoUonpvMkgGttwNW3eKDXE,751
63
65
  pyhw/frontend/logo/ascii/ubuntu.pyhw,sha256=l-Q0PfutxXYMwTojqeiM88063x4V0RBkZUHmi6YdsNc,833
64
66
  pyhw/frontend/logo/ascii/ubuntu_small.pyhw,sha256=Xf8LSZdZUu9aEG3efhb1FUlUEuJ-3UztcIOJISpKhPw,229
65
67
  pyhw/pyhwException/__init__.py,sha256=8JsFvtF13g0Y5t4z9fRndDXtfCzuBM59jDf6PhWSFSk,220
66
68
  pyhw/pyhwException/pyhwException.py,sha256=wxuzFQa9g7XB1q9TUKO_55lw7wMEJMpzG8w1GVTFVa0,197
67
69
  pyhw/pyhwUtil/__init__.py,sha256=PzeP9fXsIhvr3sUpJ4DxW9_H25DEIasBFfXd_NztfR4,226
68
- pyhw/pyhwUtil/pyhwUtil.py,sha256=Erobyk0R7jiXeSNWQ0Flj0-tNHJ5NZLONmGMF7jnUSM,2047
70
+ pyhw/pyhwUtil/pyhwUtil.py,sha256=qJREsuPU_lq7T0Ictc-_BkGEp0Zh24Ptq8aklkEe6GY,2292
69
71
  pyhw/pyhwUtil/sysctlUtil.py,sha256=S-rUvqi7ZrMyMouIhxlyHEQ4agM7sCT1Y7uzs3Hu5-o,841
70
- pyhw-0.2.1b0.dist-info/LICENSE,sha256=hJs6RBqSVCexbTsalkMLNFI5t06kekQEsSVaOt_-yLs,1497
71
- pyhw-0.2.1b0.dist-info/METADATA,sha256=1SBzPjhfcujNjeN2zwD5KhwwckmmtU7TzPVLqv-Ajl4,2510
72
- pyhw-0.2.1b0.dist-info/WHEEL,sha256=nCVcAvsfA9TDtwGwhYaRrlPhTLV9m-Ga6mdyDtuwK18,91
73
- pyhw-0.2.1b0.dist-info/entry_points.txt,sha256=q-AB8im_QahpmNrmy4aPTJRGi0LlbNlnI3kF7s6pKss,44
74
- pyhw-0.2.1b0.dist-info/top_level.txt,sha256=7Inxvxt1TngEricKZEex9_WJZS3DbKYFUXDz4v5WHYU,5
75
- pyhw-0.2.1b0.dist-info/RECORD,,
72
+ pyhw-0.2.3b0.dist-info/LICENSE,sha256=hJs6RBqSVCexbTsalkMLNFI5t06kekQEsSVaOt_-yLs,1497
73
+ pyhw-0.2.3b0.dist-info/METADATA,sha256=GON5FdvR7B60cuNqZ1MWx3c371J4cqldIgpTeEdnFNU,3914
74
+ pyhw-0.2.3b0.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
75
+ pyhw-0.2.3b0.dist-info/entry_points.txt,sha256=q-AB8im_QahpmNrmy4aPTJRGi0LlbNlnI3kF7s6pKss,44
76
+ pyhw-0.2.3b0.dist-info/top_level.txt,sha256=7Inxvxt1TngEricKZEex9_WJZS3DbKYFUXDz4v5WHYU,5
77
+ pyhw-0.2.3b0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (73.0.0)
2
+ Generator: setuptools (73.0.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5