dabla commented on code in PR #60651:
URL: https://github.com/apache/airflow/pull/60651#discussion_r2784121032
##########
providers/microsoft/winrm/src/airflow/providers/microsoft/winrm/operators/winrm.py:
##########
@@ -122,3 +182,34 @@ def execute(self, context: Context) -> list | str:
stderr_output = b"".join(stderr_buffer).decode(self.output_encoding)
error_msg = f"Error running cmd: {self.command}, return code:
{return_code}, error: {stderr_output}"
raise AirflowException(error_msg)
+
+ def _decode(self, output: str) -> bytes:
+ decoded_output = base64.standard_b64decode(output)
+ self.hook.log_output(decoded_output,
output_encoding=self.output_encoding)
+ return decoded_output
+
+ def execute_complete(
+ self,
+ context: Context,
+ event: dict[Any, Any] | None = None,
+ ) -> Any:
+ """
+ Execute callback when WinRMCommandOutputTrigger finishes execution.
+
+ This method gets executed automatically when WinRMCommandOutputTrigger
completes its execution.
+ """
+ if event:
+ status = event.get("status")
+
+ if status == "error":
+ raise AirflowException(f"Trigger failed:
{event.get('message')}")
+
+ return_code = event.get("return_code")
+
+ self.log.info("%s completed with %s", self.task_id, status)
+
+ stdout = [self._decode(output) for output in event.get("stdout",
[])]
+ stderr = [self._decode(output) for output in event.get("stderr",
[])]
+
+ return self.evaluate_result(return_code, stdout, stderr)
+ return None
Review Comment:
Changed the method signature and remove the existence check on event
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]