# Path: ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/execute_process_nopty.py
# def _execute_process_nopty(cmd, cwd, env, shell, stderr_to_stdout=True):
#     if stderr_to_stdout:
#         p = Popen(cmd,
#                   stdin=PIPE, stdout=PIPE, stderr=STDOUT,
#                   cwd=cwd, env=env, shell=shell, close_fds=False)
#     else:
#         p = Popen(cmd,
#                   stdin=PIPE, stdout=PIPE, stderr=PIPE,
#                   cwd=cwd, env=env, shell=shell, close_fds=False)
# 
#     # Left over data from read which isn't a complete line yet
#     left_overs = {p.stdout: b'', p.stderr: b''}
# 
#     fds = list(filter(None, [p.stdout, p.stderr]))
# 
#     return _yield_data(p, fds, left_overs, os.linesep)


import os
import sys
from .execute_process_nopty import _execute_process_nopty
    from .execute_process_pty import _execute_process_pty
    from shutil import which as _which

    :py:func:`osrf_pycommon.terminal_color.remove_ansi_escape_senquences`

    Exceptions can be raised by functions called by the implementation,
    for example, :py:class:`subprocess.Popen` can raise an :py:exc:`OSError`
    when the given command is not found.
    If you want to check for the existence of an executable on the path,
    see: :py:func:`which`.
    However, this function itself does not raise any special exceptions.

    :param list cmd: list of strings with the first item being a command
        and subsequent items being any arguments to that command;
        passed directly to :py:class:`subprocess.Popen`.
    :param str cwd: path in which to run the command, defaults to None which
        means :py:func:`os.getcwd` is used;
        passed directly to :py:class:`subprocess.Popen`.
    :param dict env: environment dictionary to use for executing the command,
        default is None which uses the :py:obj:`os.environ` environment;
        passed directly to :py:class:`subprocess.Popen`.
    :param bool shell: If True the system shell is used to evaluate the
        command, default is False;
        passed directly to :py:class:`subprocess.Popen`.
    :param bool emulate_tty: If True attempts to use a pty to convince
        subprocess's that they are being run in a terminal. Typically this is
        useful for capturing colorized output from commands. This does not
        work on Windows (no pty's), so it is considered False even when True.
        Defaults to False.
    :returns: a generator which yields output from the command line by line
    :rtype: generator which yields strings
    """

# Path: ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/execute_process_nopty.py
# def _execute_process_nopty(cmd, cwd, env, shell, stderr_to_stdout=True):
#     if stderr_to_stdout:
#         p = Popen(cmd,
#                   stdin=PIPE, stdout=PIPE, stderr=STDOUT,
#                   cwd=cwd, env=env, shell=shell, close_fds=False)
#     else:
#         p = Popen(cmd,
#                   stdin=PIPE, stdout=PIPE, stderr=PIPE,
#                   cwd=cwd, env=env, shell=shell, close_fds=False)
# 
#     # Left over data from read which isn't a complete line yet
#     left_overs = {p.stdout: b'', p.stderr: b''}
# 
#     fds = list(filter(None, [p.stdout, p.stderr]))
# 
#     return _yield_data(p, fds, left_overs, os.linesep)


# Path: ros2_batch_job/vendor/osrf_pycommon/osrf_pycommon/process_utils/impl.py
import os
import sys
from .execute_process_nopty import _execute_process_nopty
    from .execute_process_pty import _execute_process_pty
    from shutil import which as _which


    :py:func:`osrf_pycommon.terminal_color.remove_ansi_escape_senquences`

    Exceptions can be raised by functions called by the implementation,
    for example, :py:class:`subprocess.Popen` can raise an :py:exc:`OSError`
    when the given command is not found.
    If you want to check for the existence of an executable on the path,
    see: :py:func:`which`.
    However, this function itself does not raise any special exceptions.

    :param list cmd: list of strings with the first item being a command
        and subsequent items being any arguments to that command;
        passed directly to :py:class:`subprocess.Popen`.
    :param str cwd: path in which to run the command, defaults to None which
        means :py:func:`os.getcwd` is used;
        passed directly to :py:class:`subprocess.Popen`.
    :param dict env: environment dictionary to use for executing the command,
        default is None which uses the :py:obj:`os.environ` environment;
        passed directly to :py:class:`subprocess.Popen`.
    :param bool shell: If True the system shell is used to evaluate the
        command, default is False;
        passed directly to :py:class:`subprocess.Popen`.
    :param bool emulate_tty: If True attempts to use a pty to convince
        subprocess's that they are being run in a terminal. Typically this is
        useful for capturing colorized output from commands. This does not
        work on Windows (no pty's), so it is considered False even when True.
        Defaults to False.
    :returns: a generator which yields output from the command line by line
    :rtype: generator which yields strings
    """

    exp_func = _execute_process_nopty