pyhw 0.1.2b0__tar.gz → 0.2.0b0__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {pyhw-0.1.2b0/src/pyhw.egg-info → pyhw-0.2.0b0}/PKG-INFO +7 -4
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/README.md +6 -1
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/pyproject.toml +1 -1
- pyhw-0.2.0b0/src/pyhw/__main__.py +39 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/cpu/cpuBase.py +3 -0
- pyhw-0.2.0b0/src/pyhw/backend/cpu/cpuInfo.py +13 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/cpu/linux.py +8 -11
- pyhw-0.2.0b0/src/pyhw/backend/cpu/macos.py +69 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/gpu/gpuBase.py +3 -0
- pyhw-0.2.0b0/src/pyhw/backend/gpu/gpuInfo.py +8 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/gpu/linux.py +3 -9
- pyhw-0.2.0b0/src/pyhw/backend/gpu/macos.py +63 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/host/hostBase.py +1 -1
- pyhw-0.2.0b0/src/pyhw/backend/host/hostInfo.py +13 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/host/linux.py +2 -14
- pyhw-0.2.0b0/src/pyhw/backend/host/macos.py +269 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/kernel/kernelBase.py +4 -4
- pyhw-0.2.0b0/src/pyhw/backend/kernel/kernelInfo.py +10 -0
- pyhw-0.1.2b0/src/pyhw/backend/kernel/linux.py → pyhw-0.2.0b0/src/pyhw/backend/kernel/unix.py +3 -14
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/memory/linux.py +2 -10
- pyhw-0.2.0b0/src/pyhw/backend/memory/macos.py +56 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/memory/memoryBase.py +3 -0
- pyhw-0.2.0b0/src/pyhw/backend/memory/memoryInfo.py +10 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/os/linux.py +2 -17
- pyhw-0.2.0b0/src/pyhw/backend/os/macos.py +36 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/os/osBase.py +3 -0
- pyhw-0.2.0b0/src/pyhw/backend/os/osInfo.py +17 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/uptime/linux.py +5 -10
- pyhw-0.2.0b0/src/pyhw/backend/uptime/macos.py +40 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/uptime/uptimeBase.py +3 -0
- pyhw-0.2.0b0/src/pyhw/backend/uptime/uptimeInfo.py +7 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/frontend/frontendBase.py +1 -1
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/pyhwUtil/__init__.py +2 -1
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/pyhwUtil/pyhwUtil.py +18 -14
- pyhw-0.2.0b0/src/pyhw/pyhwUtil/sysctlUtil.py +37 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0/src/pyhw.egg-info}/PKG-INFO +7 -4
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw.egg-info/SOURCES.txt +15 -4
- pyhw-0.1.2b0/setup.py +0 -28
- pyhw-0.1.2b0/src/pyhw/__main__.py +0 -37
- pyhw-0.1.2b0/src/pyhw/backend/host/macos.py +0 -5
- pyhw-0.1.2b0/src/pyhw/backend/kernel/macos.py +0 -7
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/LICENSE +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/MANIFEST.in +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/setup.cfg +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/__init__.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/__init__.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/backendBase.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/cpu/__init__.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/gpu/__init__.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/host/__init__.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/host/windows.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/kernel/__init__.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/kernel/windows.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/memory/__init__.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/metal/t.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/os/__init__.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/shell/__init__.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/shell/shellBase.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/shell/unix.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/title/__init__.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/title/titleBase.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/title/unix.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/title/windows.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/backend/uptime/__init__.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/frontend/__init__.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/frontend/color/__init__.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/frontend/color/colorConfig.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/frontend/color/colorSet.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/frontend/color/colorUtil.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/frontend/logo/__init__.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/frontend/logo/ascii/debian.pyhw +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/frontend/logo/ascii/fedora.pyhw +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/frontend/logo/ascii/fedora_small.pyhw +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/frontend/logo/ascii/linux.pyhw +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/frontend/logo/ascii/macOS.pyhw +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/frontend/logo/ascii/ubuntu.pyhw +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/frontend/logo/ascii/ubuntu_small.pyhw +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/frontend/logo/logoBase.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/macos.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/pyhwException/__init__.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw/pyhwException/pyhwException.py +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw.egg-info/dependency_links.txt +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw.egg-info/entry_points.txt +0 -0
- {pyhw-0.1.2b0 → pyhw-0.2.0b0}/src/pyhw.egg-info/top_level.txt +0 -0
@@ -1,9 +1,7 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: pyhw
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.2.0b0
|
4
4
|
Summary: PyHw, a neofetch-like command line tool for fetching system information but written mostly in python.
|
5
|
-
Home-page: https://github.com/xiaoran007/pyhw
|
6
|
-
Author: Xiao Ran
|
7
5
|
Author-email: Xiao Ran <xiaoran.007@icloud.com>
|
8
6
|
License: BSD-3-Clause
|
9
7
|
Project-URL: homepage, https://github.com/xiaoran007/pyhw
|
@@ -15,7 +13,12 @@ Description-Content-Type: text/markdown
|
|
15
13
|
License-File: LICENSE
|
16
14
|
|
17
15
|
# PyHw
|
18
|
-
|
16
|
+

