Skip to content

Commit

Permalink
Refactor _exec_transport_commands method to accept a list of dictiona…
Browse files Browse the repository at this point in the history
…ries containing commands; add type hinting and docstring
  • Loading branch information
beeankha committed Feb 17, 2025
1 parent 27caf98 commit f7a6828
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions plugins/connection/aws_ssm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1062,10 +1062,19 @@ def _generate_commands(

return commands, put_args

def _exec_transport_commands(self, in_path, out_path, commands):
def _exec_transport_commands(self, in_path: str, out_path: str, commands: List[Command]) -> CommandResult:
"""
Execute the provided transport commands.
:param in_path: The input path.
:param out_path: The output path.
:param commands: A list of command dictionaries containing the command string and metadata.
:returns: A CommandResult object containing the return code, stdout, and stderr in a tuple.
"""
stdout_combined, stderr_combined = "", ""
for command in commands:
(returncode, stdout, stderr) = self.exec_command(command, in_data=None, sudoable=False)
(returncode, stdout, stderr) = self.exec_command(command["command"], in_data=None, sudoable=False)

# Check the return code
if returncode != 0:
Expand All @@ -1074,7 +1083,7 @@ def _exec_transport_commands(self, in_path, out_path, commands):
stdout_combined += stdout
stderr_combined += stderr

return (returncode, stdout_combined, stderr_combined)
return CommandResult(returncode, stdout_combined, stderr_combined)

@_ssm_retry
def _file_transport_command(self, in_path, out_path, ssm_action):
Expand Down

0 comments on commit f7a6828

Please sign in to comment.