Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@
import os
from collections.abc import Callable, Container, Sequence
from datetime import datetime
from subprocess import STDOUT, Popen
from subprocess import STDOUT, Popen, SubprocessError
from time import sleep
from typing import TYPE_CHECKING, Any

from airflow.models import BaseOperator
from airflow.models.dag import DAG
from airflow.models.variable import Variable
from airflow.providers.common.compat.sdk import (
AirflowException,
AirflowNotFoundException,
AirflowSkipException,
)
Expand Down Expand Up @@ -125,7 +124,7 @@ class CmdOperator(BaseOperator):
* - `skip_on_exit_code` (default: 99)
- raise :class:`airflow.exceptions.AirflowSkipException`
* - otherwise
- raise :class:`airflow.exceptions.AirflowException`
- raise :class:`subprocess.SubprocessError`

.. warning::

Expand Down Expand Up @@ -210,9 +209,9 @@ def get_env(self, context):
def execute(self, context: Context):
if self.cwd is not None:
if not os.path.exists(self.cwd):
raise AirflowException(f"Can not find the cwd: {self.cwd}")
raise SubprocessError(f"Can not find the cwd: {self.cwd}")
if not os.path.isdir(self.cwd):
raise AirflowException(f"The cwd {self.cwd} must be a directory")
raise SubprocessError(f"The cwd {self.cwd} must be a directory")
env = self.get_env(context)

# Because the command value is evaluated at runtime using the @task.command decorator, the
Expand All @@ -237,7 +236,7 @@ def execute(self, context: Context):
if exit_code in self.skip_on_exit_code:
raise AirflowSkipException(f"Command returned exit code {exit_code}. Skipping.")
if exit_code != 0:
raise AirflowException(f"Command failed. The command returned a non-zero exit code {exit_code}.")
raise SubprocessError(f"Command failed. The command returned a non-zero exit code {exit_code}.")

return self.output_processor(outs)

Expand Down
1 change: 0 additions & 1 deletion scripts/ci/prek/known_airflow_exceptions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ providers/discord/src/airflow/providers/discord/operators/discord_webhook.py::1
providers/docker/src/airflow/providers/docker/decorators/docker.py::1
providers/docker/src/airflow/providers/docker/hooks/docker.py::3
providers/docker/src/airflow/providers/docker/operators/docker_swarm.py::2
providers/edge3/src/airflow/providers/edge3/example_dags/win_test.py::3
providers/fab/src/airflow/providers/fab/auth_manager/fab_auth_manager.py::3
providers/fab/src/airflow/providers/fab/auth_manager/models/db.py::1
providers/fab/src/airflow/providers/fab/www/extensions/init_security.py::1
Expand Down
Loading