<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"><html><head><meta name="qrichtext" content="1" /><style type="text/css">p, li { white-space: pre-wrap; }</style></head><body style=" font-family:'Bitstream Vera Sans'; font-size:10pt; font-weight:400; font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Hi Stefan,<br /></p><br /><br>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">thanks for your answer, the problem only appear when there is a link to a folder the same directory as the link and it begin with "./" that is a valid path in the unix world, so a workaround would be to replace './' with '../' if _st_target begin with "./". For now I solved with my own code, do you think you can add this workaround for the next ftputil version?<br /></p><br /><br>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">regards<br />Nicola<br /></p><br /><br>
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">In data domenica 26 aprile 2009 10:23:52, Stefan Schwarzer ha scritto:<br />: &gt; Hi Nicola,<br />&gt; <br />&gt; thanks for your report.<br />&gt; <br />&gt; On 2009-04-26 00:55, MailingList SVR wrote:<br />&gt; &gt; ftputil seems unable to follow links, go for example to:<br />&gt; &gt;<br />&gt; &gt; ftp.heanet.ie with an anonymous user,<br />&gt; &gt;<br />&gt; &gt; &gt;&gt;&gt; conn.path.islink('/pub/apache')<br />&gt; &gt; True<br />&gt; &gt; &gt;&gt;&gt; conn.listdir('/pub/apache')<br />&gt; &gt; ['/pub/apache']<br />&gt; &gt;<br />&gt; &gt; so listdir doesn't follow the link. Is there a workaround ?<br />&gt; <br />&gt; I can't reproduce this with my local FTP test server:<br />&gt; <br />&gt; &gt;&gt;&gt; h = ftputil.FTPHost("localhost", 'ftptest', ...)<br />&gt; &gt;&gt;&gt; h.path.islink("blah")<br />&gt; True<br />&gt; &gt;&gt;&gt; h.listdir("blah")<br />&gt; ['second dir', 'some file', 'some_file']<br />&gt; <br />&gt; The server is PureFTPd version 1.0.21-11.2ubuntu1. This server<br />&gt; setup is used for all the tests in the file _test_real_ftp.py.<br />&gt; Here, I only added the link.<br />&gt; <br />&gt; In your specific case, I can repeat the behavior, though.<br />&gt; <br />&gt; Since ftputil just displays the directory contents it gets from<br />&gt; the server, I think the result has something to do with the<br />&gt; server. Let's examine the situation:<br />&gt; <br />&gt; &gt;&gt;&gt; h = ftputil.FTPHost("ftp.heanet.ie", "anonymous", "sschwarzer@sschwarzer.net")<br />&gt; &gt;&gt;&gt; stat_result = h.lstat("/pub/apache")<br />&gt; &gt;&gt;&gt; stat_result._st_name<br />&gt; 'apache'<br />&gt; &gt;&gt;&gt; stat_result._st_target<br />&gt; './www.apache.org'<br />&gt; <br />&gt; (_st_name and _st_target have a leading underscore because<br />&gt; "native" stat result objects don't have those attributes either.<br />&gt; When I introduced the "stat-ing", I wanted to keep ftputil as<br />&gt; similar as possible to Python's native file system interface, so<br />&gt; I didn't disclose the attributes. ftputil uses them internally,<br />&gt; though.)<br />&gt; <br />&gt; If the link is resolved manually (the workaround you asked for),<br />&gt; this causes a traceback:<br />&gt; <br />&gt; &gt;&gt;&gt; stat_result = h.lstat("/pub/apache")<br />&gt; &gt;&gt;&gt; h.path.join("/pub/apache", stat_result._st_target)<br />&gt; '/pub/apache/./www.apache.org'<br />&gt; &gt;&gt;&gt; h.listdir(h.path.join("/pub/apache", stat_result._st_target))<br />&gt; Traceback (most recent call last):<br />&gt;   File "&lt;ipython console&gt;", line 1, in &lt;module&gt;<br />&gt;   File "ftputil.py", line 805, in listdir<br />&gt;     return self._stat.listdir(path)<br />&gt;   File "ftp_stat.py", line 565, in listdir<br />&gt;     return self.__call_with_parser_retry(self._real_listdir, path)<br />&gt;   File "ftp_stat.py", line 543, in __call_with_parser_retry<br />&gt;     result = method(*args, **kwargs)<br />&gt;   File "ftp_stat.py", line 406, in _real_listdir<br />&gt;     path)<br />&gt; PermanentError: 550 /pub/apache/www.apache.org: no such directory or wrong directory parser used<br />&gt; Debugging info: ftputil 2.4, Python 2.5.2 (linux2)<br />&gt; <br />&gt; I guess the selected parser, hinted at in the message, is ok<br />&gt; because I can list the root directory on the server and can get<br />&gt; the stat result for /pub/apache.<br />&gt; <br />&gt; So I assume the link on the server points to a non-existent or<br />&gt; otherwise invalid directory and the server upon the listdir call<br />&gt; decides to just return the path of the link.<br />&gt; <br />&gt; &gt; thanks<br />&gt; <br />&gt; You're welcome. :-)<br />&gt; <br />&gt; Best regards,<br />&gt; Stefan<br />&gt; <br />&gt; _______________________________________________<br />&gt; ftputil mailing list<br />&gt; ftputil@codespeak.net<br />&gt; http://codespeak.net/mailman/listinfo/ftputil<br />&gt; <br /></p><br /></p></body></html>