@@ -603,8 +603,6 @@ def _execute_async( # pylint: disable=arguments-differ
603603 stdin : typing .Union [bytes , str , bytearray , None ] = None ,
604604 open_stdout : bool = True ,
605605 open_stderr : bool = True ,
606- verbose : bool = False ,
607- log_mask_re : typing .Optional [str ] = None ,
608606 * ,
609607 chroot_path : typing .Optional [str ] = None ,
610608 get_pty : bool = False ,
@@ -622,11 +620,6 @@ def _execute_async( # pylint: disable=arguments-differ
622620 :type open_stdout: bool
623621 :param open_stderr: open STDERR stream for read
624622 :type open_stderr: bool
625- :param verbose: produce verbose log record on command call
626- :type verbose: bool
627- :param log_mask_re: regex lookup rule to mask command for logger.
628- all MATCHED groups will be replaced by '<*masked*>'
629- :type log_mask_re: typing.Optional[str]
630623 :param chroot_path: chroot path override
631624 :type chroot_path: typing.Optional[str]
632625 :param get_pty: Get PTY for connection
@@ -656,12 +649,6 @@ def _execute_async( # pylint: disable=arguments-differ
656649 .. versionchanged:: 3.2.0 Expose pty options as optional keyword-only arguments
657650 .. versionchanged:: 4.1.0 support chroot
658651 """
659- cmd_for_log : str = self ._mask_command (cmd = command , log_mask_re = log_mask_re )
660-
661- self .logger .log (
662- level = logging .INFO if verbose else logging .DEBUG , msg = _log_templates .CMD_EXEC .format (cmd = cmd_for_log )
663- )
664-
665652 chan : paramiko .Channel = self ._ssh .get_transport ().open_session ()
666653
667654 if get_pty :
@@ -950,7 +937,7 @@ def execute_through_host(
950937 with self .proxy_to ( # type: ignore
951938 host = hostname , port = port , auth = auth , verbose = verbose , ssh_config = self .ssh_config , keepalive = False
952939 ) as conn :
953- return conn . execute (
940+ return conn (
954941 command ,
955942 timeout = timeout ,
956943 open_stdout = open_stdout ,
@@ -972,6 +959,7 @@ def execute_together(
972959 raise_on_err : bool = True ,
973960 * ,
974961 stdin : typing .Union [bytes , str , bytearray , None ] = None ,
962+ verbose : bool = False ,
975963 log_mask_re : typing .Optional [str ] = None ,
976964 exception_class : "typing.Type[exceptions.ParallelCallProcessError]" = exceptions .ParallelCallProcessError ,
977965 ** kwargs : typing .Any ,
@@ -990,6 +978,8 @@ def execute_together(
990978 :type raise_on_err: bool
991979 :param stdin: pass STDIN text to the process
992980 :type stdin: typing.Union[bytes, str, bytearray, None]
981+ :param verbose: produce verbose log record on command call
982+ :type verbose: bool
993983 :param log_mask_re: regex lookup rule to mask command for logger.
994984 all MATCHED groups will be replaced by '<*masked*>'
995985 :type log_mask_re: typing.Optional[str]
@@ -1016,17 +1006,20 @@ def get_result(remote: "SSHClientBase") -> exec_result.ExecResult:
10161006 :param remote: SSH connection instance
10171007 :return: execution result
10181008 """
1019- async_result : SshExecuteAsyncResult = remote ._execute_async ( # pylint: disable=protected-access
1009+ # pylint: disable=protected-access
1010+ cmd_for_log : str = remote ._mask_command (cmd = command , log_mask_re = log_mask_re )
1011+
1012+ remote .logger .log (
1013+ level = logging .INFO if verbose else logging .DEBUG , msg = f"Executing command:\n { cmd_for_log !r} \n "
1014+ )
1015+ async_result : SshExecuteAsyncResult = remote ._execute_async (
10201016 command , stdin = stdin , log_mask_re = log_mask_re , ** kwargs
10211017 )
1018+ # pylint: enable=protected-access
10221019
10231020 async_result .interface .status_event .wait (timeout )
10241021 exit_code = async_result .interface .recv_exit_status ()
10251022
1026- # pylint: disable=protected-access
1027- cmd_for_log : str = remote ._mask_command (cmd = command , log_mask_re = log_mask_re )
1028- # pylint: enable=protected-access
1029-
10301023 res = exec_result .ExecResult (cmd = cmd_for_log , stdin = stdin , started = async_result .started )
10311024 res .read_stdout (src = async_result .stdout )
10321025 res .read_stderr (src = async_result .stderr )
0 commit comments