I need to wait until a file is created then read it in. I have the below code, but sure it does not work:
import os.path
if os.path.isfile(file_path):
re
This code can check download by file size.
import os, sys
import time
def getSize(filename):
if os.path.isfile(filename):
st = os.stat(filename)
return st.st_size
else:
return -1
def wait_download(file_path):
current_size = getSize(file_path)
print("File size")
time.sleep(1)
while current_size !=getSize(file_path) or getSize(file_path)==0:
current_size =getSize(file_path)
print("current_size:"+str(current_size))
time.sleep(1)# wait download
print("Downloaded")