You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/02/28 20:59:18 UTC
[GitHub] [airflow] kaxil commented on a change in pull request #13153: fix stout decoding issue and add option to run command as powershell script
kaxil commented on a change in pull request #13153:
URL: https://github.com/apache/airflow/pull/13153#discussion_r584359471
##########
File path: airflow/providers/microsoft/winrm/operators/winrm.py
##########
@@ -88,10 +97,17 @@ def execute(self, context: dict) -> Union[list, str]:
# pylint: disable=too-many-nested-blocks
try:
- self.log.info("Running command: '%s'...", self.command)
- command_id = self.winrm_hook.winrm_protocol.run_command( # type: ignore[attr-defined]
- winrm_client, self.command
- )
+ if self.ps_path is not None:
+ self.log.info("Running command as powershell script: '%s'...", self.command)
+ encoded_ps = b64encode(self.command.encode('utf_16_le')).decode('ascii')
+ command_id = self.winrm_hook.winrm_protocol.run_command( # type: ignore[attr-defined]
+ winrm_client, '{0} -encodedcommand {1}'.format(self.ps_path, encoded_ps)
Review comment:
```suggestion
winrm_client, f'{self.ps_path} -encodedcommand {encoded_ps}'
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org