I am trying to figure out how to check if a download has been completed. Basically I want it to wait until the file is finished downloading then print: Download completed.
Here is my current code and what I am trying to do with it:
from urllib import request
print("Are you sure you want to download the newest file? y/n")
answer = input()
while True:
if answer == 'y':
print("Downloading file...")
downloading = True
request.urlretrieve("FILE_URL", "FILE_NAME")
elif answer == 'n':
exit()
else:
print("That is not a valid answer, please answer with y/n.")
answer = input()
#I need some sort of function here that checks if the file is still being
#downloaded
when downloading == False:
print("Download Completed.")