def exec_shell()

in solutions_builder/cli/cli_utils.py [0:0]


def exec_shell(command, working_dir=".", stop_when_error=True, stdout=None):
  """Execute shell commands"""
  proc = subprocess.Popen(command, cwd=working_dir, shell=True, stdout=stdout)
  exit_status = proc.wait()

  if exit_status != 0 and stop_when_error:
    raise RuntimeError(
        f"Error occurs when running command: {command} (working_dir={working_dir})")

  return exit_status