Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > ftplib - file.write, file.close() - verify finished writing locally before delete source?

Reply
Thread Tools

ftplib - file.write, file.close() - verify finished writing locally before delete source?

 
 
Peter A. Schott
Guest
Posts: n/a
 
      02-10-2005
If I want to verify that a file has finished writing before deleting the remote
file, what would be the best method?

Current code on Python 2.4:

#filename - remote FTP server File Name
#NewFile - local file copy of the remote file
#objFTP - standard ftplib.FTP object

NewFile = open(os.path.join(InputPath, RemoteFileName), "wb")
objFTP.retrbinary("RETR " + filename, NewFile.write)
NewFile.close()

#Here is my problem - when I call this directly after NewFile.close(), I end up
#with 0-byte local file and successfully delete the remote file.

objFTP.delete(filename)


Any ideas on how to keep the remote file from being deleted if the local file
isn't finished writing? Any ideas on why I might be retrieving a 0-byte file
locally when I call like this? If I remove the delete statement, it seems to
work.

TIA,

-Pete Schott
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: writing a file locally using response.write bruce barker ASP .Net 0 12-09-2008 06:14 AM
x64 Finalizing Installation then Reboots before Finished =?Utf-8?B?Qm9i?= Windows 64bit 6 11-28-2005 07:15 PM
ftplib help - delete from server after download results in 0-byte file Peter A. Schott Python 0 02-01-2005 10:53 PM
Printing in ASP page before the script is finished Nico Leiska ASP General 1 02-12-2004 05:48 AM
ftplib question: how to upload files? python@sarcastic-horse.com Python 3 09-12-2003 11:48 AM



Advertisments