kaxil commented on code in PR #60651:
URL: https://github.com/apache/airflow/pull/60651#discussion_r2783198106


##########
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:
   Want to raise a Exception here? If the triggerer sends a `None` event 
(shouldn't happen in ideal state, but if it does), the task completes 
successfully with None return. This would mask failures.



-- 
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]

Reply via email to