def download_file(url, location, name_of_file, correct_hash):
  try:
    location, _ = urllib.urlretrieve(url, location)
    assert get_file_hash(location) == correct_hash
    print "\t" + name_of_file + " successfully downloaded."
    return location
  except IOError:
    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 ""
Attempts to download a file from the internet to the specified location.
dataset/ETHPy150Open google/fplutil/setuputil/util.py/download_file