def execute_process()

in google_cloud_automlops/utils/utils.py [0:0]


def execute_process(command: str, to_null: bool):
    """Executes an external shell process.

    Args:
        command (str): Command to execute.
        to_null (bool): Determines where to send output.

    Raises:
        Exception: An error occured while executing the script.
    """
    stdout = subprocess.DEVNULL if to_null else None
    try:
        subprocess.run([command],
                       shell=True,
                       check=True,
                       stdout=stdout,
                       stderr=subprocess.STDOUT)
    except subprocess.CalledProcessError as err:
        raise RuntimeError(f'Error executing process. {err}') from err