pyhw 0.10.2__tar.gz → 0.11.0__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {pyhw-0.10.2/src/pyhw.egg-info → pyhw-0.11.0}/PKG-INFO +2 -2
- {pyhw-0.10.2 → pyhw-0.11.0}/pyproject.toml +2 -2
- pyhw-0.11.0/src/pyhw/__init__.py +1 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/__main__.py +23 -27
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/pyhwUtil/__init__.py +2 -1
- pyhw-0.11.0/src/pyhw/pyhwUtil/cliUtil.py +62 -0
- {pyhw-0.10.2 → pyhw-0.11.0/src/pyhw.egg-info}/PKG-INFO +2 -2
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw.egg-info/SOURCES.txt +3 -1
- pyhw-0.11.0/src/pyhw.egg-info/requires.txt +1 -0
- pyhw-0.11.0/test/test_cliUtil.py +74 -0
- pyhw-0.10.2/src/pyhw/__init__.py +0 -1
- pyhw-0.10.2/src/pyhw.egg-info/requires.txt +0 -1
- {pyhw-0.10.2 → pyhw-0.11.0}/LICENSE +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/README.md +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/setup.cfg +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/__init__.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/backendBase.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/cpu/__init__.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/cpu/bsd.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/cpu/cpuBase.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/cpu/cpuInfo.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/cpu/linux.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/cpu/macos.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/cpu/windows.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/gpu/__init__.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/gpu/bsd.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/gpu/gpuBase.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/gpu/gpuInfo.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/gpu/linux.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/gpu/macos.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/gpu/windows.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/host/__init__.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/host/bsd.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/host/hostBase.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/host/hostInfo.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/host/linux.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/host/macos.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/host/windows.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/kernel/__init__.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/kernel/kernelBase.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/kernel/kernelInfo.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/kernel/unix.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/kernel/windows.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/memory/__init__.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/memory/bsd.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/memory/linux.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/memory/macos.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/memory/memoryBase.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/memory/memoryInfo.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/memory/windows.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/metal/t.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/nic/__init__.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/nic/bsd.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/nic/linux.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/nic/macos.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/nic/nicBase.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/nic/nicInfo.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/nic/windows.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/npu/__init__.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/npu/bsd.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/npu/linux.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/npu/macos.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/npu/npuBase.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/npu/npuInfo.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/npu/windows.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/os/__init__.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/os/bsd.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/os/linux.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/os/macos.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/os/osBase.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/os/osInfo.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/os/windows.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/shell/__init__.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/shell/shellBase.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/shell/shellInfo.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/shell/unix.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/shell/windows.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/title/__init__.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/title/titleBase.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/title/titleInfo.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/title/unix.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/title/windows.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/uptime/__init__.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/uptime/bsd.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/uptime/linux.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/uptime/macos.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/uptime/uptimeBase.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/uptime/uptimeInfo.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/backend/uptime/windows.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/__init__.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/color/__init__.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/color/colorConfig.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/color/colorSet.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/color/colorUtil.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/frontendBase.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/logo/__init__.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/logo/ascii/alpine.pyhw +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/logo/ascii/arch.pyhw +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/logo/ascii/armbian.pyhw +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/logo/ascii/centos.pyhw +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/logo/ascii/debian.pyhw +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/logo/ascii/fedora.pyhw +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/logo/ascii/fedora_small.pyhw +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/logo/ascii/freebsd.pyhw +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/logo/ascii/linux.pyhw +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/logo/ascii/macOS.pyhw +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/logo/ascii/raspbian.pyhw +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/logo/ascii/ubuntu.pyhw +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/logo/ascii/ubuntu_small.pyhw +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/logo/ascii/windows_10.pyhw +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/logo/ascii/windows_11.pyhw +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/logo/ascii/windows_2025.pyhw +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/logo/ascii/windows_old.pyhw +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/frontend/logo/logoBase.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/library/lib/iokitGPULib.dylib +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/pyhwException/__init__.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/pyhwException/pyhwException.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/pyhwUtil/pyhwUtil.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw/pyhwUtil/sysctlUtil.py +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw.egg-info/dependency_links.txt +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw.egg-info/entry_points.txt +0 -0
- {pyhw-0.10.2 → pyhw-0.11.0}/src/pyhw.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: pyhw
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.11.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
|
@@ -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.
|
16
|
+
Requires-Dist: pypci-ng>=0.1.4
|
17
17
|
|
18
18
|
# PyHw
|
19
19
|
[](https://pepy.tech/project/pyhw)
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "pyhw"
|
7
|
-
version = "0.
|
7
|
+
version = "0.11.0"
|
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 = [
|
@@ -14,7 +14,7 @@ readme = "README.md"
|
|
14
14
|
license = {text = "BSD-3-Clause"}
|
15
15
|
requires-python = ">=3.9"
|
16
16
|
dependencies = [
|
17
|
-
"pypci-ng>=0.1.
|
17
|
+
"pypci-ng>=0.1.4"
|
18
18
|
]
|
19
19
|
classifiers = [
|
20
20
|
"Development Status :: 4 - Beta",
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = '0.11.0'
|
@@ -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
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
#
|
115
|
-
#
|
116
|
-
#
|
117
|
-
#
|
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__":
|
@@ -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.
|
3
|
+
Version: 0.11.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
|
@@ -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.
|
16
|
+
Requires-Dist: pypci-ng>=0.1.4
|
17
17
|
|
18
18
|
# PyHw
|
19
19
|
[](https://pepy.tech/project/pyhw)
|
@@ -112,5 +112,7 @@ src/pyhw/library/lib/iokitGPULib.dylib
|
|
112
112
|
src/pyhw/pyhwException/__init__.py
|
113
113
|
src/pyhw/pyhwException/pyhwException.py
|
114
114
|
src/pyhw/pyhwUtil/__init__.py
|
115
|
+
src/pyhw/pyhwUtil/cliUtil.py
|
115
116
|
src/pyhw/pyhwUtil/pyhwUtil.py
|
116
|
-
src/pyhw/pyhwUtil/sysctlUtil.py
|
117
|
+
src/pyhw/pyhwUtil/sysctlUtil.py
|
118
|
+
test/test_cliUtil.py
|
@@ -0,0 +1 @@
|
|
1
|
+
pypci-ng>=0.1.4
|
@@ -0,0 +1,74 @@
|
|
1
|
+
import pytest
|
2
|
+
import sys
|
3
|
+
import site
|
4
|
+
import os
|
5
|
+
import json
|
6
|
+
from unittest.mock import MagicMock
|
7
|
+
from pyhw.pyhwUtil.cliUtil import ReleaseChecker
|
8
|
+
|
9
|
+
|
10
|
+
@pytest.mark.parametrize("sys_prefix, site_packages, env_vars, expected", [
|
11
|
+
("pipx", [], {}, True),
|
12
|
+
("normal_prefix", ["/some/path/pipx"], {}, True),
|
13
|
+
("normal_prefix", [], {"PIPX_BIN_DIR": "/some/dir"}, True),
|
14
|
+
("normal_prefix", [], {}, False)
|
15
|
+
])
|
16
|
+
def test_is_running_in_pipx(sys_prefix, site_packages, env_vars, expected, monkeypatch):
|
17
|
+
monkeypatch.setattr(sys, "prefix", sys_prefix)
|
18
|
+
monkeypatch.setattr(site, "getsitepackages", lambda: site_packages)
|
19
|
+
monkeypatch.setattr(os, "environ", env_vars)
|
20
|
+
|
21
|
+
checker = ReleaseChecker()
|
22
|
+
assert checker.isInPIPX == expected
|
23
|
+
|
24
|
+
|
25
|
+
@pytest.fixture
|
26
|
+
def mock_installed_version(monkeypatch):
|
27
|
+
def mock_version(package_name):
|
28
|
+
return "0.10.1" if package_name == "pyhw" else None
|
29
|
+
|
30
|
+
monkeypatch.setattr("importlib.metadata.version", mock_version)
|
31
|
+
|
32
|
+
|
33
|
+
def test_get_installed_version(mock_installed_version):
|
34
|
+
checker = ReleaseChecker()
|
35
|
+
assert checker.CurrentVersion == "0.10.1"
|
36
|
+
|
37
|
+
|
38
|
+
@pytest.fixture
|
39
|
+
def mock_pypi_response(monkeypatch):
|
40
|
+
mock_response = MagicMock()
|
41
|
+
mock_response.__enter__.return_value = mock_response
|
42
|
+
mock_response.read.return_value = json.dumps({"info": {"version": "0.11.0"}}).encode()
|
43
|
+
|
44
|
+
monkeypatch.setattr("urllib.request.urlopen", lambda *args, **kwargs: mock_response)
|
45
|
+
|
46
|
+
|
47
|
+
def test_get_latest_version(mock_pypi_response):
|
48
|
+
checker = ReleaseChecker()
|
49
|
+
assert checker.LatestVersion == "0.11.0"
|
50
|
+
|
51
|
+
|
52
|
+
@pytest.mark.parametrize("version, expected", [
|
53
|
+
("0.10.1", (0, 10, 1)),
|
54
|
+
("1.2.3", (1, 2, 3)),
|
55
|
+
("2.0.0", (2, 0, 0)),
|
56
|
+
("3.11.22", (3, 11, 22))
|
57
|
+
])
|
58
|
+
def test_parse_version(version, expected):
|
59
|
+
assert ReleaseChecker.parse_version(version) == expected
|
60
|
+
|
61
|
+
|
62
|
+
@pytest.mark.parametrize("installed, latest, expected", [
|
63
|
+
("0.10.1", "0.11.0", True),
|
64
|
+
("0.11.0", "0.11.0", False),
|
65
|
+
("0.12.0", "0.11.0", False),
|
66
|
+
(None, "0.11.0", False),
|
67
|
+
("0.10.1", None, False)
|
68
|
+
])
|
69
|
+
def test_is_newer_version(installed, latest, expected, monkeypatch):
|
70
|
+
monkeypatch.setattr(ReleaseChecker, "_ReleaseChecker__get_installed_version", lambda self: installed)
|
71
|
+
monkeypatch.setattr(ReleaseChecker, "_ReleaseChecker__get_latest_version", lambda self: latest)
|
72
|
+
|
73
|
+
checker = ReleaseChecker()
|
74
|
+
assert checker.check_for_updates() == expected
|
pyhw-0.10.2/src/pyhw/__init__.py
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
__version__ = '0.10.2'
|
@@ -1 +0,0 @@
|
|
1
|
-
pypci-ng>=0.1.3
|
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
|
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
|