From 6640b052168d6a437bcb511c5e137c571ad7e6b8 Mon Sep 17 00:00:00 2001 From: "Gareth J. Greenaway" Date: Wed, 25 Oct 2023 16:26:10 -0700 Subject: [PATCH] fixes for MacOS X 13 --- salt/modules/mac_service.py | 11 ++++++----- tests/integration/modules/test_mac_sysctl.py | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/salt/modules/mac_service.py b/salt/modules/mac_service.py index 2932d083651..39dd6dd0f67 100644 --- a/salt/modules/mac_service.py +++ b/salt/modules/mac_service.py @@ -143,7 +143,7 @@ def _get_service(name): # so we need to raise that the service could not be found. try: if not __context__["using_cached_services"]: - raise CommandExecutionError("Service not found: {}".format(name)) + raise CommandExecutionError(f"Service not found: {name}") except KeyError: pass @@ -151,7 +151,7 @@ def _get_service(name): # state then there is no reason to check again. # fixes https://github.com/saltstack/salt/issues/57907 if __context__.get("service.state") == "dead": - raise CommandExecutionError("Service not found: {}".format(name)) + raise CommandExecutionError(f"Service not found: {name}") # we used a cached version to check, a service could have been made # between now and then, we should refresh our available services. @@ -162,7 +162,7 @@ def _get_service(name): if not service: # Could not find the service after refresh raise. - raise CommandExecutionError("Service not found: {}".format(name)) + raise CommandExecutionError(f"Service not found: {name}") # found it :) return service @@ -240,7 +240,7 @@ def _get_domain_target(name, service_target=False): if "LaunchAgents" in path: # Get the console user so we can service in the correct session uid = __utils__["mac_utils.console_user"]() - domain_target = "gui/{}".format(uid) + domain_target = f"gui/{uid}" # check to see if we need to make it a full service target. if service_target is True: @@ -638,7 +638,8 @@ def disabled(name, runas=None, domain="system"): if name != srv_name: pass else: - return True if "true" in status.lower() else False + matches = ["true", "disabled"] + return True if any([x in status.lower() for x in matches]) else False return False diff --git a/tests/integration/modules/test_mac_sysctl.py b/tests/integration/modules/test_mac_sysctl.py index 6d7b1c945d6..cdf1b665a53 100644 --- a/tests/integration/modules/test_mac_sysctl.py +++ b/tests/integration/modules/test_mac_sysctl.py @@ -12,7 +12,7 @@ from salt.exceptions import CommandExecutionError from tests.support.case import ModuleCase # Module Variables -ASSIGN_CMD = "net.inet.icmp.icmplim" +ASSIGN_CMD = "net.inet.icmp.timestamp" CONFIG = "/etc/sysctl.conf" @@ -74,7 +74,7 @@ class DarwinSysctlModuleTest(ModuleCase): os.remove(CONFIG) try: self.run_function("sysctl.persist", [ASSIGN_CMD, 10]) - line = "{}={}".format(ASSIGN_CMD, 10) + line = f"{ASSIGN_CMD}={10}" found = self.__check_string(CONFIG, line) self.assertTrue(found) except CommandExecutionError: