pyhw 0.10.2__py3-none-any.whl → 0.11.1__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/__init__.py CHANGED
@@ -1 +1 @@
1
- __version__ = '0.10.2'
1
+ __version__ = '0.11.1'
pyhw/__main__.py CHANGED
@@ -13,9 +13,17 @@ 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
+ from .pyhwUtil import ReleaseChecker
16
17
  import multiprocessing
17
18
 
18
19
 
20
+ def check_release(release_dict):
21
+ releaseChecker = ReleaseChecker()
22
+ release_dict["is_new_release"] = releaseChecker.check_for_updates()
23
+ release_dict["release"] = releaseChecker.LatestVersion
24
+ release_dict["current"] = releaseChecker.CurrentVersion
25
+
26
+
19
27
  def detect_title(os, result_dict):
20
28
  result_dict["title"] = TitleDetect(os=os).getTitle().title
21
29
 
@@ -76,8 +84,10 @@ def main():
76
84
 
77
85
  manager = multiprocessing.Manager()
78
86
  result_dict = manager.dict()
87
+ release_dict = manager.dict()
79
88
 
80
89
  processes = [
90
+ multiprocessing.Process(target=check_release, args=(release_dict,)),
81
91
  multiprocessing.Process(target=detect_title, args=(current_os, result_dict)),
82
92
  multiprocessing.Process(target=detect_host, args=(current_os, result_dict)),
83
93
  multiprocessing.Process(target=detect_kernel, args=(current_os, result_dict)),
@@ -94,7 +104,7 @@ def main():
94
104
  for process in processes:
95
105
  process.start()
96
106
 
97
- for process in processes:
107
+ for process in processes[1:]:
98
108
  process.join()
99
109
 
100
110
  for key, value in result_dict.items():
@@ -103,32 +113,18 @@ def main():
103
113
  logo_os = selectOSLogo(OSDetect(os=current_os).getOSInfo().id)
104
114
  Printer(logo_os=logo_os, data=createDataString(data)).cPrint()
105
115
 
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()
116
+ processes[0].join()
117
+ if release_dict["is_new_release"]:
118
+ print(f"🔔 Found a newer version: v{release_dict['release']} (current: v{release_dict['current']})")
119
+ print("👉 You can use the following command to upgrade:")
120
+ if ReleaseChecker().isInPIPX:
121
+ print(f" pipx upgrade pyhw")
122
+ else:
123
+ print(f" pip install -U pyhw")
124
+ # else:
125
+ # # debug
126
+ # print("🎉 You are using the latest version of pyhw!")
127
+ # print(f"🔔 Release: v{release_dict['release']} (current: v{release_dict['current']})")
132
128
 
133
129
 
134
130
  if __name__ == "__main__":
pyhw/backend/npu/macos.py CHANGED
@@ -46,20 +46,20 @@ class NPUDetectMacOS:
46
46
  # see https://apple.fandom.com/wiki/Neural_Engine for more details.
47
47
  model_name = CPUDetect(os=getOS()).getCPUInfo().model
48
48
  npu = {
49
- "Apple M1": "Apple Neural Engine 16 Core [SOC Integrated]",
50
- "Apple M1 Pro": "Apple Neural Engine 16 Core [SOC Integrated]",
51
- "Apple M1 Max": "Apple Neural Engine 16 Core [SOC Integrated]",
52
- "Apple M1 Ultra": "Apple Neural Engine 32 Core [SOC Integrated]",
53
- "Apple M2": "Apple Neural Engine 16 Core [SOC Integrated]",
54
- "Apple M2 Pro": "Apple Neural Engine 16 Core [SOC Integrated]",
55
- "Apple M2 Max": "Apple Neural Engine 16 Core [SOC Integrated]",
56
- "Apple M2 Ultra": "Apple Neural Engine 32 Core [SOC Integrated]",
57
- "Apple M3": "Apple Neural Engine 16 Core [SOC Integrated]",
58
- "Apple M3 Pro": "Apple Neural Engine 16 Core [SOC Integrated]",
59
- "Apple M3 Max": "Apple Neural Engine 16 Core [SOC Integrated]",
60
- "Apple M4": "Apple Neural Engine 16 Core [SOC Integrated]",
61
- "Apple M4 Pro": "Apple Neural Engine 16 Core [SOC Integrated]",
62
- "Apple M4 Max": "Apple Neural Engine 16 Core [SOC Integrated]"
49
+ "Apple M1": "Apple Neural Engine 16 Cores (5 nm) [SOC Integrated]",
50
+ "Apple M1 Pro": "Apple Neural Engine 16 Cores (5 nm) [SOC Integrated]",
51
+ "Apple M1 Max": "Apple Neural Engine 16 Cores (5 nm) [SOC Integrated]",
52
+ "Apple M1 Ultra": "Apple Neural Engine 32 Cores (5 nm) [SOC Integrated]",
53
+ "Apple M2": "Apple Neural Engine 16 Cores (5 nm) [SOC Integrated]",
54
+ "Apple M2 Pro": "Apple Neural Engine 16 Cores (5 nm) [SOC Integrated]",
55
+ "Apple M2 Max": "Apple Neural Engine 16 Cores (5 nm) [SOC Integrated]",
56
+ "Apple M2 Ultra": "Apple Neural Engine 32 Cores (5 nm) [SOC Integrated]",
57
+ "Apple M3": "Apple Neural Engine 16 Cores (3 nm) [SOC Integrated]",
58
+ "Apple M3 Pro": "Apple Neural Engine 16 Cores (3 nm) [SOC Integrated]",
59
+ "Apple M3 Max": "Apple Neural Engine 16 Cores (3 nm) [SOC Integrated]",
60
+ "Apple M4": "Apple Neural Engine 16 Cores (3 nm) [SOC Integrated]",
61
+ "Apple M4 Pro": "Apple Neural Engine 16 Cores (3 nm) [SOC Integrated]",
62
+ "Apple M4 Max": "Apple Neural Engine 16 Cores (3 nm) [SOC Integrated]"
63
63
  }
64
64
  return npu.get(model_name, "Not Found")
65
65
 
pyhw/pyhwUtil/__init__.py CHANGED
@@ -1,4 +1,5 @@
1
1
  from .pyhwUtil import getOS, getArch, getDocker, createDataString, selectOSLogo
2
2
  from .sysctlUtil import sysctlGetString, sysctlGetInt
3
+ from .cliUtil import ReleaseChecker
3
4
 
4
- __all__ = ["getOS", "getArch", "getDocker", "createDataString", "selectOSLogo", "sysctlGetString", "sysctlGetInt"]
5
+ __all__ = ["getOS", "getArch", "getDocker", "createDataString", "selectOSLogo", "sysctlGetString", "sysctlGetInt", "ReleaseChecker"]
@@ -0,0 +1,62 @@
1
+ import sys
2
+ import site
3
+ import os
4
+ import urllib.request
5
+ import json
6
+ import importlib.metadata
7
+
8
+
9
+ class ReleaseChecker:
10
+ PACKAGE_NAME = "pyhw"
11
+
12
+ def __init__(self):
13
+ self.isInPIPX = self.__is_running_in_pipx()
14
+ self.CurrentVersion = self.__get_installed_version()
15
+ self.LatestVersion = self.__get_latest_version()
16
+
17
+ @staticmethod
18
+ def __is_running_in_pipx():
19
+ return (
20
+ "pipx" in sys.prefix or
21
+ any("pipx" in path for path in site.getsitepackages()) or
22
+ "PIPX_BIN_DIR" in os.environ
23
+ )
24
+
25
+ def __get_installed_version(self):
26
+ try:
27
+ return importlib.metadata.version(self.PACKAGE_NAME)
28
+ except importlib.metadata.PackageNotFoundError:
29
+ return None
30
+
31
+ def __get_latest_version(self):
32
+ url = f"https://pypi.org/pypi/{self.PACKAGE_NAME}/json"
33
+ try:
34
+ with urllib.request.urlopen(url, timeout=3) as response:
35
+ data = json.load(response)
36
+ return data["info"]["version"]
37
+ except Exception:
38
+ return None
39
+
40
+ @staticmethod
41
+ def parse_version(version):
42
+ return tuple(map(int, version.split(".")))
43
+
44
+ def __is_newer_version(self):
45
+ if self.CurrentVersion is None or self.LatestVersion is None:
46
+ return False
47
+ else:
48
+ return self.parse_version(self.CurrentVersion) < self.parse_version(self.LatestVersion)
49
+
50
+ def check_for_updates(self):
51
+ return self.__is_newer_version()
52
+
53
+ def check_for_updates_print(self):
54
+ if self.__is_newer_version():
55
+ print(f"🔔 Found newer version: {self.CurrentVersion} (current: {self.LatestVersion})")
56
+ print("👉 You can use the following command to upgrade:")
57
+ if self.isInPIPX:
58
+ print(f" pipx upgrade {self.PACKAGE_NAME}")
59
+ else:
60
+ print(f" pip install -U {self.PACKAGE_NAME}")
61
+
62
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: pyhw
3
- Version: 0.10.2
3
+ Version: 0.11.1
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
@@ -13,7 +13,7 @@ Classifier: Operating System :: OS Independent
13
13
  Requires-Python: >=3.9
14
14
  Description-Content-Type: text/markdown
15
15
  License-File: LICENSE
16
- Requires-Dist: pypci-ng>=0.1.3
16
+ Requires-Dist: pypci-ng>=0.1.4
17
17
 
18
18
  # PyHw
19
19
  [![Downloads](https://static.pepy.tech/badge/pyhw)](https://pepy.tech/project/pyhw)
@@ -1,5 +1,5 @@
1
- pyhw/__init__.py,sha256=KniWsK3VleHLcYbbhl5YHxNYNRusZE0zJco_WyUvAwI,23
2
- pyhw/__main__.py,sha256=Gp50LaRF9vl_czdLNJRoa0OIzctLKhcZU0XH3EjNVjM,4741
1
+ pyhw/__init__.py,sha256=3TWkE7T0Jt_0JSXR8Em3yqaM443tlkkxCPdXvSdnzBM,23
2
+ pyhw/__main__.py,sha256=Z8PQRp_hZrui2wZuHKW9hRorbYvy6Qc8szYbjj3t2io,4479
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
@@ -46,7 +46,7 @@ pyhw/backend/nic/windows.py,sha256=c67JwHARtPxNsZ-0_MVKUfc7DwpsRVn7kiHdx_NyDn8,1
46
46
  pyhw/backend/npu/__init__.py,sha256=PgLKbwpgT5vw9xpa294Zxb94McyxNXW46_vMbT2Iqyc,58
47
47
  pyhw/backend/npu/bsd.py,sha256=eKkOWZ4MBybR_KOGGcsWUpzCGgghhvuBy5VNsnEE8cI,134
48
48
  pyhw/backend/npu/linux.py,sha256=fPsaXClSC-Py2kHRi17y4eGWrjwRDmjsIX4lgMxRVPc,1806
49
- pyhw/backend/npu/macos.py,sha256=c-iSmGfBWYeoh7nXuCFmPlVH6bc6sil_yRsAlabl93k,2513
49
+ pyhw/backend/npu/macos.py,sha256=qOIXfWILnA-sAKH6nq_cep7BlH0rKk4bglc1VgyKp6U,2625
50
50
  pyhw/backend/npu/npuBase.py,sha256=1cVWRmr8g-mDXrJAx2cUO4qWZft2TtT7L2-HzRot2nI,748
51
51
  pyhw/backend/npu/npuInfo.py,sha256=82dK6XvW_XKw4O5-RfR4-qQRR7Plh8qqJLj0YDzISmU,135
52
52
  pyhw/backend/npu/windows.py,sha256=Z2v5CORSa1ap66k48G7uVLbon3zaoT4ug5sX2_rt6vM,1196
@@ -102,12 +102,13 @@ pyhw/frontend/logo/ascii/windows_old.pyhw,sha256=AMsvWAZ50HM8lweWEmzDWbRNDGkKFJo
102
102
  pyhw/library/lib/iokitGPULib.dylib,sha256=KAz0VyeRspD3U7WeedUnPvJVUZEKn_Pw0AKk5zm42ZM,154808
103
103
  pyhw/pyhwException/__init__.py,sha256=8JsFvtF13g0Y5t4z9fRndDXtfCzuBM59jDf6PhWSFSk,220
104
104
  pyhw/pyhwException/pyhwException.py,sha256=wxuzFQa9g7XB1q9TUKO_55lw7wMEJMpzG8w1GVTFVa0,197
105
- pyhw/pyhwUtil/__init__.py,sha256=diIqlNUBfuHu-2VAOJk5nipGLafnWxR3chAAOmX8QRo,250
105
+ pyhw/pyhwUtil/__init__.py,sha256=34ygvVBBqfJ_9OMzHToCcV_BVahixNsa_Z5yh6VsaPQ,304
106
+ pyhw/pyhwUtil/cliUtil.py,sha256=SuXAs-ousXw6h5i8psazJEP5Q9X5VaxZlxhPSFYdM-4,1933
106
107
  pyhw/pyhwUtil/pyhwUtil.py,sha256=TxAgsDlrz-AJFyeXnOjL1MVnh1uR9dEqli5dmYPZcog,6915
107
108
  pyhw/pyhwUtil/sysctlUtil.py,sha256=S-rUvqi7ZrMyMouIhxlyHEQ4agM7sCT1Y7uzs3Hu5-o,841
108
- pyhw-0.10.2.dist-info/LICENSE,sha256=hJs6RBqSVCexbTsalkMLNFI5t06kekQEsSVaOt_-yLs,1497
109
- pyhw-0.10.2.dist-info/METADATA,sha256=NlYsXDWh6YlpRrkrC0Z4HKu1IsXmxAE0zcLevOMYPqw,6732
110
- pyhw-0.10.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
111
- pyhw-0.10.2.dist-info/entry_points.txt,sha256=q-AB8im_QahpmNrmy4aPTJRGi0LlbNlnI3kF7s6pKss,44
112
- pyhw-0.10.2.dist-info/top_level.txt,sha256=7Inxvxt1TngEricKZEex9_WJZS3DbKYFUXDz4v5WHYU,5
113
- pyhw-0.10.2.dist-info/RECORD,,
109
+ pyhw-0.11.1.dist-info/LICENSE,sha256=hJs6RBqSVCexbTsalkMLNFI5t06kekQEsSVaOt_-yLs,1497
110
+ pyhw-0.11.1.dist-info/METADATA,sha256=9ioJk1jICjlBRXiqGga7j1PHyioTisnFddbE7lIAJzU,6732
111
+ pyhw-0.11.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
112
+ pyhw-0.11.1.dist-info/entry_points.txt,sha256=q-AB8im_QahpmNrmy4aPTJRGi0LlbNlnI3kF7s6pKss,44
113
+ pyhw-0.11.1.dist-info/top_level.txt,sha256=7Inxvxt1TngEricKZEex9_WJZS3DbKYFUXDz4v5WHYU,5
114
+ pyhw-0.11.1.dist-info/RECORD,,
File without changes
File without changes