From 04ae0c33129051368a01ca56fad21581139f73e5 Mon Sep 17 00:00:00 2001 From: Jordan Borean Date: Wed, 2 May 2018 07:04:53 +1000 Subject: [PATCH] winrm: removed old exec_command that is no longer used (#39572) --- lib/ansible/plugins/connection/winrm.py | 41 ------------------------- 1 file changed, 41 deletions(-) diff --git a/lib/ansible/plugins/connection/winrm.py b/lib/ansible/plugins/connection/winrm.py index 0389bf66157..63e921b24ec 100644 --- a/lib/ansible/plugins/connection/winrm.py +++ b/lib/ansible/plugins/connection/winrm.py @@ -505,47 +505,6 @@ class Connection(ConnectionBase): return (result.status_code, result.std_out, result.std_err) - def exec_command_old(self, cmd, in_data=None, sudoable=True): - super(Connection, self).exec_command(cmd, in_data=in_data, sudoable=sudoable) - cmd_parts = shlex.split(to_bytes(cmd), posix=False) - cmd_parts = map(to_text, cmd_parts) - script = None - cmd_ext = cmd_parts and self._shell._unquote(cmd_parts[0]).lower()[-4:] or '' - # Support running .ps1 files (via script/raw). - if cmd_ext == '.ps1': - script = '& %s' % cmd - # Support running .bat/.cmd files; change back to the default system encoding instead of UTF-8. - elif cmd_ext in ('.bat', '.cmd'): - script = '[System.Console]::OutputEncoding = [System.Text.Encoding]::Default; & %s' % cmd - # Encode the command if not already encoded; supports running simple PowerShell commands via raw. - elif '-EncodedCommand' not in cmd_parts: - script = cmd - if script: - cmd_parts = self._shell._encode_script(script, as_list=True, strict_mode=False) - if '-EncodedCommand' in cmd_parts: - encoded_cmd = cmd_parts[cmd_parts.index('-EncodedCommand') + 1] - decoded_cmd = to_text(base64.b64decode(encoded_cmd).decode('utf-16-le')) - display.vvv("EXEC %s" % decoded_cmd, host=self._winrm_host) - else: - display.vvv("EXEC %s" % cmd, host=self._winrm_host) - try: - result = self._winrm_exec(cmd_parts[0], cmd_parts[1:], from_exec=True) - except Exception: - traceback.print_exc() - raise AnsibleConnectionFailure("failed to exec cmd %s" % to_native(cmd)) - result.std_out = to_bytes(result.std_out) - result.std_err = to_bytes(result.std_err) - - # parse just stderr from CLIXML output - if self.is_clixml(result.std_err): - try: - result.std_err = self.parse_clixml_stream(result.std_err) - except Exception: - # unsure if we're guaranteed a valid xml doc- use raw output in case of error - pass - - return (result.status_code, result.std_out, result.std_err) - def is_clixml(self, value): return value.startswith(b"#< CLIXML")