[Tutor] Checking a file size before moving it
Levy Lazarre
llazarre@yahoo.com
Fri Jan 31 00:16:14 2003
Hello to all,
I am writing a Python script that is intended to move
some files from directory A to directory B on a
server. Users copy the files to directory A once
daily. The Python script is triggered by a scheduler
and sweeps the directory for the files every 15
minutes. Obviously, I need to check that a file has
been completely written before attempting to move it.
On the Unix platform, I use the following scheme to
ascertain that a file is no longer being written:
stat the file and get its size(size1)
sleep for 10 seconds
stat the file again and get its size(size2)
if size2 == size1 proceed with the move operation
This works fine in Unix but I am not sure sleep works
OK in Win32 since I had some problems in the past
doing something similar with VB6. The timer would
sometimes trigger at the same time the files were
being
copied and incomplete files were moved to the target
directory.
Can anybody suggest a different way of checking if the
copy operation has been completed?
Thanks,
Levy Lazarre
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com