How to check a file saving is complete using Python?
Posted
by indrajithk
on Stack Overflow
See other posts from Stack Overflow
or by indrajithk
Published on 2010-05-17T09:46:57Z
Indexed on
2010/05/17
9:50 UTC
Read the original article
Hit count: 210
I am trying to automate a downloading process. In this I want to know, whether a particular file's save is completed or not. The scenario is like this.
- Open a site address using either Chrome or Firefox (any browser)
- Save the page to disk using 'Crtl + S' (I work on windows)
- Now if the page is very big, then it takes few seconds to save. I want to parse the html once the save is complete.
Since I don't have control on the browser save functionality, I don't know whether the save has completed or not.
One idea I thought, is to get the md5sum of the file using a while loop, and check against the previous one calculated, and continue the while loop till the md5 sum from the previous and current one matches. This doesn't works I guess, as it seems browser first attempts to save the file in a tmp file and then copies the content to the specified file (or just renames the file).
Any ideas? I use python for the automation, hence any idea which can be implemented using python is welcome.
Thanks Indrajith
© Stack Overflow or respective owner