[ftputil] python stat versus FTPHost.stat Difference
Stefan Schwarzer
sschwarzer at sschwarzer.net
Sat Aug 30 23:30:34 CEST 2008
Hi Robert,
On 2008-08-30 22:37, Robert Hancock wrote:
>> 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.
>
> ftp> dir
> 227 Entering Passive Mode (127,0,0,1,41,19).
> 150 Here comes the directory listing.
> drwxrwxr-x 2 500 500 24576 Aug 29 03:06 archive
> -rw-r--r-- 1 500 500 4149948 Aug 29 03:05 proftp.log
> 226 Directory send OK.
> ftp> by
> 221 Goodbye.
Parsing seems to work:
>>> import ftputil
>>> import ftp_stat
>>> up = ftp_stat.UnixParser()
>>> up.parse_line("-rw-r--r-- 1 500 500 4149948 Aug 29 03:05 proftp.log")
(33188, None, None, 1, '500', '500', 4149948, None, 1219971900.0, None)
>>> t = _
>>> import time
>>> time.localtime(t[-2])
(2008, 8, 29, 3, 5, 0, 4, 242, 1)
> $ ls -la
> total 4092
> drwxrwxr-x 3 rhancock rhancock 4096 2008-08-28 22:15 .
> drwxrwxr-x 3 rhancock rhancock 4096 2008-08-28 21:48 ..
> drwxrwxr-x 2 rhancock rhancock 24576 2008-08-28 23:06 archive
> -rw-r--r-- 1 rhancock rhancock 4149948 2008-08-28 23:05 proftp.log
Ah! This seems to be a time shift issue. The server time is
four hours ahead of the client time, and I guess you haven't
done anything (yet) to deal with time shift.
Now, ftputil gets the directory listing from the server, and
because the file's date on the server is "Aug 29" _and_ on
the client August 29 _hasn't yet arrived_, ftputil assumes
"Aug 29" must be August 29 in 2007! (In my experience, the
directory output is made up according to this same rule, so
I have implemented the parser that way.) This makes the
one-year difference.
Please read the ftputil documentation and try to use the
time-shift-related commands. Please ask on the mailing list
if any more difficulties come up.
>> 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).
>
> This will take me a while to investigate. I'm using the command line
> utility of Fedora 9 to connect to vsfttp on the same machine.
I have no problem with that. :)
Do you have any objections to having me send your mail and
my reply to the ftputil list. You (perhaps accidentally) sent
your last mail only to me privately.
Best regards,
Stefan
More information about the ftputil
mailing list