<!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;">In data domenica 26 aprile 2009 12:11:31, MailingList SVR ha scritto:<br>
: &gt; Hi Stefan,<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; 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>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; regards<br>
&gt; Nicola<br>
&gt; <br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>additionally I tested standard ftp clients (filezilla and cli linux  ftp client) and they resolve the link and then show the content<br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p>&gt; <br>
&gt; <br>
&gt; In data domenica 26 aprile 2009 10:23:52, Stefan Schwarzer ha scritto:<br>
&gt; : &gt; Hi Nicola,<br>
&gt; &gt; <br>
&gt; &gt; thanks for your report.<br>
&gt; &gt; <br>
&gt; &gt; On 2009-04-26 00:55, MailingList SVR wrote:<br>
&gt; &gt; &gt; ftputil seems unable to follow links, go for example to:<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; ftp.heanet.ie with an anonymous user,<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; &gt;&gt;&gt; conn.path.islink('/pub/apache')<br>
&gt; &gt; &gt; True<br>
&gt; &gt; &gt; &gt;&gt;&gt; conn.listdir('/pub/apache')<br>
&gt; &gt; &gt; ['/pub/apache']<br>
&gt; &gt; &gt;<br>
&gt; &gt; &gt; so listdir doesn't follow the link. Is there a workaround ?<br>
&gt; &gt; <br>
&gt; &gt; I can't reproduce this with my local FTP test server:<br>
&gt; &gt; <br>
&gt; &gt; &gt;&gt;&gt; h = ftputil.FTPHost("localhost", 'ftptest', ...)<br>
&gt; &gt; &gt;&gt;&gt; h.path.islink("blah")<br>
&gt; &gt; True<br>
&gt; &gt; &gt;&gt;&gt; h.listdir("blah")<br>
&gt; &gt; ['second dir', 'some file', 'some_file']<br>
&gt; &gt; <br>
&gt; &gt; The server is PureFTPd version 1.0.21-11.2ubuntu1. This server<br>
&gt; &gt; setup is used for all the tests in the file _test_real_ftp.py.<br>
&gt; &gt; Here, I only added the link.<br>
&gt; &gt; <br>
&gt; &gt; In your specific case, I can repeat the behavior, though.<br>
&gt; &gt; <br>
&gt; &gt; Since ftputil just displays the directory contents it gets from<br>
&gt; &gt; the server, I think the result has something to do with the<br>
&gt; &gt; server. Let's examine the situation:<br>
&gt; &gt; <br>
&gt; &gt; &gt;&gt;&gt; h = ftputil.FTPHost("ftp.heanet.ie", "anonymous", "sschwarzer@sschwarzer.net")<br>
&gt; &gt; &gt;&gt;&gt; stat_result = h.lstat("/pub/apache")<br>
&gt; &gt; &gt;&gt;&gt; stat_result._st_name<br>
&gt; &gt; 'apache'<br>
&gt; &gt; &gt;&gt;&gt; stat_result._st_target<br>
&gt; &gt; './www.apache.org'<br>
&gt; &gt; <br>
&gt; &gt; (_st_name and _st_target have a leading underscore because<br>
&gt; &gt; "native" stat result objects don't have those attributes either.<br>
&gt; &gt; When I introduced the "stat-ing", I wanted to keep ftputil as<br>
&gt; &gt; similar as possible to Python's native file system interface, so<br>
&gt; &gt; I didn't disclose the attributes. ftputil uses them internally,<br>
&gt; &gt; though.)<br>
&gt; &gt; <br>
&gt; &gt; If the link is resolved manually (the workaround you asked for),<br>
&gt; &gt; this causes a traceback:<br>
&gt; &gt; <br>
&gt; &gt; &gt;&gt;&gt; stat_result = h.lstat("/pub/apache")<br>
&gt; &gt; &gt;&gt;&gt; h.path.join("/pub/apache", stat_result._st_target)<br>
&gt; &gt; '/pub/apache/./www.apache.org'<br>
&gt; &gt; &gt;&gt;&gt; h.listdir(h.path.join("/pub/apache", stat_result._st_target))<br>
&gt; &gt; Traceback (most recent call last):<br>
&gt; &gt;   File "&lt;ipython console&gt;", line 1, in &lt;module&gt;<br>
&gt; &gt;   File "ftputil.py", line 805, in listdir<br>
&gt; &gt;     return self._stat.listdir(path)<br>
&gt; &gt;   File "ftp_stat.py", line 565, in listdir<br>
&gt; &gt;     return self.__call_with_parser_retry(self._real_listdir, path)<br>
&gt; &gt;   File "ftp_stat.py", line 543, in __call_with_parser_retry<br>
&gt; &gt;     result = method(*args, **kwargs)<br>
&gt; &gt;   File "ftp_stat.py", line 406, in _real_listdir<br>
&gt; &gt;     path)<br>
&gt; &gt; PermanentError: 550 /pub/apache/www.apache.org: no such directory or wrong directory parser used<br>
&gt; &gt; Debugging info: ftputil 2.4, Python 2.5.2 (linux2)<br>
&gt; &gt; <br>
&gt; &gt; I guess the selected parser, hinted at in the message, is ok<br>
&gt; &gt; because I can list the root directory on the server and can get<br>
&gt; &gt; the stat result for /pub/apache.<br>
&gt; &gt; <br>
&gt; &gt; So I assume the link on the server points to a non-existent or<br>
&gt; &gt; otherwise invalid directory and the server upon the listdir call<br>
&gt; &gt; decides to just return the path of the link.<br>
&gt; &gt; <br>
&gt; &gt; &gt; thanks<br>
&gt; &gt; <br>
&gt; &gt; You're welcome. :-)<br>
&gt; &gt; <br>
&gt; &gt; Best regards,<br>
&gt; &gt; Stefan<br>
&gt; &gt; <br>
&gt; &gt; _______________________________________________<br>
&gt; &gt; ftputil mailing list<br>
&gt; &gt; ftputil@codespeak.net<br>
&gt; &gt; http://codespeak.net/mailman/listinfo/ftputil<br>
&gt; &gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; -qt-user-state:0;"><br></p></body></html>