From a44ed6d90b4e9c912a46902934ac586efe2d3c44 Mon Sep 17 00:00:00 2001 From: Alex Huszagh Date: Sat, 7 Sep 2024 12:45:08 -0500 Subject: [PATCH] CI Fix --- example/breeze_theme.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/example/breeze_theme.py b/example/breeze_theme.py index 2468143..817af58 100644 --- a/example/breeze_theme.py +++ b/example/breeze_theme.py @@ -292,8 +292,8 @@ def macos_supported_version() -> bool: def _get_theme_macos() -> Theme: '''Get the current theme, as light or dark, for the system on macOS.''' - # NOTE: This can segfault on M1 and M2 Macs on Big Sur 11.4+. So, we also try reading - # directly using subprocess. + # NOTE: This can segfault on M1 and M2 Macs on Big Sur 11.4+. So, we also + # try reading directly using subprocess. try: command = ['defaults', 'read', '-globalDomain', 'AppleInterfaceStyle'] process = subprocess.run(command, capture_output=True, check=True) @@ -303,11 +303,14 @@ def _get_theme_macos() -> Theme: except UnicodeDecodeError: return Theme.LIGHT except subprocess.CalledProcessError as error: - # We can't read these defaults, just try using our libcs - print(error.stderr) - print(error.stdout) - # TODO: Reset to pass... - raise + # If this keypair does not exist, then it's a specific error because the style + # hasn't been set before, so then it specifically is a light theme. this can + # affect no-UI systems like CI. + not_exist = b'does not exist' in error.stderr + any_app = b'kCFPreferencesAnyApplication' in error.stderr + interface_style = b'AppleInterfaceStyle' in error.stderr + if not_exist and any_app and interface_style: + return Theme.LIGHT # NOTE: We do this so we don't need imports at the global level. try: