[ftputil] python stat versus FTPHost.stat Difference
Stefan Schwarzer
sschwarzer at sschwarzer.net
Fri Aug 29 18:55:22 CEST 2008
Hello Robert,
Thanks for your report!
On 2008-08-29 06:05, Robert Hancock wrote:
> Python 2.5.2 (r252:60911, Aug 28 2008, 23:51:17)
> [GCC 4.3.0 20080428 (Red Hat 4.3.0-8)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import ftputil
>>>> host = ftputil.FTPHost('localhost', 'rhancock', 'test')
>>>> res = host.stat('/local/data/proftp/proftp.log')
>>>> res[8]
> 1188371100.0
>>>> import os
>>>> res = os.stat('/local/data/proftp/proftp.log')
>>>> res[8]
> 1219979117
This is quite interesting. That's a difference of "exactly" one
year (365.83 days, if my calculation is correct). Could you
please log in to the FTP server with an FTP command line client
(if you hopefully have one) and send the output of a DIR command
of the directory which contains the file? I would like to know if
ftputil's parsing of the data fails or if the data going into the
parser already isn't as expected.
> Issuing a stat on a local file from ftputil and from python produces two
> different results. Why?
I don't know yet. :-) Please send me the output I asked for
above. :)
> Given the today's date, the python stat produces the correct result. Is
> there something I need to set in ftputil?
First, you may have to account for time shift between server and
client (the computer running ftputil) by using
FTPHost.synchronize_times or setting the time shift "manually"
with FTPHost.set_time_shift (see the documentation for details).
To my surprise, I found that you can have time shift issues even
if server and client run on the same host: After an update some
time ago, my local PureFTPd server always used UTC times in
directory listings while the client code to test ftputil expected
the local time zone (Middle European Time with DST).
Second, depending on the age of the file on the server, it may
return only the date, not the time, of the file. In that case,
the best ftputil can do is to convert just this date to a float.
This can result in stat'ed timestamp differences between the
local and the remote file of up to a day! For instance, if
ftputil gets a file's timestamp as "May 29 2000", it can't know
if the modification _time_ actually was 0:01 or 23:59.
Best regards,
Stefan
More information about the ftputil
mailing list