Reformat everything.

This commit is contained in:
Felix Fontein
2025-11-01 12:08:41 +01:00
parent 3f2213791a
commit 340ff8586d
1008 changed files with 61301 additions and 58309 deletions

View File

@@ -94,23 +94,22 @@ from ansible.plugins.become import BecomeBase
class BecomeModule(BecomeBase):
name = 'community.general.doas'
name = "community.general.doas"
# messages for detecting prompted password issues
fail = ('Permission denied',)
missing = ('Authorization required',)
fail = ("Permission denied",)
missing = ("Authorization required",)
# See https://github.com/ansible-collections/community.general/issues/9977,
# https://github.com/ansible/ansible/pull/78111
pipelining = False
def check_password_prompt(self, b_output):
''' checks if the expected password prompt exists in b_output '''
"""checks if the expected password prompt exists in b_output"""
# FIXME: more accurate would be: 'doas (%s@' % remote_user
# however become plugins don't have that information currently
b_prompts = [to_bytes(p) for p in self.get_option('prompt_l10n')] or [br'doas \(', br'Password:']
b_prompts = [to_bytes(p) for p in self.get_option("prompt_l10n")] or [rb"doas \(", rb"Password:"]
b_prompt = b"|".join(b_prompts)
return bool(re.match(b_prompt, b_output))
@@ -123,16 +122,16 @@ class BecomeModule(BecomeBase):
self.prompt = True
become_exe = self.get_option('become_exe')
become_exe = self.get_option("become_exe")
flags = self.get_option('become_flags')
if not self.get_option('become_pass') and '-n' not in flags:
flags += ' -n'
flags = self.get_option("become_flags")
if not self.get_option("become_pass") and "-n" not in flags:
flags += " -n"
become_user = self.get_option('become_user')
user = f'-u {become_user}' if become_user else ''
become_user = self.get_option("become_user")
user = f"-u {become_user}" if become_user else ""
success_cmd = self._build_success_command(cmd, shell, noexe=True)
executable = getattr(shell, 'executable', shell.SHELL_FAMILY)
executable = getattr(shell, "executable", shell.SHELL_FAMILY)
return f'{become_exe} {flags} {user} {executable} -c {success_cmd}'
return f"{become_exe} {flags} {user} {executable} -c {success_cmd}"