libftp.size function gives wrong results!

Michael Davis michael at damaru.com
Sun Jun 9 11:51:19 EDT 2002


Hi,

I'm writing a python program which will upload or download files via ftp. 
It's intended to be used to deploy a web site from a local machine to a 
server. It tries to determine which files are modified on the local machine 
by comparing file sizes and modification times.

I try to compare files using os.stat for the local file and FTP.size for the 
remote. The problem is, FTP.size is giving me incorrect results. If I use 
the ftp command line client, and look at one of my files on the server (the 
output looks like 'ls -l') then I can see that the file size, is, say, 
1200. But the FTP.size function returns, say, 1242. This happens for all 
the files, they're all reported to be about 5% larger than they really are.

Is there a better way of doing this, aside from capturing the output of 
FTPLIB.dir (which goes to stdout) and parsing it?

Thanks in advance!
-- 
Michael Davis
Damaru
Custom Programming - Web Development - Database Design
http://www.damaru.com
416-540-1284



More information about the Python-list mailing list