airflow.providers.standard.hooks.subprocess

Module Contents

Classes

SubprocessHook

Hook for running processes with the subprocess module.

Functions

working_directory([cwd])

Context manager for handling (temporary) working directory.

Attributes

SubprocessResult

airflow.providers.standard.hooks.subprocess.SubprocessResult[source]
airflow.providers.standard.hooks.subprocess.working_directory(cwd=None)[source]

Context manager for handling (temporary) working directory.

Use the given cwd as working directory, if provided. Otherwise, create a temporary directory.

class airflow.providers.standard.hooks.subprocess.SubprocessHook(**kwargs)[source]

Bases: airflow.hooks.base.BaseHook

Hook for running processes with the subprocess module.

run_command(command, env=None, output_encoding='utf-8', cwd=None)[source]

Execute the command.

If cwd is None, execute the command in a temporary directory which will be cleaned afterwards. If env is not supplied, os.environ is passed

Parameters
  • command (list[str]) – the command to run

  • env (dict[str, str] | None) – Optional dict containing environment variables to be made available to the shell environment in which command will be executed. If omitted, os.environ will be used. Note, that in case you have Sentry configured, original variables from the environment will also be passed to the subprocess with SUBPROCESS_ prefix. See: https://airflow.apache.org/docs/apache-airflow/stable/administration-and-deployment/logging-monitoring/errors.html for details.

  • output_encoding (str) – encoding to use for decoding stdout

  • cwd (str | None) – Working directory to run the command in. If None (default), the command is run in a temporary directory.

Returns

namedtuple containing exit_code and output, the last line from stderr or stdout

Return type

SubprocessResult

send_sigterm()[source]

Send SIGTERM signal to self.sub_process if one exists.

Was this entry helpful?