File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -143,6 +143,7 @@ def get_computer_uuid() -> str:
143143 machine_id_fn = {
144144 PlatformEnum .WINDOWS : get_uuid_windows ,
145145 PlatformEnum .LINUX : get_uuid_linux ,
146+ PlatformEnum .MACOS : get_uuid_macos ,
146147 PlatformEnum .UNKNOWN : lambda : 'unknown platform' ,
147148 }.get (get_platform (), lambda : 'unknown, unhandled platform' )
148149 machine_id_str = machine_id_fn ()
@@ -178,6 +179,20 @@ def get_uuid_linux() -> str:
178179 return machine_id_contents
179180
180181
182+ def get_uuid_macos () -> str :
183+ sub_proc = subprocess .run (
184+ ['ioreg' ,
185+ '-rd1' ,
186+ '-c' ,
187+ 'IOPlatformExpertDevice' ,
188+ ],
189+ capture_output = True )
190+ if sub_proc .returncode != 0 :
191+ return 'unknown-macos'
192+ ioreg_output = sub_proc .stdout .decode ('UTF-8' )
193+ return windows_uuid
194+
195+
181196def to_nearest_half (num : float ) -> float :
182197 return round (num * 2 , 0 ) / 2
183198
Original file line number Diff line number Diff line change 99class PlatformEnum (enum .Enum ):
1010 LINUX = enum .auto ()
1111 WINDOWS = enum .auto ()
12+ MACOS = enum .auto ()
1213 UNKNOWN = enum .auto ()
1314
1415
@@ -25,6 +26,8 @@ def get_platform() -> PlatformEnum:
2526 platform_lookup = PlatformEnum .WINDOWS
2627 elif 'linux' in platform_str :
2728 platform_lookup = PlatformEnum .LINUX
29+ elif 'darwin' in platform_str :
30+ platform_lookup = PlatformEnum .MACOS
2831 else :
2932 platform_lookup = PlatformEnum .UNKNOWN
3033 platform_lookup_cache = platform_lookup # Cache return
You can’t perform that action at this time.
0 commit comments