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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. pyhw/__main__.py +16 -14
  2. pyhw/backend/cpu/cpuBase.py +3 -0
  3. pyhw/backend/cpu/cpuInfo.py +13 -0
  4. pyhw/backend/cpu/linux.py +5 -11
  5. pyhw/backend/cpu/macos.py +69 -0
  6. pyhw/backend/gpu/gpuBase.py +3 -0
  7. pyhw/backend/gpu/gpuInfo.py +8 -0
  8. pyhw/backend/gpu/linux.py +3 -9
  9. pyhw/backend/gpu/macos.py +63 -0
  10. pyhw/backend/host/hostBase.py +1 -1
  11. pyhw/backend/host/hostInfo.py +13 -0
  12. pyhw/backend/host/linux.py +20 -19
  13. pyhw/backend/host/macos.py +265 -1
  14. pyhw/backend/kernel/kernelBase.py +4 -4
  15. pyhw/backend/kernel/kernelInfo.py +10 -0
  16. pyhw/backend/kernel/{linux.py → unix.py} +3 -14
  17. pyhw/backend/memory/linux.py +2 -10
  18. pyhw/backend/memory/macos.py +56 -0
  19. pyhw/backend/memory/memoryBase.py +3 -0
  20. pyhw/backend/memory/memoryInfo.py +10 -0
  21. pyhw/backend/os/linux.py +2 -17
  22. pyhw/backend/os/macos.py +36 -0
  23. pyhw/backend/os/osBase.py +3 -0
  24. pyhw/backend/os/osInfo.py +17 -0
  25. pyhw/backend/uptime/linux.py +5 -10
  26. pyhw/backend/uptime/macos.py +40 -0
  27. pyhw/backend/uptime/uptimeBase.py +3 -0
  28. pyhw/backend/uptime/uptimeInfo.py +7 -0
  29. pyhw/frontend/frontendBase.py +1 -1
  30. pyhw/pyhwUtil/__init__.py +2 -1
  31. pyhw/pyhwUtil/pyhwUtil.py +22 -14
  32. pyhw/pyhwUtil/sysctlUtil.py +37 -0
  33. {pyhw-0.1.3b0.dist-info → pyhw-0.2.1b0.dist-info}/METADATA +22 -3
  34. {pyhw-0.1.3b0.dist-info → pyhw-0.2.1b0.dist-info}/RECORD +38 -26
  35. {pyhw-0.1.3b0.dist-info → pyhw-0.2.1b0.dist-info}/WHEEL +1 -1
  36. pyhw/backend/kernel/macos.py +0 -7
  37. {pyhw-0.1.3b0.dist-info → pyhw-0.2.1b0.dist-info}/LICENSE +0 -0
  38. {pyhw-0.1.3b0.dist-info → pyhw-0.2.1b0.dist-info}/entry_points.txt +0 -0
  39. {pyhw-0.1.3b0.dist-info → pyhw-0.2.1b0.dist-info}/top_level.txt +0 -0
pyhw/__main__.py CHANGED
@@ -14,23 +14,25 @@ from .pyhwUtil import getOS, selectOSLogo
14
14
 
15
15
 
16
16
  def main():
17
- print("This is a test version of PyHw. Currently, it only supports Linux. Currently there are some display issues on small terminals.")
18
- if getOS() != "linux":
19
- print(f"Only Linux is supported for now. Current os: {getOS()}")
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}")
20
21
  return
21
22
  data = Data()
22
- data.title = TitleDetect(os="linux").getTitle().title
23
- data.Host = HostDetect(os="linux").getHostInfo().model
24
- data.Kernel = KernelDetect(os="linux").getKernelInfo().kernel
25
- data.Shell = ShellDetect(os="linux").getShellInfo().info
26
- data.Uptime = UptimeDetect(os="linux").getUptime().uptime
27
- data.OS = OSDetect(os="linux").getOSInfo().prettyName
28
- data.CPU = CPUDetect(os="linux").getCPUInfo().cpu
29
- if GPUDetect(os="linux").getGPUInfo().number > 0:
30
- data.GPU = GPUDetect(os="linux").getGPUInfo().gpus
31
- data.Memory = MemoryDetect(os="linux").getMemoryInfo().memory
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
32
34
 
33
- Printer(logo_os=selectOSLogo(OSDetect(os="linux").getOSInfo().id), data=createDataString(data)).cPrint()
35
+ Printer(logo_os=selectOSLogo(OSDetect(os=current_os).getOSInfo().id), data=createDataString(data)).cPrint()
34
36
 
35
37
 
36
38
  if __name__ == "__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")
@@ -0,0 +1,13 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass
5
+ class CPUInfo:
6
+ """
7
+ Class to store CPU information. Print key: cpu
8
+ """
9
+ def __init__(self):
10
+ self.cpu = ""
11
+ self.model = ""
12
+ self.cores = ""
13
+ self.frequency = ""
pyhw/backend/cpu/linux.py CHANGED
@@ -1,23 +1,17 @@
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 = CPUInfoLinux()
8
+ self.__cpuInfo = CPUInfo()
17
9
 
18
10
  def getCPUInfo(self):
19
11
  self.__getCPUInfo()
20
12
  self.__modelClean()
13
+ if self.__cpuInfo.model == "":
14
+ self.__cpuInfo.model = "Unknown"
21
15
  if self.__cpuInfo.model != "":
22
16
  self.__cpuInfo.cpu = self.__cpuInfo.model
23
17
  if self.__cpuInfo.cores != "":
@@ -53,7 +47,7 @@ class CPUDetectLinux:
53
47
  else:
54
48
  for line in cpu_info.split("\n"):
55
49
  if line.startswith("cpu MHz") or line.startswith("clock"):
56
- self.__cpuInfo.frequency = float(line.split(":")[1].strip()) / 1000 # Ghz
50
+ self.__cpuInfo.frequency = f"{round(float(line.split(':')[1].strip()) / 1000, 2)} Ghz" # Ghz
57
51
  break
58
52
 
59
53
  def __modelClean(self):
@@ -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")
@@ -0,0 +1,8 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass
5
+ class GPUInfo:
6
+ def __init__(self):
7
+ self.number = 0
8
+ self.gpus = []
pyhw/backend/gpu/linux.py CHANGED
@@ -1,18 +1,12 @@
1
1
  import subprocess
2
- from dataclasses import dataclass
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 = GPUInfoLinux()
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} (SOC Integrated Graphics)")
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
@@ -12,7 +12,7 @@ class HostDetect:
12
12
  if self.OS == "linux":
13
13
  return HostDetectLinux().getHostInfo()
14
14
  elif self.OS == "macos":
15
- pass
15
+ return HostDetectMacOS().getHostInfo()
16
16
  elif self.OS == "windows":
17
17
  pass
18
18
  else:
@@ -0,0 +1,13 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass
5
+ class HostInfo:
6
+ model = ""
7
+ family = ""
8
+ name = ""
9
+ version = ""
10
+ sku = ""
11
+ serial = ""
12
+ uuid = ""
13
+ vendor = ""
@@ -2,24 +2,13 @@
2
2
  In dev.
3
3
  """
4
4
  from ...pyhwUtil import getArch
5
- from dataclasses import dataclass
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
6
+ import os
18
7
 
19
8
 
20
9
  class HostDetectLinux:
21
10
  def __init__(self):
22
- self.__hostInfo = HostInfoLinux()
11
+ self.__hostInfo = HostInfo()
23
12
  self.__arch = getArch()
24
13
 
25
14
  def getHostInfo(self):
@@ -37,11 +26,23 @@ class HostDetectLinux:
37
26
  except FileNotFoundError:
38
27
  pass
39
28
  elif self.__arch in ["aarch64", "arm32"]:
40
- try:
41
- with open("/sys/firmware/devicetree/base/model", "r") as f:
42
- self.__hostInfo.model = f.read().strip()
43
- except FileNotFoundError:
44
- pass
29
+ # try to find dmi folder since some arm based desktops and servers may have same structure as x86_64 machines.
30
+ if os.path.exists("/sys/devices/virtual/dmi/id"):
31
+ try:
32
+ with open("/sys/devices/virtual/dmi/id/product_name", "r") as f:
33
+ self.__hostInfo.name = f.read().strip()
34
+ with open("/sys/devices/virtual/dmi/id/product_version", "r") as f:
35
+ self.__hostInfo.version = f.read().strip()
36
+ self.__hostInfo.model = self.__hostInfo.name + " " + self.__hostInfo.version
37
+ except FileNotFoundError:
38
+ pass
39
+ else:
40
+ # some single board computers may not have dmi folder, try to find model name in device tree.
41
+ try:
42
+ with open("/sys/firmware/devicetree/base/model", "r") as f:
43
+ self.__hostInfo.model = f.read().strip()
44
+ except FileNotFoundError:
45
+ pass
45
46
 
46
47
  def __getHostFamily(self):
47
48
  pass
@@ -1,5 +1,269 @@
1
1
  """
2
2
  In dev.
3
3
  """
4
+ from .hostInfo import HostInfo
5
+ from ...pyhwUtil import sysctlGetString
6
+
7
+
4
8
  class HostDetectMacOS:
5
- pass
9
+ def __init__(self):
10
+ self.__hostInfo = HostInfo()
11
+ self.__HWModel = ""
12
+
13
+ def getHostInfo(self):
14
+ self.__getHWModel()
15
+ self.__hostInfo.model = self.__handleMacName(self.__HWModel)
16
+ return self.__hostInfo
17
+
18
+ def __getHWModel(self):
19
+ self.__HWModel = sysctlGetString("hw.model")
20
+
21
+ def __handleMacName(self, hw_model: str):
22
+ # This part of the code is directly re-implemented from the fastfetch project. It seems that there is no
23
+ # more elegant way to get the product name of the Mac.
24
+ # See https://github.com/fastfetch-cli/fastfetch/blob/dev/src/detection/host/host_apple.c for more details.
25
+ if hw_model.startswith("MacBookPro"):
26
+ version = hw_model[len("MacBookPro"):]
27
+ if self.__hwModelCheck(version, "18,3") or self.__hwModelCheck(version, "18,4"):
28
+ return "MacBook Pro (14-inch, 2021)"
29
+ if self.__hwModelCheck(version, "18,1") or self.__hwModelCheck(version, "18,2"):
30
+ return "MacBook Pro (16-inch, 2021)"
31
+ if self.__hwModelCheck(version, "17,1"):
32
+ return "MacBook Pro (13-inch, M1, 2020)"
33
+ if self.__hwModelCheck(version, "16,3"):
34
+ return "MacBook Pro (13-inch, 2020, Two Thunderbolt 3 ports)"
35
+ if self.__hwModelCheck(version, "16,2"):
36
+ return "MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports)"
37
+ if self.__hwModelCheck(version, "16,4") or self.__hwModelCheck(version, "16,1"):
38
+ return "MacBook Pro (16-inch, 2019)"
39
+ if self.__hwModelCheck(version, "15,4"):
40
+ return "MacBook Pro (13-inch, 2019, Two Thunderbolt 3 ports)"
41
+ if self.__hwModelCheck(version, "15,3"):
42
+ return "MacBook Pro (15-inch, 2019)"
43
+ if self.__hwModelCheck(version, "15,2"):
44
+ return "MacBook Pro (13-inch, 2018/2019, Four Thunderbolt 3 ports)"
45
+ if self.__hwModelCheck(version, "15,1"):
46
+ return "MacBook Pro (15-inch, 2018/2019)"
47
+ if self.__hwModelCheck(version, "14,3"):
48
+ return "MacBook Pro (15-inch, 2017)"
49
+ if self.__hwModelCheck(version, "14,2"):
50
+ return "MacBook Pro (13-inch, 2017, Four Thunderbolt 3 ports)"
51
+ if self.__hwModelCheck(version, "14,1"):
52
+ return "MacBook Pro (13-inch, 2017, Two Thunderbolt 3 ports)"
53
+ if self.__hwModelCheck(version, "13,3"):
54
+ return "MacBook Pro (15-inch, 2016)"
55
+ if self.__hwModelCheck(version, "13,2"):
56
+ return "MacBook Pro (13-inch, 2016, Four Thunderbolt 3 ports)"
57
+ if self.__hwModelCheck(version, "13,1"):
58
+ return "MacBook Pro (13-inch, 2016, Two Thunderbolt 3 ports)"
59
+ if self.__hwModelCheck(version, "12,1"):
60
+ return "MacBook Pro (Retina, 13-inch, Early 2015)"
61
+ if self.__hwModelCheck(version, "11,4") or self.__hwModelCheck(version, "11,5"):
62
+ return "MacBook Pro (Retina, 15-inch, Mid 2015)"
63
+ if self.__hwModelCheck(version, "11,2") or self.__hwModelCheck(version, "11,3"):
64
+ return "MacBook Pro (Retina, 15-inch, Late 2013/Mid 2014)"
65
+ if self.__hwModelCheck(version, "11,1"):
66
+ return "MacBook Pro (Retina, 13-inch, Late 2013/Mid 2014)"
67
+ if self.__hwModelCheck(version, "10,2"):
68
+ return "MacBook Pro (Retina, 13-inch, Late 2012/Early 2013)"
69
+ if self.__hwModelCheck(version, "10,1"):
70
+ return "MacBook Pro (Retina, 15-inch, Mid 2012/Early 2013)"
71
+ if self.__hwModelCheck(version, "9,2"):
72
+ return "MacBook Pro (13-inch, Mid 2012)"
73
+ if self.__hwModelCheck(version, "9,1"):
74
+ return "MacBook Pro (15-inch, Mid 2012)"
75
+ if self.__hwModelCheck(version, "8,3"):
76
+ return "MacBook Pro (17-inch, 2011)"
77
+ if self.__hwModelCheck(version, "8,2"):
78
+ return "MacBook Pro (15-inch, 2011)"
79
+ if self.__hwModelCheck(version, "8,1"):
80
+ return "MacBook Pro (13-inch, 2011)"
81
+ if self.__hwModelCheck(version, "7,1"):
82
+ return "MacBook Pro (13-inch, Mid 2010)"
83
+ if self.__hwModelCheck(version, "6,2"):
84
+ return "MacBook Pro (15-inch, Mid 2010)"
85
+ if self.__hwModelCheck(version, "6,1"):
86
+ return "MacBook Pro (17-inch, Mid 2010)"
87
+ if self.__hwModelCheck(version, "5,5"):
88
+ return "MacBook Pro (13-inch, Mid 2009)"
89
+ if self.__hwModelCheck(version, "5,3"):
90
+ return "MacBook Pro (15-inch, Mid 2009)"
91
+ if self.__hwModelCheck(version, "5,2"):
92
+ return "MacBook Pro (17-inch, Mid/Early 2009)"
93
+ if self.__hwModelCheck(version, "5,1"):
94
+ return "MacBook Pro (15-inch, Late 2008)"
95
+ if self.__hwModelCheck(version, "4,1"):
96
+ return "MacBook Pro (17/15-inch, Early 2008)"
97
+ elif hw_model.startswith("MacBookAir"):
98
+ version = hw_model[len("MacBookAir"):]
99
+ if self.__hwModelCheck(version, "10,1"):
100
+ return "MacBook Air (M1, 2020)"
101
+ if self.__hwModelCheck(version, "9,1"):
102
+ return "MacBook Air (Retina, 13-inch, 2020)"
103
+ if self.__hwModelCheck(version, "8,2"):
104
+ return "MacBook Air (Retina, 13-inch, 2019)"
105
+ if self.__hwModelCheck(version, "8,1"):
106
+ return "MacBook Air (Retina, 13-inch, 2018)"
107
+ if self.__hwModelCheck(version, "7,2"):
108
+ return "MacBook Air (13-inch, Early 2015/2017)"
109
+ if self.__hwModelCheck(version, "7,1"):
110
+ return "MacBook Air (11-inch, Early 2015)"
111
+ if self.__hwModelCheck(version, "6,2"):
112
+ return "MacBook Air (13-inch, Mid 2013/Early 2014)"
113
+ if self.__hwModelCheck(version, "6,1"):
114
+ return "MacBook Air (11-inch, Mid 2013/Early 2014)"
115
+ if self.__hwModelCheck(version, "5,2"):
116
+ return "MacBook Air (13-inch, Mid 2012)"
117
+ if self.__hwModelCheck(version, "5,1"):
118
+ return "MacBook Air (11-inch, Mid 2012)"
119
+ if self.__hwModelCheck(version, "4,2"):
120
+ return "MacBook Air (13-inch, Mid 2011)"
121
+ if self.__hwModelCheck(version, "4,1"):
122
+ return "MacBook Air (11-inch, Mid 2011)"
123
+ if self.__hwModelCheck(version, "3,2"):
124
+ return "MacBook Air (13-inch, Late 2010)"
125
+ if self.__hwModelCheck(version, "3,1"):
126
+ return "MacBook Air (11-inch, Late 2010)"
127
+ if self.__hwModelCheck(version, "2,1"):
128
+ return "MacBook Air (Mid 2009)"
129
+
130
+ elif hw_model.startswith("Macmini"):
131
+ version = hw_model[len("Macmini"):]
132
+ if self.__hwModelCheck(version, "9,1"):
133
+ return "Mac mini (M1, 2020)"
134
+ if self.__hwModelCheck(version, "8,1"):
135
+ return "Mac mini (2018)"
136
+ if self.__hwModelCheck(version, "7,1"):
137
+ return "Mac mini (Mid 2014)"
138
+ if self.__hwModelCheck(version, "6,1") or self.__hwModelCheck(version, "6,2"):
139
+ return "Mac mini (Late 2012)"
140
+ if self.__hwModelCheck(version, "5,1") or self.__hwModelCheck(version, "5,2"):
141
+ return "Mac mini (Mid 2011)"
142
+ if self.__hwModelCheck(version, "4,1"):
143
+ return "Mac mini (Mid 2010)"
144
+ if self.__hwModelCheck(version, "3,1"):
145
+ return "Mac mini (Early/Late 2009)"
146
+
147
+ elif hw_model.startswith("MacBook"):
148
+ version = hw_model[len("MacBook"):]
149
+ if self.__hwModelCheck(version, "10,1"):
150
+ return "MacBook (Retina, 12-inch, 2017)"
151
+ if self.__hwModelCheck(version, "9,1"):
152
+ return "MacBook (Retina, 12-inch, Early 2016)"
153
+ if self.__hwModelCheck(version, "8,1"):
154
+ return "MacBook (Retina, 12-inch, Early 2015)"
155
+ if self.__hwModelCheck(version, "7,1"):
156
+ return "MacBook (13-inch, Mid 2010)"
157
+ if self.__hwModelCheck(version, "6,1"):
158
+ return "MacBook (13-inch, Late 2009)"
159
+ if self.__hwModelCheck(version, "5,2"):
160
+ return "MacBook (13-inch, Early/Mid 2009)"
161
+
162
+ elif hw_model.startswith("MacPro"):
163
+ version = hw_model[len("MacPro"):]
164
+ if self.__hwModelCheck(version, "7,1"):
165
+ return "Mac Pro (2019)"
166
+ if self.__hwModelCheck(version, "6,1"):
167
+ return "Mac Pro (Late 2013)"
168
+ if self.__hwModelCheck(version, "5,1"):
169
+ return "Mac Pro (Mid 2010 - Mid 2012)"
170
+ if self.__hwModelCheck(version, "4,1"):
171
+ return "Mac Pro (Early 2009)"
172
+
173
+ elif hw_model.startswith("Mac"):
174
+ version = hw_model[len("Mac"):]
175
+ if self.__hwModelCheck(version, "15,13"):
176
+ return "MacBook Air (15-inch, M3, 2024)"
177
+ if self.__hwModelCheck(version, "15,2"):
178
+ return "MacBook Air (13-inch, M3, 2024)"
179
+ if self.__hwModelCheck(version, "15,3"):
180
+ return "MacBook Pro (14-inch, Nov 2023, Two Thunderbolt / USB 4 ports)"
181
+ if self.__hwModelCheck(version, "15,4"):
182
+ return "iMac (24-inch, 2023, Two Thunderbolt / USB 4 ports)"
183
+ if self.__hwModelCheck(version, "15,5"):
184
+ return "iMac (24-inch, 2023, Two Thunderbolt / USB 4 ports, Two USB 3 ports)"
185
+ if self.__hwModelCheck(version, "15,6") or self.__hwModelCheck(version, "15,8") or self.__hwModelCheck(version, "15,10"):
186
+ return "MacBook Pro (14-inch, Nov 2023, Three Thunderbolt 4 ports)"
187
+ if self.__hwModelCheck(version, "15,7") or self.__hwModelCheck(version, "15,9") or self.__hwModelCheck(version, "15,11"):
188
+ return "MacBook Pro (16-inch, Nov 2023, Three Thunderbolt 4 ports)"
189
+ if self.__hwModelCheck(version, "14,15"):
190
+ return "MacBook Air (15-inch, M2, 2023)"
191
+ if self.__hwModelCheck(version, "14,14"):
192
+ return "Mac Studio (M2 Ultra, 2023, Two Thunderbolt 4 front ports)"
193
+ if self.__hwModelCheck(version, "14,13"):
194
+ return "Mac Studio (M2 Max, 2023, Two USB-C front ports)"
195
+ if self.__hwModelCheck(version, "14,8"):
196
+ return "Mac Pro (2023)"
197
+ if self.__hwModelCheck(version, "14,6") or self.__hwModelCheck(version, "14,10"):
198
+ return "MacBook Pro (16-inch, 2023)"
199
+ if self.__hwModelCheck(version, "14,5") or self.__hwModelCheck(version, "14,9"):
200
+ return "MacBook Pro (14-inch, 2023)"
201
+ if self.__hwModelCheck(version, "14,3"):
202
+ return "Mac mini (M2, 2023, Two Thunderbolt 4 ports)"
203
+ if self.__hwModelCheck(version, "14,12"):
204
+ return "Mac mini (M2, 2023, Four Thunderbolt 4 ports)"
205
+ if self.__hwModelCheck(version, "14,7"):
206
+ return "MacBook Pro (13-inch, M2, 2022)"
207
+ if self.__hwModelCheck(version, "14,2"):
208
+ return "MacBook Air (M2, 2022)"
209
+ if self.__hwModelCheck(version, "13,1"):
210
+ return "Mac Studio (M1 Max, 2022, Two USB-C front ports)"
211
+ if self.__hwModelCheck(version, "13,2"):
212
+ return "Mac Studio (M1 Ultra, 2022, Two Thunderbolt 4 front ports)"
213
+
214
+ elif hw_model.startswith("iMac"):
215
+ version = hw_model[len("iMac"):]
216
+ if self.__hwModelCheck(version, "21,1"):
217
+ return "iMac (24-inch, M1, 2021, Two Thunderbolt / USB 4 ports, Two USB 3 ports)"
218
+ if self.__hwModelCheck(version, "21,2"):
219
+ return "iMac (24-inch, M1, 2021, Two Thunderbolt / USB 4 ports)"
220
+ if self.__hwModelCheck(version, "20,1") or self.__hwModelCheck(version, "20,2"):
221
+ return "iMac (Retina 5K, 27-inch, 2020)"
222
+ if self.__hwModelCheck(version, "19,1"):
223
+ return "iMac (Retina 5K, 27-inch, 2019)"
224
+ if self.__hwModelCheck(version, "19,2"):
225
+ return "iMac (Retina 4K, 21.5-inch, 2019)"
226
+ if self.__hwModelCheck(version, "Pro1,1"):
227
+ return "iMac Pro (2017)"
228
+ if self.__hwModelCheck(version, "18,3"):
229
+ return "iMac (Retina 5K, 27-inch, 2017)"
230
+ if self.__hwModelCheck(version, "18,2"):
231
+ return "iMac (Retina 4K, 21.5-inch, 2017)"
232
+ if self.__hwModelCheck(version, "18,1"):
233
+ return "iMac (21.5-inch, 2017)"
234
+ if self.__hwModelCheck(version, "17,1"):
235
+ return "iMac (Retina 5K, 27-inch, Late 2015)"
236
+ if self.__hwModelCheck(version, "16,2"):
237
+ return "iMac (Retina 4K, 21.5-inch, Late 2015)"
238
+ if self.__hwModelCheck(version, "16,1"):
239
+ return "iMac (21.5-inch, Late 2015)"
240
+ if self.__hwModelCheck(version, "15,1"):
241
+ return "iMac (Retina 5K, 27-inch, Late 2014 - Mid 2015)"
242
+ if self.__hwModelCheck(version, "14,4"):
243
+ return "iMac (21.5-inch, Mid 2014)"
244
+ if self.__hwModelCheck(version, "14,2"):
245
+ return "iMac (27-inch, Late 2013)"
246
+ if self.__hwModelCheck(version, "14,1"):
247
+ return "iMac (21.5-inch, Late 2013)"
248
+ if self.__hwModelCheck(version, "13,2"):
249
+ return "iMac (27-inch, Late 2012)"
250
+ if self.__hwModelCheck(version, "13,1"):
251
+ return "iMac (21.5-inch, Late 2012)"
252
+ if self.__hwModelCheck(version, "12,2"):
253
+ return "iMac (27-inch, Mid 2011)"
254
+ if self.__hwModelCheck(version, "12,1"):
255
+ return "iMac (21.5-inch, Mid 2011)"
256
+ if self.__hwModelCheck(version, "11,3"):
257
+ return "iMac (27-inch, Mid 2010)"
258
+ if self.__hwModelCheck(version, "11,2"):
259
+ return "iMac (21.5-inch, Mid 2010)"
260
+ if self.__hwModelCheck(version, "10,1"):
261
+ return "iMac (27/21.5-inch, Late 2009)"
262
+ if self.__hwModelCheck(version, "9,1"):
263
+ return "iMac (24/20-inch, Early 2009)"
264
+
265
+ return "Unknown Mac Model"
266
+
267
+ @staticmethod
268
+ def __hwModelCheck(version: str, target: str):
269
+ return version == target