def download_file(url, location, name_of_file, correct_hash):
  """Attempts to download a file from the internet to the specified location.

  If the file is not found, or the retrieval of the file failed, the
  exception will be caught and the system will exit.

  Args:
    url: A string of the URL to be retrieved.
    location: A string of the path the file will be downloaded to.
    name_of_file: A string with the name of the file, for printing purposes.
    correct_hash: A string with the expected SHA-1 hash of the file
  Returns:
    String: The location of the file, if the download is successful. Will
        return an empty string upon failure.
  """
  try:
    location, _ = urllib.urlretrieve(url, location)
    assert get_file_hash(location) == correct_hash
    print "\t" + name_of_file + " successfully downloaded."
    return location
  except __HOLE__:
    sys.stderr.write("\t" + name_of_file + " failed to download.\n")
    return ""
  except AssertionError:
    sys.stderr.write("\tIncorrect file downloaded. Please download " +
                     name_of_file + " manually.\n")
    return ""
dataset/ETHPy150Open google/fplutil/setuputil/util.py/download_file