-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathutils.py
More file actions
22 lines (20 loc) · 971 Bytes
/
utils.py
File metadata and controls
22 lines (20 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import re, subprocess
from sys import platform
def get_apple_hardware():
"Get apple hardware info"
cpu_info = subprocess.run(["system_profiler","SPHardwareDataType"], stdout=subprocess.PIPE).stdout.decode("utf-8")
gpu_info = subprocess.run(["system_profiler","SPDisplaysDataType"], stdout=subprocess.PIPE).stdout.decode("utf-8")
system_info = dict(
cpu = re.search(r'Chip:\s+(.+)', cpu_info).group(1),
cpu_cores = re.search(r'Number of Cores:\s+(\d+)', cpu_info).group(1),
memory = re.search(r'Memory:\s+(\d+)\s+GB', cpu_info).group(1),
gpu = re.search(r'Chipset Model:\s+(.+)', gpu_info).group(1),
gpu_cores = re.search(r'Total Number of Cores:\s+(\d+)', gpu_info).group(1),
)
return system_info
def get_apple_gpu_name():
if platform == "darwin":
system_info = get_apple_hardware()
return f"{system_info['gpu']} GPU {system_info['gpu_cores']} Cores"
else:
return None