def wait_for_installation(program, command=False, search=False, basedir=""):
  """Once installation has started, poll until completion.

  Once an asynchronous installation has started, wait for executable to exist.
  Poll every second, until executable is found or user presses ctrl-c.

  Args:
    program: A string representing the name of the program that is being
        installed.
    command: True if the program name needs to be run in order to test
        installation. False if it the executable can be searched for.
    search: True if the executable will not be on the path, and must be searched
        for, starting from the base directory given.
    basedir: If search is true, start from this directory when looking for the
        program. If search is false, basedir will be ignored.
  Returns:
    Boolean: Whether or not the the package finished installing
  """
  print("Waiting for installation to complete.\nAlternately, press Ctrl-C to "
        "quit, and rerun this script after installation has completed.")
  try:
    while command:
      try:
        subprocess.check_output(program, shell=True, stderr=subprocess.PIPE)
        return True
      except subprocess.CalledProcessError:
        time.sleep(DELAY)

    while search and not find_file(basedir, program):
      time.sleep(DELAY)

    while not search and not find_executable(program):
      time.sleep(DELAY)
  except __HOLE__:
    sys.stderr.write("Setup exited before completion.")
    return False
  return True
dataset/ETHPy150Open google/fplutil/setuputil/util.py/wait_for_installation