|
17
|
+

|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
PyHw, a neofetch-like command line tool for fetching system information but written mostly in Python. **Currently, this project is still in the initial stage, only part of the linux systems and macOS are supported.**
|
19
22
|
|
20
23
|
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 🤔)
|
21
24
|
|
@@ -1,5 +1,10 @@
|
|
1
1
|
# PyHw
|
2
|
-
|
2
|
+

|
3
|
+

|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
PyHw, a neofetch-like command line tool for fetching system information but written mostly in Python. **Currently, this project is still in the initial stage, only part of the linux systems and macOS are supported.**
|
3
8
|
|
4
9
|
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 🤔)
|
5
10
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "pyhw"
|
7
|
-
version = "0.
|
7
|
+
version = "0.2.0b"
|
8
8
|
description = "PyHw, a neofetch-like command line tool for fetching system information but written mostly in python."
|
9
9
|
authors = [
|
10
10
|
{ name = "Xiao Ran", email = "xiaoran.007@icloud.com" }
|
@@ -0,0 +1,39 @@
|
|
1
|
+
from .frontend import Printer
|
2
|
+
from .backend import Data
|
3
|
+
from .backend.title import TitleDetect
|
4
|
+
from .backend.host import HostDetect
|
5
|
+
from .backend.kernel import KernelDetect
|
6
|
+
from .backend.shell import ShellDetect
|
7
|
+
from .backend.uptime import UptimeDetect
|
8
|
+
from .backend.os import OSDetect
|
9
|
+
from .backend.cpu import CPUDetect
|
10
|
+
from .backend.gpu import GPUDetect
|
11
|
+
from .backend.memory import MemoryDetect
|
12
|
+
from .pyhwUtil import createDataString
|
13
|
+
from .pyhwUtil import getOS, selectOSLogo
|
14
|
+
|
15
|
+
|
16
|
+
def main():
|
17
|
+
current_os = getOS()
|
18
|
+
print("This is a test version of PyHw. Currently, it only supports Linux and macOS.")
|
19
|
+
if current_os != "linux" and current_os != "macos":
|
20
|
+
print(f"Only Linux and macOS is supported for now. Current os: {current_os}")
|
21
|
+
return
|
22
|
+
data = Data()
|
23
|
+
data.title = TitleDetect(os=current_os).getTitle().title
|
24
|
+
data.Host = HostDetect(os=current_os).getHostInfo().model
|
25
|
+
data.Kernel = KernelDetect(os=current_os).getKernelInfo().kernel
|
26
|
+
data.Shell = ShellDetect(os=current_os).getShellInfo().info
|
27
|
+
data.Uptime = UptimeDetect(os=current_os).getUptime().uptime
|
28
|
+
data.OS = OSDetect(os=current_os).getOSInfo().prettyName
|
29
|
+
data.CPU = CPUDetect(os=current_os).getCPUInfo().cpu
|
30
|
+
gpu_info = GPUDetect(os=current_os).getGPUInfo()
|
31
|
+
if gpu_info.number > 0:
|
32
|
+
data.GPU = gpu_info.gpus
|
33
|
+
data.Memory = MemoryDetect(os=current_os).getMemoryInfo().memory
|
34
|
+
|
35
|
+
Printer(logo_os=selectOSLogo(OSDetect(os=current_os).getOSInfo().id), data=createDataString(data)).cPrint()
|
36
|
+
|
37
|
+
|
38
|
+
if __name__ == "__main__":
|
39
|
+
main()
|
@@ -1,4 +1,5 @@
|
|
1
1
|
from .linux import CPUDetectLinux
|
2
|
+
from .macos import CPUDetectMacOS
|
2
3
|
from ...pyhwException import OSUnsupportedException
|
3
4
|
|
4
5
|
|
@@ -9,5 +10,7 @@ class CPUDetect:
|
|
9
10
|
def getCPUInfo(self):
|
10
11
|
if self.OS == "linux":
|
11
12
|
return CPUDetectLinux().getCPUInfo()
|
13
|
+
elif self.OS == "macos":
|
14
|
+
return CPUDetectMacOS().getCPUInfo()
|
12
15
|
else:
|
13
16
|
raise OSUnsupportedException("Unsupported operating system")
|
@@ -1,22 +1,15 @@
|
|
1
|
-
from dataclasses import dataclass
|
2
1
|
import re
|
3
2
|
import os
|
4
|
-
|
5
|
-
|
6
|
-
@dataclass
|
7
|
-
class CPUInfoLinux:
|
8
|
-
cpu = ""
|
9
|
-
model = ""
|
10
|
-
cores = ""
|
11
|
-
frequency = ""
|
3
|
+
from .cpuInfo import CPUInfo
|
12
4
|
|
13
5
|
|
14
6
|
class CPUDetectLinux:
|
15
7
|
def __init__(self):
|
16
|
-
self.__cpuInfo =
|
8
|
+
self.__cpuInfo = CPUInfo()
|
17
9
|
|
18
10
|
def getCPUInfo(self):
|
19
11
|
self.__getCPUInfo()
|
12
|
+
self.__modelClean()
|
20
13
|
if self.__cpuInfo.model != "":
|
21
14
|
self.__cpuInfo.cpu = self.__cpuInfo.model
|
22
15
|
if self.__cpuInfo.cores != "":
|
@@ -52,5 +45,9 @@ class CPUDetectLinux:
|
|
52
45
|
else:
|
53
46
|
for line in cpu_info.split("\n"):
|
54
47
|
if line.startswith("cpu MHz") or line.startswith("clock"):
|
55
|
-
self.__cpuInfo.frequency = float(line.split(
|
48
|
+
self.__cpuInfo.frequency = f"{round(float(line.split(':')[1].strip()) / 1000, 2)} Ghz" # Ghz
|
56
49
|
break
|
50
|
+
|
51
|
+
def __modelClean(self):
|
52
|
+
self.__cpuInfo.model = self.__cpuInfo.model.replace("(R)", "")
|
53
|
+
self.__cpuInfo.model = self.__cpuInfo.model.replace("(TM)", "")
|
@@ -0,0 +1,69 @@
|
|
1
|
+
from .cpuInfo import CPUInfo
|
2
|
+
from ...pyhwUtil import sysctlGetString, sysctlGetInt, getArch
|
3
|
+
|
4
|
+
|
5
|
+
class CPUDetectMacOS:
|
6
|
+
def __init__(self):
|
7
|
+
self.__cpuInfo = CPUInfo()
|
8
|
+
self.__arch = getArch()
|
9
|
+
self.__pCore = 0
|
10
|
+
self.__eCore = 0
|
11
|
+
|
12
|
+
def getCPUInfo(self):
|
13
|
+
if self.__arch == "aarch64":
|
14
|
+
self.__getCPUModel()
|
15
|
+
self.__AppleSiliconBaseFrequency()
|
16
|
+
self.__handleAppleSilicon()
|
17
|
+
self.__cpuInfo.cpu = f"{self.__cpuInfo.model} ({self.__pCore}P, {self.__eCore}E) @ {self.__cpuInfo.frequency}"
|
18
|
+
else:
|
19
|
+
self.__getCPUModel()
|
20
|
+
self.__getCPUCores()
|
21
|
+
self.__getCPUFrequency()
|
22
|
+
# need test on Intel Macs.
|
23
|
+
self.__cpuInfo.cpu = f"{self.__cpuInfo.model.replace('CPU', f'({self.__cpuInfo.cores})')}"
|
24
|
+
return self.__cpuInfo
|
25
|
+
|
26
|
+
def __getCPUModel(self):
|
27
|
+
model = sysctlGetString("machdep.cpu.brand_string")
|
28
|
+
model = model.replace("(R)", "")
|
29
|
+
model = model.replace("(TM)", "")
|
30
|
+
self.__cpuInfo.model = model
|
31
|
+
|
32
|
+
def __getCPUCores(self):
|
33
|
+
cores = sysctlGetString("hw.logicalcpu_max")
|
34
|
+
self.__cpuInfo.cores = cores
|
35
|
+
|
36
|
+
def __getCPUFrequency(self):
|
37
|
+
# sysctl doesn't provide the exact CPU frequency on Apple Silicon Macs, there are some indirect methods
|
38
|
+
# to get the CPU frequency, but can not integrate with Python directly.
|
39
|
+
# C-Based helper module will be added later.
|
40
|
+
# See https://github.com/fastfetch-cli/fastfetch/blob/dev/src/detection/cpu/cpu_apple.c for more details.
|
41
|
+
freq = sysctlGetString("hw.cpufrequency")
|
42
|
+
self.__cpuInfo.frequency = freq
|
43
|
+
|
44
|
+
def __handleAppleSilicon(self):
|
45
|
+
nlevels = sysctlGetInt("hw.nperflevels")
|
46
|
+
if nlevels is not None and nlevels == 2: # currently, Apple Silicon chip only has 2 performance levels.
|
47
|
+
pcore = sysctlGetInt("hw.perflevel0.logicalcpu_max") # level 0 is P-core
|
48
|
+
ecore = sysctlGetInt("hw.perflevel1.logicalcpu_max") # level 1 is E-core
|
49
|
+
if pcore is not None and ecore is not None:
|
50
|
+
self.__pCore = pcore
|
51
|
+
self.__eCore = ecore
|
52
|
+
|
53
|
+
def __AppleSiliconBaseFrequency(self):
|
54
|
+
# see https://en.wikipedia.org/wiki/Apple_silicon#M_series for more details.
|
55
|
+
freq = {
|
56
|
+
"Apple M1": "2.30 GHz",
|
57
|
+
"Apple M1 Pro": "2.32 GHz",
|
58
|
+
"Apple M1 Max": "2.32 GHz",
|
59
|
+
"Apple M1 Ultra": "2.32 GHz",
|
60
|
+
"Apple M2": "3.50 GHz",
|
61
|
+
"Apple M2 Pro": "3.50 GHz",
|
62
|
+
"Apple M2 Max": "3.69 GHz",
|
63
|
+
"Apple M2 Ultra": "3.70 Ghz",
|
64
|
+
"Apple M3": "4.05 GHz",
|
65
|
+
"Apple M3 Pro": "4.05 GHz",
|
66
|
+
"Apple M3 Max": "4.05 GHz",
|
67
|
+
"Apple M4": "4.40 GHz"
|
68
|
+
}
|
69
|
+
self.__cpuInfo.frequency = freq.get(self.__cpuInfo.model, "Unknown")
|
@@ -1,4 +1,5 @@
|
|
1
1
|
from .linux import GPUDetectLinux
|
2
|
+
from .macos import GPUDetectMacOS
|
2
3
|
|
3
4
|
|
4
5
|
class GPUDetect:
|
@@ -8,5 +9,7 @@ class GPUDetect:
|
|
8
9
|
def getGPUInfo(self):
|
9
10
|
if self.OS == "linux":
|
10
11
|
return GPUDetectLinux().getGPUInfo()
|
12
|
+
elif self.OS == "macos":
|
13
|
+
return GPUDetectMacOS().getGPUInfo()
|
11
14
|
else:
|
12
15
|
raise NotImplementedError("Unsupported operating system")
|
@@ -1,18 +1,12 @@
|
|
1
1
|
import subprocess
|
2
|
-
from
|
2
|
+
from .gpuInfo import GPUInfo
|
3
3
|
from ..cpu import CPUDetect
|
4
4
|
from ...pyhwUtil import getArch
|
5
5
|
|
6
6
|
|
7
|
-
@dataclass
|
8
|
-
class GPUInfoLinux:
|
9
|
-
number = 0
|
10
|
-
gpus = []
|
11
|
-
|
12
|
-
|
13
7
|
class GPUDetectLinux:
|
14
8
|
def __init__(self):
|
15
|
-
self.__gpuInfo =
|
9
|
+
self.__gpuInfo = GPUInfo()
|
16
10
|
|
17
11
|
def getGPUInfo(self):
|
18
12
|
self.__getGPUInfo()
|
@@ -37,7 +31,7 @@ class GPUDetectLinux:
|
|
37
31
|
# if detector can't find any VGA/Display/3D GPUs, assume the host is a sbc device, this function is a placeholder for a more advanced method.
|
38
32
|
if getArch() == "aarch64" or getArch() == "arm32":
|
39
33
|
self.__gpuInfo.number = 1
|
40
|
-
self.__gpuInfo.gpus.append(f"{CPUDetect(os='linux').getCPUInfo().model}
|
34
|
+
self.__gpuInfo.gpus.append(f"{CPUDetect(os='linux').getCPUInfo().model} [SOC Integrated]")
|
41
35
|
else:
|
42
36
|
self.__gpuInfo.number = 1
|
43
37
|
self.__gpuInfo.gpus.append("Not found")
|
@@ -0,0 +1,63 @@
|
|
1
|
+
from .gpuInfo import GPUInfo
|
2
|
+
from ...pyhwUtil import getArch
|
3
|
+
import json
|
4
|
+
import subprocess
|
5
|
+
|
6
|
+
|
7
|
+
class GPUDetectMacOS:
|
8
|
+
def __init__(self):
|
9
|
+
self.__gpuInfo = GPUInfo()
|
10
|
+
self.__arch = getArch()
|
11
|
+
|
12
|
+
def getGPUInfo(self):
|
13
|
+
if self.__arch == "aarch64":
|
14
|
+
self.__getGPUAppleSilicon()
|
15
|
+
else: # Does not consider powerPC based Macs.
|
16
|
+
self.__getGPUIntel()
|
17
|
+
return self.__gpuInfo
|
18
|
+
|
19
|
+
def __getGPUAppleSilicon(self):
|
20
|
+
gpus = list()
|
21
|
+
try:
|
22
|
+
gpu_info_dict = json.loads(subprocess.check_output(["system_profiler", "SPDisplaysDataType", "-json"]))
|
23
|
+
if 'SPDisplaysDataType' in gpu_info_dict:
|
24
|
+
gpus = gpu_info_dict['SPDisplaysDataType']
|
25
|
+
self.__gpuInfo.number = len(gpus)
|
26
|
+
else:
|
27
|
+
pass
|
28
|
+
except Exception:
|
29
|
+
return
|
30
|
+
|
31
|
+
for gpu in gpus:
|
32
|
+
self.__gpuInfo.gpus.append(f'{gpu.get("sppci_model")} ({gpu.get("sppci_cores")} cores) [SOC Integrated]')
|
33
|
+
|
34
|
+
def __getGPUIntel(self):
|
35
|
+
gpus = list()
|
36
|
+
try:
|
37
|
+
gpu_info_dict = json.loads(subprocess.check_output(["system_profiler", "SPDisplaysDataType", "-json"]))
|
38
|
+
if 'SPDisplaysDataType' in gpu_info_dict:
|
39
|
+
gpus = gpu_info_dict['SPDisplaysDataType']
|
40
|
+
self.__gpuInfo.number = len(gpus)
|
41
|
+
else:
|
42
|
+
pass
|
43
|
+
except Exception:
|
44
|
+
return
|
45
|
+
|
46
|
+
for gpu in gpus:
|
47
|
+
if self.__handleVendor(gpu.get("spdisplays_vendor")) == "Intel": # Integrated GPU
|
48
|
+
self.__gpuInfo.gpus.append(f'{gpu.get("sppci_model")} [CPU Integrated]')
|
49
|
+
elif self.__handleVendor(gpu.get("spdisplays_vendor")) == "AMD": # dGPU
|
50
|
+
self.__gpuInfo.gpus.append(f'{gpu.get("sppci_model")} [Discrete]')
|
51
|
+
elif self.__handleVendor(gpu.get("spdisplays_vendor")) == "Nvidia": # Since current macOS does not support NVIDIA GPUs, this condition is not applicable
|
52
|
+
pass
|
53
|
+
|
54
|
+
@staticmethod
|
55
|
+
def __handleVendor(vendor):
|
56
|
+
if vendor == "sppci_vendor_Apple":
|
57
|
+
return "Apple"
|
58
|
+
elif vendor == "sppci_vendor_intel":
|
59
|
+
return "Intel"
|
60
|
+
elif vendor == "sppci_vendor_amd":
|
61
|
+
return "AMD"
|
62
|
+
else:
|
63
|
+
return vendor
|
@@ -2,24 +2,12 @@
|
|
2
2
|
In dev.
|
3
3
|
"""
|
4
4
|
from ...pyhwUtil import getArch
|
5
|
-
from
|
6
|
-
|
7
|
-
|
8
|
-
@dataclass
|
9
|
-
class HostInfoLinux:
|
10
|
-
model = ""
|
11
|
-
family = ""
|
12
|
-
name = ""
|
13
|
-
version = ""
|
14
|
-
sku = ""
|
15
|
-
serial = ""
|
16
|
-
uuid = ""
|
17
|
-
vendor = ""
|
5
|
+
from .hostInfo import HostInfo
|
18
6
|
|
19
7
|
|
20
8
|
class HostDetectLinux:
|
21
9
|
def __init__(self):
|
22
|
-
self.__hostInfo =
|
10
|
+
self.__hostInfo = HostInfo()
|
23
11
|
self.__arch = getArch()
|
24
12
|
|
25
13
|
def getHostInfo(self):
|